Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

transform camera resolution in opencv

I'm using a web cam of resolution 640x480 and I want to increase the resolution to 1024x768 so that the camera video can come up on the full screen. I'm sending you a sample code and please check and give me feedback.

Note: I'm using version 2.3 of OPENCV on Visual Sudio C++ (2010)

CODE:

include <windows.h>

include "cv.h"

include "highgui.h"

include <stdio.h>

include <stdlib.h>

include <iostream>

include <iomanip>

CvFont font; IplImage* frame = 0; CvCapture* capture;

using namespace std;

int main() { CvCapture* capture=cvCreateCameraCapture(0); cvNamedWindow("Cam Feed",CV_WINDOW_NORMAL);

while(1)
{
    //Getting the present frame
    frame=cvQueryFrame(capture);

    capture = cvCreateCameraCapture(0);

    cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 1024 );

    cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 768 );

    cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, 5);

    frame = cvQueryFrame(capture);
    printf("camera: %f x %f\n", cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT));
    BattleMenu();

    cvResizeWindow("Cam Feed", 1024, 768);

    cvMoveWindow("Cam Feed", 400, 130);
    cvWaitKey(1);
    cvShowImage("Cam Feed",frame);
}

/* free memory */
cvDestroyWindow( "Cam Feed" );
cvReleaseCapture( &capture );

return 0;

}

click to hide/show revision 2
No.2 Revision

updated 2013-02-19 10:42:55 -0600

berak gravatar image

transform camera resolution in opencv

I'm using a web cam of resolution 640x480 and I want to increase the resolution to 1024x768 so that the camera video can come up on the full screen. I'm sending you a sample code and please check and give me feedback.

Note: I'm using version 2.3 of OPENCV on Visual Sudio C++ (2010)

CODE:

include <windows.h>

include "cv.h"

include "highgui.h"

include <stdio.h>

include <stdlib.h>

include <iostream>

include <iomanip>

#include <WINDOWS.H>
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
CvFont font;
IplImage* frame = 0;
CvCapture* capture;

capture; using namespace std;

std; int main() { CvCapture* capture=cvCreateCameraCapture(0); cvNamedWindow("Cam Feed",CV_WINDOW_NORMAL);

Feed",CV_WINDOW_NORMAL);

    while(1)
 {
     //Getting the present frame
     frame=cvQueryFrame(capture);

     capture = cvCreateCameraCapture(0);

     cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 1024 );

     cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 768 );

     cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, 5);

     frame = cvQueryFrame(capture);
     printf("camera: %f x %f\n", cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT));
     BattleMenu();

     cvResizeWindow("Cam Feed", 1024, 768);

     cvMoveWindow("Cam Feed", 400, 130);
     cvWaitKey(1);
     cvShowImage("Cam Feed",frame);
 }

 /* free memory */
 cvDestroyWindow( "Cam Feed" );
 cvReleaseCapture( &capture );

 return 0;
}

}