mardi 27 mai 2014

python - CvtColor erreur à des résolutions plus élevées - Stack Overflow


I have a Logitech Pro 9000 webcam and right now I try to learn OpenCV. I use OpenCV 2.4.5 together with Python 2.7. I'm having problems with the CvtColor function at higher resolutions. The following script is working in 640x480, but not with higher resolutions (800X600 and up).


import cv

cv.NamedWindow("Video", cv.CV_WINDOW_AUTOSIZE)

camera_index = 1
capture = cv.CaptureFromCAM(camera_index)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH,1200)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT,800)

grey_frame = cv.CreateImage((1200,800),8,1)

while True:
input_frame = cv.QueryFrame(capture)
cv.CvtColor(input_frame,grey_frame,cv.CV_BGR2GRAY)
cv.WaitKey(5)
cv.ShowImage("Video", grey_frame)

I get the following error


cv2.error: dst.data == dst0.data

EDIT: SOLVED After saving the captured input_frame. I noticed that the resolution of the saved image is not matching my set values. I set 1200x800 as capture properties and got a 1280x800 image. After using this resolution, everything worked fine.




After saving the captured input_frame. I noticed that the resolution of the saved image is not matching my set values. I set 1200x800 as capture properties and got a 1280x800 image. After using this resolution, everything worked fine.



I have a Logitech Pro 9000 webcam and right now I try to learn OpenCV. I use OpenCV 2.4.5 together with Python 2.7. I'm having problems with the CvtColor function at higher resolutions. The following script is working in 640x480, but not with higher resolutions (800X600 and up).


import cv

cv.NamedWindow("Video", cv.CV_WINDOW_AUTOSIZE)

camera_index = 1
capture = cv.CaptureFromCAM(camera_index)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_WIDTH,1200)
cv.SetCaptureProperty(capture,cv.CV_CAP_PROP_FRAME_HEIGHT,800)

grey_frame = cv.CreateImage((1200,800),8,1)

while True:
input_frame = cv.QueryFrame(capture)
cv.CvtColor(input_frame,grey_frame,cv.CV_BGR2GRAY)
cv.WaitKey(5)
cv.ShowImage("Video", grey_frame)

I get the following error


cv2.error: dst.data == dst0.data

EDIT: SOLVED After saving the captured input_frame. I noticed that the resolution of the saved image is not matching my set values. I set 1200x800 as capture properties and got a 1280x800 image. After using this resolution, everything worked fine.



After saving the captured input_frame. I noticed that the resolution of the saved image is not matching my set values. I set 1200x800 as capture properties and got a 1280x800 image. After using this resolution, everything worked fine.


0 commentaires:

Enregistrer un commentaire