Python Forum
how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) (/thread-6354.html)

Pages: 1 2


how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - bedio - Nov-18-2017

hello, i am trying to use the pydlssvm code found on internet but i still getting error on the test_camera file i can not make a real tracking.

actually i am getting this error can someone help me to solve it? also if one of you have a perfect working code of the DLSSVM please send to me

this is my current error
return np.concatenate(layers, axis=2).astype("float64")
IndexError: axis 2 out of bounds [0, 2)


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - heiner55 - Nov-18-2017

What is pydlssvm ?

Meanwhile I found myself:
https://github.com/djosix/PyDLSSVM

Your error message means:
   You should use 0 or 1 for axis, not 2.
You should open an issue at https://github.com/djosix/PyDLSSVM, if you think it is an error.


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - bedio - Nov-18-2017

yes it is that. all the step worked until the last one which is test_camera.py that is not working for me. if you know how to do help me.


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - buran - Nov-18-2017

Please, post the entire traceback that you get. We need to see the whole thing. Do not just give us the last line. Take a time to read What to include in a post


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - bedio - Nov-18-2017

Error:
('tracker.config:', {'search': 1.3, 'rescale': 0.2, 'sv_max': 100, 'Q': 10, 'P': 5, 'step': 2}) Start real-time tracking on camera --------------------------------------- /usr/local/lib/python2.7/dist-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15. warn("The default mode, 'constant', will be changed to 'reflect' in " Traceback (most recent call last): File "/home/soro/eclipse-workspace/MYSSVM.zip_expanded/PyDLSSVM-master/test_camera.py", line 69, in <module> output = tracker.track(frame) File "/home/soro/eclipse-workspace/MYSSVM.zip_expanded/PyDLSSVM-master/dlssvm_tracker/tracker.py", line 76, in track sampler = Sampler(frame, self.target, self.config) File "/home/soro/eclipse-workspace/MYSSVM.zip_expanded/PyDLSSVM-master/dlssvm_tracker/sampler.py", line 22, in __init__ self.features = self._get_features(cropped) File "/home/soro/eclipse-workspace/MYSSVM.zip_expanded/PyDLSSVM-master/dlssvm_tracker/sampler.py", line 80, in _get_features return np.concatenate(layers, axis=2).astype("float64") IndexError: axis 2 out of bounds [0, 2)



RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - heiner55 - Nov-18-2017

Error:
/usr/local/lib/python2.7/...
The demo from github needs Python 3.x:
python3 test_camera.py


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - bedio - Nov-18-2017

ok i set the python command to python3.5 and chose python3 for the interpreter in pydev in eclipse and it termited without error but northing
tracker.config: {'search': 1.3, 'step': 2, 'sv_max': 100, 'Q': 10, 'rescale': 0.2, 'P': 5}
Start real-time tracking on camera
---------------------------------------



RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - bedio - Nov-18-2017

i have tried to understand why it was not working. and i think now the problem is from python3 because i am using opencv 3.3 and i can read video with interpreter fixed on python2 but when i compile with python3 it gave me norming it just terminate here is an example of code supose to work with python3 but it does not
import numpy as np
import cv2


 
cap = cv2.VideoCapture(0)
 
while(cap.isOpened()):  # check !
    # capture frame-by-frame
    ret, frame = cap.read()
 
    if ret: # check ! (some webcam's need a "warmup")
        # our operation on frame come here
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
 
        # Display the resulting frame
        cv2.imshow('frame', gray)
 
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
# When everything is done release the capture
cap.release()
cv2.destroyAllWindows()
maybe if i can make this code work it will be the same for the tracking project.


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - heiner55 - Nov-18-2017

Keep me uptodate.


RE: how to solve this problem. IndexError: axis 2 out of bounds [0, 2) - bedio - Nov-20-2017

i tried the same code on my laptop and it work fine without any modification and no eror. i think it should be my desktop which have problem
thank you