I am running a simple network on keras using theano and opencv. I am getting a segmentation fault error while executing cvtColor() method. code snippet:
if __name__ == '__main__':
cap = cv2.VideoCapture(0)
if not cap:
print "!!! Failed VideoCapture: unable to open device 0"
sys.exit(1)
cascade_path = "~/opencv-2.4.13.2/data/haarcascades/haarcascade_frontalface_default.xml"
model = Model()
model.load()
while True:
pdb.set_trace()
_, frame = cap.read()
frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cascade = cv2.CascadeClassifier(cascade_path)
Below is the debug info:
Model Loaded.
>
-> _, frame = cap.read()
(Pdb) n
-> frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
(Pdb) list
16 while True:
17 pdb.set_trace()
18 _, frame = cap.read()
19
20
21 -> frame_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
22
23
24 cascade = cv2.CascadeClassifier(cascade_path)
25
26
(Pdb) n
Segmentation fault
It crashes the moment cv2.cvtColor() is invoked. frame variable has required (Pdb) frame.size 921600
I even used cv2.imshow("color_image", frame) to display the colored frame and its displayed correctly. But, the moment I convert it to grayscale it crashes!
I am using OpenCV2.4 at the moment. Yesterday, the same code was working properly on OpenCV3.2. For some reasons I had to downgrade the opencv lib.
Any suggestions to resolve this problem?
Thanks.