-1

My problem is that I need to take a picture from the camera and process it with OpenCV and Python to get coordinates and send them to a robotic arm, but I can't get communication with the Cognex camera with the following code (I got it from the OpenCV documentation):

import cv2

cognex = cv2.VideoCapture('192.168.1.5')
while True:
     ret, frame = cognex.read()
     cv2.imshow('Cognex Camera', frame)
     if cv2.readKey(1) & 0xFF == ord('q'):
           break

cognex.release()
cv2.destroyAllWindows()

but when I run this example I got this error:

warning: Error opening file 
(/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:901)
warning: 192.168.1.5 
(/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:902)
Traceback (most recent call last):
File "ejemplo.py", line 8, in <module>
cv2.imshow('Cognex Camera', frame)
cv2.error: OpenCV(4.1.0) C:\projects\opencv- 
python\opencv\modules\highgui\src\window.cpp:352: error: 
(-215:Assertion failed) size.width>0 && size.height>0 in function 
'cv::imshow'

and I think it's because it doesn't open the connection with the camera. I have searched for information on the internet that can help me but I have not be able to find out if it can really connect or cannot connect OpenCV with the Cognex camera.

5
  • I guess you would want cv2.VideoCapture('http://192.168.1.5') Commented Aug 20, 2019 at 18:09
  • I tried but it didn't work, it shows the same error. Commented Aug 20, 2019 at 18:33
  • Did you trying to ping the camera? Where did you get its address? Have you logged into your router to see the DHCP allocations? Does it serve images over http or rtsp? Is there a port you should specify? Which camera is it? Does Cognex's own software see the camera? Commented Aug 20, 2019 at 18:38
  • 1 ) yes, I tried. The IP I set it up in the in-sight explorer software and Im not using a DHCP protocol. 2) I tried with http and rtsp, but no one of this works. Maybe the camera does not support this protocols. 3) The only port that I know about this camera is the 23 but this port is used for a Telnet conecction. 4) The camera is a in sight 7000 gen II 5) Yes, Cognex have a software to get the connection and program the camera. Commented Aug 20, 2019 at 19:11
  • I think you should contact cognex about it. AFAIK cognex requires you to use their sdk to connect to the camera (as many other camera providers) and then you would have to convert it to OpenCV image and then you can do your process... Commented Aug 21, 2019 at 7:06

1 Answer 1

-1

not sure if you found a solution but you can try the Pleora eBUS SDK which allows you to use cameras from any vendor and integrate with OpenCV. https://www.pleora.com/products/ebus-software/ebus-sdk/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.