python类rotate()的实例源码

helpers.py 文件源码 项目:head-segmentation 作者: szywind 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def transformations(src, choice):
    if choice == 0:
        # Rotate 90
        src = cv2.rotate(src, rotateCode=cv2.ROTATE_90_CLOCKWISE)
    if choice == 1:
        # Rotate 90 and flip horizontally
        src = cv2.rotate(src, rotateCode=cv2.ROTATE_90_CLOCKWISE)
        src = cv2.flip(src, flipCode=1)
    if choice == 2:
        # Rotate 180
        src = cv2.rotate(src, rotateCode=cv2.ROTATE_180)
    if choice == 3:
        # Rotate 180 and flip horizontally
        src = cv2.rotate(src, rotateCode=cv2.ROTATE_180)
        src = cv2.flip(src, flipCode=1)
    if choice == 4:
        # Rotate 90 counter-clockwise
        src = cv2.rotate(src, rotateCode=cv2.ROTATE_90_COUNTERCLOCKWISE)
    if choice == 5:
        # Rotate 90 counter-clockwise and flip horizontally
        src = cv2.rotate(src, rotateCode=cv2.ROTATE_90_COUNTERCLOCKWISE)
        src = cv2.flip(src, flipCode=1)
    return src
vwriter.py 文件源码 项目:piwall-cvtools 作者: infinnovation 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def rotating_example():
    img = cv2.imread('./data/hi.jpg')
    vwriter = VideoWriterRGB('hi-video.avi')
    frames = 0
    for angle in range(0, 360, 5):
        rot = imutils.rotate(img, angle=angle)
        cv2.imshow("Angle = %d" % (angle), rot)
        vwriter.addFrame(rot)
        frames += 1
    for angle in range(360, 0, -5):
        rot = imutils.rotate(img, angle=angle)
        cv2.imshow("Angle = %d" % (angle), rot)
        vwriter.addFrame(rot)
        frames += 1
    vwriter.finalise()
    print("Created movie with %d frames" % frames)
helpers.py 文件源码 项目:head-segmentation 作者: szywind 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def transformations2(src, choice):
    mode = choice // 2
    src = imutils.rotate(src, mode * 90)
    if choice % 2 == 1:
        src = cv2.flip(src, flipCode=1)
    return src


问题


面经


文章

微信
公众号

扫码关注公众号