-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproduceModule.py
74 lines (66 loc) · 2.33 KB
/
produceModule.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import cv2
import time
import threading
class makeFrame(threading.Thread):
def __init__(self,dataDeque,link=''):
super(makeFrame,self).__init__()
self.dataDeque=dataDeque
imagePathList=['../tests/data/interhand2.6m/fringer\\30.jpg',
'../tests/data/interhand2.6m/fringer\\31.jpg',
'../tests/data/interhand2.6m/fringer\\32.jpg',
'../tests/data/interhand2.6m/fringer\\33.jpg',
'../tests/data/interhand2.6m/fringer\\34.jpg',
'../tests/data/interhand2.6m/fringer\\35.jpg']
self.picList=[]
for imagePath in imagePathList:
self.picList.append(cv2.imread(imagePath))
self.runFlag=True
self.link=link
if len(link)>0:
self.cap=cv2.VideoCapture(self.link)
print('asdf')
else:
self.cap=None
def run(self):
while self.runFlag:
self.videoPic()
#self.testPic()
def videoPic(self):
det_results=[]
ret,pic=self.cap.read()
print('ret',ret)
if ret==True:
#init param
det_result = {
'image':pic,
'image_name': self.link,
'bbox': [int(pic.shape[1]/10),int(pic.shape[0]/10),int(pic.shape[1]/10*8),int(pic.shape[0]/10*8)], # bbox format is 'xywh'
'camera_param': None,
'keypoints_3d_gt': None
}
#
det_results.append([det_result])
return det_results
def testPic(self):
time.sleep(0.05)
det_results_list = self.addFrame()
self.dataDeque.append(det_results_list)
def addFrame(self):
det_results=[]
for pic in self.picList:
#init param
det_result = {
'image':pic,
'image_name': 'imagePath',
'bbox': [int(pic.shape[1]/10),int(pic.shape[0]/10),int(pic.shape[1]/10*8),int(pic.shape[0]/10*8)], # bbox format is 'xywh'
'camera_param': None,
'keypoints_3d_gt': None
}
#
det_results.append([det_result])
return det_results
if __name__=='__main__':
from collections import deque
dataDeque=deque()
mf = makeFrame(dataDeque, link='0')
mf.start()