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.

Human pose estimation demo error

Lc00
Beginner
990 Views

Hi, I am trying to convert the frame into grayscale by using the open_images_capture function. There has an error when the frame is converting into grayscale. The figure below shows the error message.

Lc00_2-1649316308754.png

Is there any solution to solve it?

 

Thank you.

0 Kudos
1 Solution
Hairul_Intel
Moderator
923 Views

Hi Lc00,

Based on the limited information shared from your code snippet, I was not able to fully comprehend how your demo is running. However, you did mention that it works if you use cv2.VideoCapture instead of the open_images_capture function.

 

For your information, the open_images_capture function is somewhat similar to the workaround code I shared previously. The difference is that the open_images_capture function does not return the status value which is needed to check whether the frame is available to be loaded before the cvtColor function.

 

Here is the code snippet from open_images_capture as an example:

status.png

 

I would suggest you try these possible methods:

  1. Call your cvtColor function after the if not status inside of the open_images_capture function.
  2. Return the status value to your function and use the previous workaround code.

 

 

 

Regards,

Hairul

 

View solution in original post

0 Kudos
5 Replies
Hairul_Intel
Moderator
960 Views

Hi Lc00,

Thank you for reaching out to us.

 

This error occurs when the image is not properly loaded in OpenCV. Please ensure the following:

  • Verify the image exists in the path that you have given.
  • Verify that your webcam is not being used on another task.

 

 

Asides from that, when using cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) function, OpenCV is unable to read the final frame of the video as the object passed to cvtColor function is empty. You can refer to this GitHub discussion (This is an external link and is not maintained by Intel).

 

Here is an example workaround code that you can try:

source = cv2.VideoCapture('video.mp4')

 

while True:

   ret, img = source.read()

   if ret == False:

       break

   

   gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

   

   cv2.imshow("Live", gray)

   

   key = cv2.waitKey(1)

   if key == ord("q"):

       break

 

cv2.destroyAllWindows()

source.release()

 

 

 

Regards,

Hairul


0 Kudos
Lc00
Beginner
932 Views

Thank you for the information. 

I have already tried the code you have given is working but when I replace the cv2.VideoCapture with open_images_capture function which existing in omz/demos/common/python there have errors like the picture shown above. Below is my code.

Lc00_0-1649687000944.pngLc00_1-1649687079823.png

 

0 Kudos
Hairul_Intel
Moderator
924 Views

Hi Lc00,

Based on the limited information shared from your code snippet, I was not able to fully comprehend how your demo is running. However, you did mention that it works if you use cv2.VideoCapture instead of the open_images_capture function.

 

For your information, the open_images_capture function is somewhat similar to the workaround code I shared previously. The difference is that the open_images_capture function does not return the status value which is needed to check whether the frame is available to be loaded before the cvtColor function.

 

Here is the code snippet from open_images_capture as an example:

status.png

 

I would suggest you try these possible methods:

  1. Call your cvtColor function after the if not status inside of the open_images_capture function.
  2. Return the status value to your function and use the previous workaround code.

 

 

 

Regards,

Hairul

 

0 Kudos
Lc00
Beginner
912 Views

Thank you. The problem already sloved.

0 Kudos
Hairul_Intel
Moderator
897 Views

Hi Lc00,

Glad to know that your issue has been resolved.

 

This thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question.

 

 

Regards,

Hairul


0 Kudos
Reply