Am working on a project of transmission from a robot camera to my 'PC' with tcp/ip protocol (Ethernet cable), so the robot has a web interface in which I can see the camera (the web interface is like the router one, I have access to it by typing the IP address in my browser).So I want to get this image/video data into my python project! My questions are:
- How can I know which data are the image?
- Which library allow me to get it? (socket ?)
- I use now
urllibto get the image/video and show it in cv2's window, but this is not what I wanted to do, I want to get directly the data from the IP address.
Thank you.
import cv2
import numpy as np
import urllib.request
from http.client import IncompleteRead
url = 'http://192.168.1.100/TD/VDEV_IMS.PNG'
while True:
reponse = urllib.request.urlopen(url)
imgNp = np.array(bytearray(reponse.read()), dtype=np.uint8)
reponse = urllib.request.urlopen(url)
imgNp = np.array(bytearray(reponse.read()), dtype=np.uint8)
img = cv2.imdecode(imgNp, -1)
try:
cv2.imshow("test", img)
except IncompleteRead:
return
if ord('q') == cv2.waitKey(10):
exit(0)