Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'NoneType' object is not subscriptable #4

Open
APOC00X opened this issue May 29, 2018 · 4 comments
Open

TypeError: 'NoneType' object is not subscriptable #4

APOC00X opened this issue May 29, 2018 · 4 comments

Comments

@APOC00X
Copy link

APOC00X commented May 29, 2018

TypeError: 'NoneType' object is not subscriptable

TypeError Traceback (most recent call last)
~/Desktop/.../ocrlearnKnn.py in ()
65 while True:
66 ret, frame = cap.read()
---> 67 frame = frame[:,:426]
68 rois, edges = findRoi(frame, 50)
69 digits = []
TypeError: 'NoneType' object is not subscriptable

run with jupyter notebook 5.50 in anaconda
python 3.6.5
cv 3.4.1
Macbook Air

@yiminzme
Copy link
Contributor

yiminzme commented Jun 4, 2018

At ocrlearnKnn.py:58, try other parameter such as 0, 2 or 3, etc. That is the parameter for camera index. Typically, parameter 0 would work for a computer with one camera.

cap = cv2.VideoCapture(0)

@APOC00X
Copy link
Author

APOC00X commented Jun 6, 2018

Thank you very much
That worked but, another error happened...

error Traceback (most recent call last)
~/Desktop/.../digitsOCR-master/ocrlearnKnn.py in ()
77 newFrame = np.hstack((frame,newEdges))
78 cv2.imshow('frame', newFrame)
---> 79 videoFrame.write(newFrame)
80 key = cv2.waitKey(1) & 0xff
81 if key == ord(' '):

error: OpenCV(3.4.1) /opt/conda/conda-bld/opencv-suite_1527005509093/work/modules/videoio/src/cap_mjpeg_encoder.cpp:468: error: (-215) imgWidth == frameWidth && imgHeight == frameHeight && channels == 3 in function write

I tried to move those '#'s before the defining of 'width' and 'height' but no effect...

@yiminzme
Copy link
Contributor

yiminzme commented Jun 6, 2018

Yeah, the width and height are fixed, so it might not work. You can try my version https://github.com/vinc96/digitsOCR, which automatically fetch the width and height information and works on my Windows and Mac. If you have a chance to try it, please tell me if it works.
I also created a pull request for solving this issue.

@APOC00X
Copy link
Author

APOC00X commented Jun 8, 2018

!!!That worked smoothly ! I would very much appreciate receiving your help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants