'Connecting to Cognex Camera using Open CV and Python
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.
Solution 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/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | jonathanhou |