2012-10-20 91 views
0

我设法采取与Python和CV2库中的图片,但我想改变图像的尺寸和得到的东西质量不高和调整下来在640的Python - CV2改变尺寸和质量

我的代码是:

cam = VideoCapture(0) # 0 -> index of camera 
s, img = cam.read() 
    if s: # frame captured without any errors 
      imwrite(filename,img) #save image 

我曾尝试使用的方法set,但它不工作。

回答

0

您可以调整使用的OpenCV:

img = cv2.resize(img, (640, 640)) 

的分辨率设置为640x640,或

img = cv2.resize(img, (0,0), fx = 0.5, fy = 0.5) 

到图像的每个尺寸的一半。

如果你要质量劣,你可以使用一个模糊(我建议高斯):

img = cv2.GaussianBlur(img, (15,15), 0) 

如果您想了解更多或更少的模糊,改变(15,15)(它是内核大小)。

如果您想了解更多关于图像处理,我发现这非常有用:

OpenCV tutorials

OpenCV image processing