本文整理汇总了Python中cv.GetSize方法的典型用法代码示例。如果您正苦于以下问题:Python cv.GetSize方法的具体用法?Python cv.GetSize怎么用?Python cv.GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv
的用法示例。
在下文中一共展示了cv.GetSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rotate
# 需要导入模块: import cv [as 别名]
# 或者: from cv import GetSize [as 别名]
def rotate(self, degrees):
if (degrees > 180):
# Flip around both axes
cv.Flip(self.image, None, -1)
degrees = degrees - 180
img = self.image
size = cv.GetSize(img)
if (degrees / 90 % 2):
new_size = (size[1], size[0])
center = ((size[0] - 1) * 0.5, (size[0] - 1) * 0.5)
else:
new_size = size
center = ((size[0] - 1) * 0.5, (size[1] - 1) * 0.5)
mapMatrix = cv.CreateMat(2, 3, cv.CV_64F)
cv.GetRotationMatrix2D(center, degrees, 1.0, mapMatrix)
dst = cv.CreateImage(new_size, self.image_depth, self.image_channels)
cv.SetZero(dst)
cv.WarpAffine(img, dst, mapMatrix)
self.image = dst
示例2: size
# 需要导入模块: import cv [as 别名]
# 或者: from cv import GetSize [as 别名]
def size(self):
return cv.GetSize(self.image)
示例3: preprocess_captcha_part
# 需要导入模块: import cv [as 别名]
# 或者: from cv import GetSize [as 别名]
def preprocess_captcha_part(file):
letter_algo = []
letters = split_captcha(file)
for i in range (len(letters)):
#letter = Image.fromstring("L", cv.GetSize(letters[i]), letters[i].tostring())
letter = Image.open(letters[i])
letter_algo.append(letter.point(lambda i: (i/255.)))
return letters
示例4: pil_from_cv
# 需要导入模块: import cv [as 别名]
# 或者: from cv import GetSize [as 别名]
def pil_from_cv(src):
return Image.fromstring("L", cv.GetSize(src), src.tostring())
示例5: pygame_from_cv
# 需要导入模块: import cv [as 别名]
# 或者: from cv import GetSize [as 别名]
def pygame_from_cv(src):
import cv
""" return pygame image from opencv image """
src_rgb = cv.CreateMat(src.height, src.width, cv.CV_8UC3)
cv.CvtColor(src, src_rgb, cv.CV_BGR2RGB)
return pygame.image.frombuffer(src_rgb.tostring(), cv.GetSize(src_rgb), "RGB")
示例6: FPV_thread
# 需要导入模块: import cv [as 别名]
# 或者: from cv import GetSize [as 别名]
def FPV_thread():
global camera_index
global capture
global WINDOW_NAME
global latest_frame
global FPV_thread_stop
global overlay_message # shared with application return results
global face_position # shared with application return results
FPV_init()
cv.NamedWindow(WINDOW_NAME, cv.CV_WINDOW_NORMAL)
cv.MoveWindow(WINDOW_NAME, 0, 0)
width_scale = 1.0
height_scale = 1.0
while True:
frame = cv.QueryFrame(capture)
cv.Flip(frame, None, 1)
#copy to buffer
frame_lock.acquire()
original_imagesize = (0,0)
resized_imagesize = (0,0)
if not latest_frame:
latest_frame = cv.CreateImage((640, 480), frame.depth, frame.nChannels)
original_imagesize = cv.GetSize(frame)
resized_imagesize = cv.GetSize(latest_frame)
width_scale = original_imagesize[0]*1.0/resized_imagesize[0]
height_scale = original_imagesize[1]*1.0/resized_imagesize[1]
cv.Resize(frame, latest_frame)
frame_lock.release()
#Display Result
text_start_point = (10, 50)
cv.PutText(frame, overlay_message, text_start_point, font, cv.Scalar(255,255,255))
cv.Rectangle(frame, text_start_point, (original_imagesize[0], 100), cv.Scalar(0,0,0), thickness=cv.CV_FILLED)
if face_position[0] > 0.0:
point1 = (int(face_position[0]*width_scale), int(face_position[1]*height_scale))
point2 = (int((face_position[0] + face_position[2])*width_scale), \
int((face_position[1]+face_position[3])*height_scale))
cv.Rectangle(frame, point1, point2, \
cv.Scalar(255, 255, 255), thickness=2)
cv.ShowImage(WINDOW_NAME, frame)
cv.ResizeWindow(WINDOW_NAME, 200, 100)
cv.NamedWindow(WINDOW_NAME, cv.CV_WINDOW_NORMAL);
cv.SetWindowProperty(WINDOW_NAME, 0, cv.CV_WINDOW_FULLSCREEN);
c = cv.WaitKey(10)
if c == ord('q'):
break
print "[INFO] FPV Thread is finished"
FPV_thread_stop = True
FPV_close()