0
import cv2.cv as cv
import time
from subprocess import Popen
capture = cv.CaptureFromCAM(0)
num = 0
while True:
img = cv.QueryFrame(capture)
cv.SaveImage('pic'+str(num)+'.jpg', img)
if num == 500:
    del(capture)
    break
if cv.WaitKey(10) == 27:
    break
num += 1

I am capturing images in python language using opencv. The images captured using webcam are of 480 by 640 resolution.I need to increase its resolution.So how can I do this? The code is as follows.

user3352710
  • 79
  • 1
  • 3
  • 9
  • As mentioned in this post,http://stackoverflow.com/questions/11678527/how-to-resize-an-image-to-a-specific-size-in-opencv, use cv.Resize – a p Feb 28 '14 at 11:28
  • 1
    I recommend you use the cv2 interface which is newer and I think easier to use. If you do, check [this Question/Answer](http://stackoverflow.com/a/22059934/377366) which covers camera capture and also resizing using cv2. I'd mark as duplicate of that one but it hasn't been accepted so I can't yet. – KobeJohn Feb 28 '14 at 11:40
  • Do you mean: How to combine several images into one image that has a higher resolution and is still of good quality? – User Feb 28 '14 at 14:23

1 Answers1

1

Using VideoCapture class's set function you can change the resolution to the sepecific value. Here's a sample c++ program:

#include"opencv2/opencv.hpp"
using namespace std;
int main()
{
VideoCapture cap(0);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1920);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1080);
Mat frame;
cap >> frame;
imwrite("test.jpg",frame);
}

You can find similar function in python as well. Refer to this for further details. And you can use VideoCapture's get function to get the current value of the cam's width or height like:

cap.get(CV_CAP_PROP_FRAME_HEIGHT);

Hope this solves your issue. Thanks.

Chewpers
  • 2,430
  • 5
  • 23
  • 30
Shameel Mohamed
  • 607
  • 5
  • 23