Ask Your Question

UtkarshV's profile - activity

2014-01-10 20:35:27 -0500 received badge  Nice Answer (source)
2014-01-05 21:29:08 -0500 received badge  Teacher (source)
2014-01-05 00:16:52 -0500 commented answer Why this error in cvtColor function happens?

Thanks. Was facing something similar. This fixed my problem.

2014-01-05 00:14:43 -0500 received badge  Editor (source)
2014-01-05 00:13:51 -0500 answered a question How to fix OpenCV Error Assertion ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) ) ?

Do a truth check after capture.read on the returned value, if the return is true, only then proceed. I faced a similar problem, this fixed that.

See this example:

import numpy as np
import cv2

cap=cv2.VideoCapture(0)  
while(cap.isOpened()):
    #cpature frame by frame
    ret,frame=cap.read()
    if(ret):        #if cam read is successful

        #ops here:
        gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

        #disp the resulting frame
        cv2.imshow('Grayframe :: q to exit',gray)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
#when everything else done,release capture
cap.release()
cv2.destroyAllWindows()
2014-01-04 23:42:53 -0500 commented question Why this error in cvtColor function happens?

I'm facing a similar issue. Oddly the same code works with ver2.43 and not with ver2.47. Could you please write about how you resolved it?

2014-01-04 23:33:14 -0500 commented answer Is there any official IRC for OpenCV?

+1 would be great to have an official channel.

2014-01-04 23:32:52 -0500 received badge  Supporter (source)