Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

OpenVINO env open camera slowly and `cam.set()` always return False.

zhao__wang
Beginner
866 Views

Usb camera's FPS, width, height could change if I use `cam.set()`, although it always return and `cam.get()` cann't get the value what I set.  
The truth is everything works fine when I compiled opencv without IE backend, I didn't specify or change any camera backend.  

Thanks, appreciate for your reply.

0 Kudos
4 Replies
Shubha_R_Intel
Employee
866 Views

Dear zhao, wang,

Can you kindly attach a code snippet which shows the problem ? Also are you using OpenVino 2019 R1 ? If not, please re-try on 2019 R1 as many bugs and issues have been fixed.

Thanks,

Shubha

 

0 Kudos
Shubha_R_Intel
Employee
866 Views

Dear zhao, wang,

Additionally, things related to the camera are not in the purview of OpenVino (Model Optimizer and Inference Engine) issues.  Those are OpenCV related issues. Perhaps my answer to this post will help you :

https://software.intel.com/en-us/forums/computer-vision/topic/806937

In the meantime, thank you for using OpenVino and please post your findings here !

Thanks,

Shubha

0 Kudos
zhao__wang
Beginner
866 Views

Shubha R. (Intel) wrote:

Dear zhao, wang,

Can you kindly attach a code snippet which shows the problem ? Also are you using OpenVino 2019 R1 ? If not, please re-try on 2019 R1 as many bugs and issues have been fixed.

Thanks,

Shubha

 

 

@Shubha R. (Intel) Sorry for the delay, my mailbox marks the message as spam.  

Here is my code with abnormal output:

print('cv2 ver: ', cv2.__version__)  # --> cv2 ver: 4.0.1-openvino
cam = cv2.VideoCapture(0)
if not cam.isOpened():
    raise Exception('Camera failed to open.')
ret_FPS = cam.set(cv2.CAP_PROP_FPS, 30)  # --> False
ret_Wid = cam.set(cv2.CAP_PROP_FRAME_WIDTH, 320)  # --> False
ret_Hei = cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)  # --> False
print('cam.get(5): {}, cam.get(3): {}, cam.get(4): {}'
      .format(cam.get(5), cam.get(3), cam.get(4)))
# --> return 30, 1280, 720
ret, frame = cam.read()
print('frame.shape: ', frame.shape)  # --> (240, 320)

Because opencv compiled by myself work well, so at first, I thought that was openVINO built-in cv's problem. But the fact is that this problem is caused by opencv default video backend. I change video backend to v4l, work well.  

Here is the correct version:

print('cv2 ver: ', cv2.__version__)  # --> cv2 ver: 4.0.1-openvino
cam = cv2.VideoCapture(0 + cv2.CAP_V4L)
if not cam.isOpened():
    raise Exception('Camera failed to open.')
ret_FPS = cam.set(cv2.CAP_PROP_FPS, 30)  # --> True
ret_Wid = cam.set(cv2.CAP_PROP_FRAME_WIDTH, 320)  # --> True
ret_Hei = cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)  # --> True
print('cam.get(5): {}, cam.get(3): {}, cam.get(4): {}'
      .format(cam.get(5), cam.get(3), cam.get(4)))
# --> return 30, 320, 240
ret, frame = cam.read()
print('frame.shape: ', frame.shape)  # --> (240, 320)

 

0 Kudos
Shubha_R_Intel
Employee
866 Views

Dear zhao, wang,

Thank you for reporting back. Glad you found a way to make it work. I'm happy that you realize that this is an OpenCV issue, not a Model Optimizer or Inference Engine one.

Thanks for using OpenVino !

Shubha

 

0 Kudos
Reply