关闭

Python OpenCV sample subset images

95人阅读 评论(0) 收藏 举报
分类:

sample subset images from many images


import sys,os

def fileCountIn(dir):
    return sum([len(files) for root,dirs,files in os.walk(dir)])

print "sample images:"
path = "/home/qz/Desktop/CalibGoProHero4/intrinsic/src3/"
newpath = "/home/qz/Desktop/CalibGoProHero4/intrinsic/src/"
fileCount = fileCountIn(path)
print fileCount
sample_ratio = 0.025
sample_digits = int(1/sample_ratio)
print sample_digits
index = 1
for filename in os.listdir(path):
    index = index +1
    if(index%sample_digits==0):
        print filename
        img = cv2.imread(path + filename)
        img = cv2.transpose(img)
        img = cv2.flip(img,1 )
        new_name = newpath + filename
        cv2.imwrite(new_name, img)


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:21455次
    • 积分:689
    • 等级:
    • 排名:千里之外
    • 原创:53篇
    • 转载:10篇
    • 译文:1篇
    • 评论:6条
    文章分类
    最新评论