-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcameraTest.py
50 lines (40 loc) · 1.34 KB
/
cameraTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import cv2
import matplotlib.pyplot as plt
# import cvlib as cv
import urllib.request
import numpy as np
# from cvlib.object_detection import draw_bbox
import concurrent.futures
url='http://192.168.99.95/1024x768.mjpeg'
im=None
def run1():
cv2.namedWindow("live transmission", cv2.WINDOW_AUTOSIZE)
while True:
img_resp=urllib.request.urlopen(url)
imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
im = cv2.imdecode(imgnp,-1)
# record the video and save to file
cv2.imshow('live transmission',im)
key=cv2.waitKey(5)
if key==ord('q'):
break
cv2.destroyAllWindows()
run1()
def run2():
cv2.namedWindow("detection", cv2.WINDOW_AUTOSIZE)
while True:
img_resp=urllib.request.urlopen(url)
imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
im = cv2.imdecode(imgnp,-1)
# bbox, label, conf = cv.detect_common_objects(im)
# im = draw_bbox(im, bbox, label, conf)
cv2.imshow('detection',im)
key=cv2.waitKey(5)
if key==ord('q'):
break
# cv2.destroyAllWindows()
if __name__ == '__main__':
print("started")
# with concurrent.futures.ProcessPoolExecutor() as executer:
# f1= executer.submit(run1)
# # f2= executer.submit(run2)