本文整理汇总了Python中cv2.startWindowThread方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.startWindowThread方法的具体用法?Python cv2.startWindowThread怎么用?Python cv2.startWindowThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv2
的用法示例。
在下文中一共展示了cv2.startWindowThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pick_corrs
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def pick_corrs(images, n_pts_to_pick=4):
data = [ [[], 0, False, False, False, image, "Image %d" % i, n_pts_to_pick]
for i, image in enumerate(images)]
for d in data:
win_name = d[6]
cv2.namedWindow(win_name)
cv2.setMouseCallback(win_name, corr_picker_callback, d)
cv2.startWindowThread()
cv2.imshow(win_name, d[5])
key = None
while key != '\n' and key != '\r' and key != 'q':
key = cv2.waitKey(33)
key = chr(key & 255) if key >= 0 else None
cv2.destroyAllWindows()
if key == 'q':
return None
else:
return [d[0] for d in data]
示例2: dump_2dcoor
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def dump_2dcoor():
camera = libcpm.Camera()
camera.setup()
runner = get_parallel_runner('../data/cpm.npy')
cv2.namedWindow('color')
cv2.startWindowThread()
cnt = 0
while True:
cnt += 1
m1 = camera.get_for_py(0)
m1 = np.array(m1, copy=False)
m2 = camera.get_for_py(1)
m2 = np.array(m2, copy=False)
o1, o2 = runner(m1, m2)
pts = []
for k in range(14):
pts.append((argmax_2d(o1[:,:,k]),
argmax_2d(o2[:,:,k])))
pts = np.asarray(pts)
np.save('pts{}.npy'.format(cnt), pts)
cv2.imwrite("frame{}.png".format(cnt), m1);
if cnt == 10:
break
示例3: main
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def main():
'''
Arguments to be set:
showCam : determine if show the camera preview screen.
'''
print("Enter main() function")
if args.testImage is not None:
img = cv2.imread(args.testImage)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = cv2.resize(img, FACE_SHAPE)
print(class_label[result[0]])
sys.exit(0)
showCam = 1
capture = getCameraStreaming()
if showCam:
cv2.startWindowThread()
cv2.namedWindow(windowsName, cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty(windowsName, cv2.WND_PROP_FULLSCREEN, cv2.WND_PROP_FULLSCREEN)
showScreenAndDectect(capture)
开发者ID:a514514772,项目名称:Real-Time-Facial-Expression-Recognition-with-DeepLearning,代码行数:26,代码来源:webcam_detection.py
示例4: run
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def run(self):
cv2.startWindowThread()
while True:
img = numpy.zeros((480, 640, 3))
skeleton = kinect.tracked_skeleton
if skeleton:
for user, skel in skeleton.items():
for joint_name in skel.joints:
x, y = getattr(skel, joint_name).pixel_coordinate
pt = (int(x), int(y))
cv2.circle(img, pt, 5, (255, 255, 255), thickness=-1)
kinect.remove_all_users()
cv2.imshow('Skeleton', img)
cv2.waitKey(50)
self.sub_skel.close()
self.context.term()
示例5: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def __init__(self, rom_name, vis,frameskip=1,windowname='preview'):
self.ale = ALEInterface()
self.max_frames_per_episode = self.ale.getInt("max_num_frames_per_episode");
self.ale.setInt("random_seed",123)
self.ale.setInt("frame_skip",frameskip)
romfile = str(ROM_PATH)+str(rom_name)
if not os.path.exists(romfile):
print('No ROM file found at "'+romfile+'".\nAdjust ROM_PATH or double-check the filt exists.')
self.ale.loadROM(romfile)
self.legal_actions = self.ale.getMinimalActionSet()
self.action_map = dict()
self.windowname = windowname
for i in range(len(self.legal_actions)):
self.action_map[self.legal_actions[i]] = i
# print(self.legal_actions)
self.screen_width,self.screen_height = self.ale.getScreenDims()
print("width/height: " +str(self.screen_width) + "/" + str(self.screen_height))
self.vis = vis
if vis:
cv2.startWindowThread()
cv2.namedWindow(self.windowname, flags=cv2.WINDOW_AUTOSIZE) # permit manual resizing
示例6: preview_stream
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def preview_stream(stream):
""" Display stream in an OpenCV window until "q" key is pressed """
# together with waitkeys later, helps to close the video window effectively
_cv2.startWindowThread()
for frame in stream.frame_generator():
if frame is not None:
_cv2.imshow('Video', frame)
_cv2.moveWindow('Video',5,5)
else:
break
key = _cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
_cv2.waitKey(1)
_cv2.destroyAllWindows()
_cv2.waitKey(1)
示例7: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def __init__(self, src, window_name=None, org=None):
self.src = src
self.window_name = window_name if window_name else src
cv2.startWindowThread()
cv2.namedWindow(self.window_name, cv2.WINDOW_AUTOSIZE)
if org:
# Set the window position
x, y = org
cv2.moveWindow(self.window_name, x, y)
super().__init__()
示例8: resizeImage
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def resizeImage(file_path):
#Resize Cropping & Padding an image to the 640x480 pixel size
if file_path is not -1:
if check_image_with_pil(file_path):
image = Image.open(file_path)
image.thumbnail(size, Image.ANTIALIAS)
image_size = image.size
padding_0 = max( (size[0] - image_size[0]) / 2, 0 )
padding_1 = max( (size[1] - image_size[1]) / 2, 0 )
cv2.namedWindow('Original Image')
cv2.namedWindow('Resized Image')
cv2.startWindowThread()
orig_img = cv2.imread(file_path, 0)
cv2.imshow('Original Image',orig_img)
cv2.waitKey(2)
if((padding_0==0) & (padding_1==0)):
image.save(file_path, img_save_type)
else:
thumb = image.crop( (0, 0, size[0], size[1]) )
thumb = ImageChops.offset(thumb, int(padding_0), int(padding_1))
thumb.save(file_path)
resized_img = cv2.imread(file_path, 0)
cv2.imshow('Resized Image',resized_img)
else :
cv2.destroyAllWindows()
cv2.waitKey(2)
示例9: stereo_cpm_viewer
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def stereo_cpm_viewer():
camera = libcpm.Camera()
camera.setup()
runner = get_parallel_runner('../data/cpm.npy')
cv2.namedWindow('color')
cv2.startWindowThread()
cnt = 0
while True:
cnt += 1
m1 = camera.get_for_py(0)
m1 = np.array(m1, copy=False)
m2 = camera.get_for_py(1)
m2 = np.array(m2, copy=False)
m1s = cv2.resize(m1, (368,368))
m2s = cv2.resize(m2, (368,368))
o1, o2 = runner(m1s, m2s)
#buf = dumps([m1, m2, o1, o2])
#f = open('recording/{:03d}.npy'.format(cnt), 'w')
#f.write(buf)
#f.close()
c1 = colorize(m1, o1[:,:,:-1].sum(axis=2))
c2 = colorize(m2, o2[:,:,:-1].sum(axis=2))
viz = np.concatenate((c1, c2), axis=1)
cv2.imshow('color', viz / 255.0)
示例10: main
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def main():
'''
Arguments to be set:
showCam : determine if show the camera preview screen.
'''
print("Enter main() function")
capture = getCameraStreaming()
cv2.startWindowThread()
cv2.namedWindow(windowsName, cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty(windowsName, cv2.WND_PROP_FULLSCREEN, cv2.WND_PROP_FULLSCREEN)
while True:
recContent = speechRecognition()
if recContent is not None:
emotion = showScreenAndDectect(capture)
if emotion == "Angry":
emoji = " >:O"
elif emotion == "Fear":
emoji = " :-S"
elif emotion == "Happy":
emoji = " :-D"
elif emotion == "Sad":
emoji = " :'("
elif emotion == "Surprise":
emoji = " :-O"
else:
emoji = " "
print("Output result: " + recContent + emoji)
开发者ID:a514514772,项目名称:Real-Time-Facial-Expression-Recognition-with-DeepLearning,代码行数:32,代码来源:gen_sentence_with_emoticons.py
示例11: test_ssd
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def test_ssd():
face_detector = FaceDetectorSSDMobilenetV2()
image = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"samples/blackpink/blackpink4.jpg")
print("image path is: " + image)
test_image = cv2.imread(image, cv2.IMREAD_COLOR)
faces = face_detector.detect(test_image)
for face in faces:
cv2.rectangle(test_image,(int(face.x),int(face.y)),(int(face.x + face.w), int(face.y + face.h)), (0,255,0),3)
window_name = "image"
cv2.namedWindow(window_name, cv2.WND_PROP_AUTOSIZE)
cv2.startWindowThread()
cv2.imshow('image', test_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.waitKey(1)
print("done showing face annotated image!")
for face in faces:
print(face.face_landmark)
print("done")
示例12: test_ssd_webcam
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def test_ssd_webcam():
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
out = cv2.VideoWriter('ssd_output.mp4', fourcc, 60.0, (640, 480))
face_detector = FaceDetectorSSDMobilenetV2()
while(True):
ret, frame = cap.read()
test_image = frame
faces = face_detector.detect(test_image)
for face in faces:
cv2.rectangle(test_image,(int(face.x),int(face.y)),(int(face.x + face.w), int(face.y + face.h)), (0,255,0),3)
window_name = "image"
cv2.namedWindow(window_name, cv2.WND_PROP_AUTOSIZE)
cv2.startWindowThread()
out.write(test_image)
cv2.imshow(window_name, test_image)
if cv2.waitKey(5) & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()
示例13: imshow
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def imshow(image):
import cv2 as cv
if isinstance(image, str):
image = cv.imread(image)
cv.startWindowThread()
cv.namedWindow('Image', cv.WINDOW_NORMAL)
cv.imshow('Image', image)
示例14: imshow
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def imshow(image, name=0):
import cv2 as cv
if isinstance(image, str):
image = cv.imread(image)
cv.startWindowThread()
cv.namedWindow(str(name), cv.WINDOW_NORMAL)
cv.imshow(str(name), image)
示例15: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import startWindowThread [as 别名]
def __init__(self, src, window_name=None, org=None):
self.src = src
self.window_name = window_name if window_name else src
cv2.startWindowThread()
cv2.namedWindow(self.window_name, cv2.WINDOW_AUTOSIZE)
if org:
# Set the window position
x, y = org
cv2.moveWindow(self.window_name, x, y)
super(DisplayVideo, self).__init__()