本文整理汇总了C++中cvGetCaptureProperty函数的典型用法代码示例。如果您正苦于以下问题:C++ cvGetCaptureProperty函数的具体用法?C++ cvGetCaptureProperty怎么用?C++ cvGetCaptureProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cvGetCaptureProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cvGetCaptureProperty
//------------------------------------------------------------------------------
void OgreVideoTexture::_createTextureFromCapture(CvCapture *_capture)
{
int w, h;
w = cvGetCaptureProperty(_capture, CV_CAP_PROP_FRAME_WIDTH);
h = cvGetCaptureProperty(_capture, CV_CAP_PROP_FRAME_HEIGHT);
Ogre::TextureManager *TM = Ogre::TextureManager::getSingletonPtr();
// Create the texture
mVideoTexture = Ogre::TextureManager::getSingleton().createManual(
mTextureName, // name
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, // type
1024, 1024, // width & height
0, // number of mipmaps
Ogre::PF_BYTE_BGR,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
_initTexture(mVideoTexture);
// Create a material using the texture
mVideoMaterial = Ogre::MaterialManager::getSingleton().create(
mMaterialName, // name
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mVideoMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(mTextureName);
//mVideoMaterial->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
}
示例2: main
int main(int argc, const char * argv[]) {
CvCapture* capture = cvCreateFileCapture( argv[1] );
if (!capture) return -1;
IplImage* bgr_frame = cvQueryFrame( capture );
double fps = cvGetCaptureProperty( capture , CV_CAP_PROP_FPS );
CvSize size = cvSize(
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
);
CvVideoWriter* writer = cvCreateVideoWriter( argv[2], CV_FOURCC('M', 'J', 'P', 'G'), fps, size);
IplImage* logpolar_frame = cvCreateImage(size, IPL_DEPTH_8U, 3);
while ( (bgr_frame = cvQueryFrame(capture)) != NULL ) {
cvLogPolar(bgr_frame, logpolar_frame,
cvPoint2D32f(bgr_frame->width/2, bgr_frame->height/2),
40,
CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
cvWriteFrame(writer, logpolar_frame);
}
cvReleaseVideoWriter( &writer );
cvReleaseImage( &logpolar_frame );
cvReleaseCapture( &capture );
return 0;
}
示例3: trainBackgroundModel
void trainBackgroundModel(CvCapture* capture)
{
CvSize frame_size;
frame_size.height = (int) cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT );
frame_size.width = (int) cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH );
if(background_model != NULL)
delete background_model;
background_model = new pixel_data*[frame_size.height];
for(int i = 0; i < frame_size.height; i++)
background_model[i] = new pixel_data[frame_size.width];
const char* title = "Training Background Model";
std::vector<const char*> lines;
for(int i = 5; i >= 0; i--)
{
char buffer[400];
sprintf(buffer, "Starting training in %d ...", i);
lines.clear();
lines.push_back(buffer);
setOptions(title, lines);
cvWaitKey(1000);
}
for(int num_frames = 0; num_frames < NUM_BACKGROUND_TRAINING_FRAMES; num_frames++)
{
char buffer[400];
sprintf(buffer, "%g%%", ((double)num_frames/NUM_BACKGROUND_TRAINING_FRAMES*100.0));
lines.clear();
lines.push_back(buffer);
setOptions(title, lines);
/* get a frame */
IplImage* frame = cvQueryFrame( capture );
RgbImage img(frame);
for(int i = 0; i < frame->height; i++)
{
for(int j = 0; j < frame->width; j++)
{
background_model[i][j].addDataPoint(img[i][j].r, img[i][j].g, img[i][j].b);
}
}
/* always check */
if( !frame ) break;
cvShowImage(MAIN_WINDOW, frame);
cvWaitKey(10);
}
lines.push_back("Done");
setOptions(title, lines);
cvWaitKey(3000);
}
示例4: Init
void Init(int argc, char *argv[])
{
capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture){
std::cout << "error starting video capture" << std::endl;
exit(0);
}
//propose a resolution
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
//get the actual (supported) resolution
ivWidth = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
ivHeight = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
std::cout << "camera/video resolution: " << ivWidth << "x" << ivHeight << std::endl;
#ifdef FORCE_RESIZING
ivWidth = RESOLUTION_X;
ivHeight = RESOLUTION_Y;
#endif
cvNamedWindow("MOCTLD", 0); //CV_WINDOW_AUTOSIZE );
CvSize wsize = {ivWidth, ivHeight};
curImage = cvCreateImage(wsize, IPL_DEPTH_8U, 3);
cvResizeWindow("MOCTLD", ivWidth, ivHeight);
cvSetMouseCallback("MOCTLD", MouseHandler);
}
示例5: the_car
void the_project::project_init()
{
car_of_pro = new the_car();
//camera 480*640
for_cam = cvCreateCameraCapture(1);
for_video = cvCreateFileCapture("test.avi");
image_size = cvSize(cvGetCaptureProperty(for_cam,3),cvGetCaptureProperty(for_cam,4));
wr1 = cvCreateVideoWriter("record_ori.avi",CV_FOURCC('X','V','I','D') ,15,image_size);
wr2 = cvCreateVideoWriter("record_cha.avi",CV_FOURCC('X','V','I','D') ,15,image_size);
newpoints[0]=cvPoint2D32f(0,0);
newpoints[1]=cvPoint2D32f(0,image_size.height);
newpoints[2]=cvPoint2D32f(image_size.width,image_size.height);
newpoints[3]=cvPoint2D32f(image_size.width,0);
red_min=200;
rg_max=100;
rb_max=100;
green_min=200;
gb_max=100;
gr_max=100;
}
示例6: cvGetCaptureProperty
//void StereoDisplay::SetFileName(LPSTR filename)
bool StereoDisplay::SetFileName(void)
{
int isColor = 1;
double fps = cvGetCaptureProperty( camera0_->capture_, CV_CAP_PROP_FPS);
CvSize size = cvSize( (int)cvGetCaptureProperty( camera0_->capture_, CV_CAP_PROP_FRAME_WIDTH),
(int)cvGetCaptureProperty( camera0_->capture_, CV_CAP_PROP_FRAME_HEIGHT));
//http://www.xvidmovies.com/codec/
// divx.com
//writer_ = cvCreateVideoWriter( filename, CV_FOURCC_DEFAULT, fps, size, isColor ); // XP Codec Pack 2.5.1
//writer_ = cvCreateVideoWriter( filename, CV_FOURCC('X','V','I','D'), fps, size ); // XP Codec Pack 2.5.1
//writer_ = cvCreateVideoWriter( "mytest.divx", CV_FOURCC('D','I','V','X'), fps, size ); // XP Codec Pack 2.5.1
//writer_ = cvCreateVideoWriter( file_name, CV_FOURCC('U','2','6','3'), fps, size ); // XP Codec Pack 2.5.1
//writer_ = cvCreateVideoWriter( file_name, CV_FOURCC('D','I','V','3'), fps, size ); // XP Codec Pack 2.5.1
writer_ = cvCreateVideoWriter( "flv1.avi", CV_FOURCC('F','L','V','1'), fps, size ); // XP Codec Pack 2.5.1
if( NULL == writer_ )
{
return false;
}
else
{
logpolarframe_ = cvCreateImage(size, IPL_DEPTH_8U,3);
recording_ = true;
return true;
}
}
示例7: test
void test() {
CvCapture *capture = cvCreateFileCapture("D:\\²âÊÔÊÓƵ\\1344.avi");
int frameWidth = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
int frameHeight = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
codeBook *cb = new codeBook[frameWidth * frameHeight];
memset(cb, 0, frameWidth * frameHeight * sizeof(codeBook));
unsigned int bound[3] = { 10 ,10,10 };
int minMod[3] = { 10 ,10,10 };
int maxMod[3] = { 10 ,10,10 };
IplImage *frame[1000];
for (int i = 0; i < 1000; i++) {
frame[i] = cvCreateImage(cvSize(frameWidth, frameHeight), 8, 3);
cvCopy(cvQueryFrame(capture), frame[i]);
}
for (int i = 0; i < frameWidth * frameHeight; i++) {
for (int j = 0; j < 1000; j++) {
UpdateCodeBook((unsigned char*)frame[j]->imageData + i * 3, cb[i], bound, 3);
}
}
IplImage *mask = cvCreateImage(cvSize(frameWidth, frameHeight), 8, 1);
for (int i = 0; i < 1000; i++) {
for (int j = 0; j < frameWidth * frameHeight; j++) {
mask->imageData[j] = BackgroundDiff((unsigned char*)frame[i]->imageData + j * 3, cb[j], 3, minMod, maxMod);
}
FindConnectedComponents(mask);
cvShowImage("1", mask);
cvShowImage("2", frame[i]);
cvWaitKey(30);
}
}
示例8: Video_to_image
void Video_to_image(char* filename)
{
printf("------------- video to image ... ----------------\n");
//初始化一个视频文件捕捉器
CvCapture* capture = cvCaptureFromAVI(filename);
//获取视频信息
cvQueryFrame(capture);
int frameH = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
int frameW = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int numFrames = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
printf("\tvideo height : %d\n\tvideo width : %d\n\tfps : %d\n\tframe numbers : %d\n", frameH, frameW, fps, numFrames);
//定义和初始化变量
int i = 0;
IplImage* img = 0;
char image_name[13];
cvNamedWindow( "mainWin", CV_WINDOW_AUTOSIZE );
//读取和显示
while(1)
{
img = cvQueryFrame(capture); //获取一帧图片
cvShowImage( "mainWin", img ); //将其显示
char key = cvWaitKey(20);
//sprintf(image_name, "%s%d%s", "image", ++i, ".jpg");//保存的图片名
sprintf(image_name, "%s%d%s", "", ++i, ".jpg");//保存的图片名
cvSaveImage( image_name, img); //保存一帧图片
if(i == NUM_FRAME) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("mainWin");
}
示例9: opendir
void MyVideo::loadResource(char* folder) {
//search the folder for images and video
DIR *dir = NULL;
dirent *ent = NULL;
dir = opendir(folder);
//if the folder is invalid
if (dir == NULL) {
cout<<"Invalid folder"<<endl;
return;
}
//get all the files
while ((ent = readdir(dir)) != NULL) {
//find the first '.'
char* suffix = (char*)malloc(sizeof(char));
sscanf(ent->d_name, "%*[^.]%s", suffix);
char* input_src = (char*)malloc(sizeof(char));
strcpy(input_src, folder);
strcat(input_src, ent->d_name);
if((strcmp(suffix, ".avi") == 0)&&(ent->d_name[0]!='.')) {
inputvideo = cvCaptureFromFile(input_src);
}
if((strcmp(suffix, ".jpg") == 0)&&(ent->d_name[0]!='.')) {
IplImage *p = cvLoadImage(input_src, 1);
images.push_back(p);
}
}
width = (int)cvGetCaptureProperty(inputvideo, 3);
height = (int)cvGetCaptureProperty(inputvideo, 4);
fps = (int)cvGetCaptureProperty(inputvideo, 5);
fourcc = (int)cvGetCaptureProperty(inputvideo, 6);
framecount = (int)cvGetCaptureProperty(inputvideo, 7);
}
示例10: cvCaptureFromCAM
int StereoCamera::setup(CvSize imageSize){
this->imageSize = imageSize;
//captures[0] = cvCaptureFromCAM(CV_CAP_DSHOW + 0);
//captures[1] = cvCaptureFromCAM(CV_CAP_DSHOW + 1);
captures[0] = cvCaptureFromCAM(CV_CAP_ANY + 0);
captures[1] = cvCaptureFromCAM(CV_CAP_ANY + 1);
if(captures[0] == NULL)
{
printf("error\n");
}
if( captures[0] && captures[1]){
for(int i=0;i<2;i++){
cvSetCaptureProperty(captures[i], CV_CAP_PROP_FRAME_WIDTH, imageSize.width);
cvSetCaptureProperty(captures[i], CV_CAP_PROP_FRAME_HEIGHT, imageSize.height);
}
printf("%d\n", (int)cvGetCaptureProperty(captures[0], CV_CAP_PROP_FRAME_WIDTH));
printf("%d\n", (int)cvGetCaptureProperty(captures[0], CV_CAP_PROP_FRAME_HEIGHT));
ready = true;
return RESULT_OK;
}else{
ready = false;
return RESULT_FAIL;
}
}
示例11: cvCreateCameraCapture
// Get the resolutions of a device
void Cam::getDeviceInfo(int d){
CvCapture *cap = cvCreateCameraCapture(d);
num_resolutions = 0;
for(int i=0; i<N_RESOLUTIONS; i++){
// Set actual values of resolution
cvSetCaptureProperty( cap, CV_CAP_PROP_FRAME_WIDTH, c_resolutions[i].x );
cvSetCaptureProperty( cap, CV_CAP_PROP_FRAME_HEIGHT, c_resolutions[i].y );
// Compare the actual resolution value with the last accepted value (Width and Height)
if( c_resolutions[i].x == cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH)
&& c_resolutions[i].y == cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT) ){
resolutions[num_resolutions].x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH);
resolutions[num_resolutions].y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT);
num_resolutions++;
}
}
cvReleaseCapture(&cap);
/*
for(int i=0; i<num_resolutions; i++){
std::cout << i << ": " << resolutions[i].x << ", " << resolutions[i].y << std::endl;
}
*/
}
示例12: main
int
main (int argc, char **argv)
{
CvCapture *capture = 0;
IplImage *frame = 0;
CvVideoWriter *writer;
int c, num = 0;
//CvFont font;
//char str[64];
double fps, width, height;
if ( argc == 1 || (argc >= 2 && strlen (argv[1]) == 1 && isdigit (argv[1][0])) )
{
capture = cvCreateCameraCapture (argc == 2 ? argv[1][0] - '0' : 0);
fps = 20.0;
width = 320;
height = 240;
//fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
//cvSetCaptureProperty (capture, CV_CAP_PROP_FRAME_WIDTH, width);
//cvSetCaptureProperty (capture, CV_CAP_PROP_FRAME_HEIGHT, height);
}
else if ( argc >= 2 )
{
capture = cvCaptureFromFile(argv[1]);
fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
}
printf ("fps=%f width=%f height=%f\n", fps, width, height);
printf ("Write to cap.avi. Finish with Esc.\n");
// FourCC http://www.fourcc.org/codecs.php
//writer = cvCreateVideoWriter( "cap.avi",
// CV_FOURCC('D','I','V','X'),
// fps, cvSize((int)width,(int)height) );
writer = cvCreateVideoWriter( "cap.avi", -1,
fps, cvSize((int)width,(int)height) );
//cvInitFont (&font, CV_FONT_HERSHEY_COMPLEX, 0.7, 0.7);
cvNamedWindow ("Capture", CV_WINDOW_AUTOSIZE);
while (1) {
frame = cvQueryFrame (capture);
if( frame == NULL ) break;
//snprintf (str, 64, "%03d[frame]", num);
//cvPutText (frame, str, cvPoint (10, 20), &font, CV_RGB (0, 255, 100));
cvWriteFrame (writer, frame);
cvShowImage ("Capture", frame);
num++;
c = cvWaitKey (10);
if (c == 'q') // exit
break;
}
cvReleaseVideoWriter (&writer);
cvReleaseCapture (&capture);
cvDestroyWindow ("Capture");
return 0;
}
示例13: main
int
main(int argc, char *argv[])
{
CvCapture *capture = NULL;
IplImage *src_frame, *image, *dst_frame;
char *infile, *outfile;
Matrix matrix;
Args args;
int64 t0, t1;
double tps, deltatime;
CvVideoWriter *writer;
CvSize size;
double fps;
int frame_count;
int i;
infile = argv[1];
outfile = argv[2];
args.c = argc - 3;
for (i = 0; i < 3; i++)
args.v[i] = argv[i + 3];
capture = cvCaptureFromFile(infile);
if (capture == NULL) {
printf("Could not load video \"%s\".\n", infile);
return EXIT_FAILURE;
}
src_frame = cvQueryFrame(capture);
fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
size = cvSize(
(int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
(int) cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
);
writer = cvCreateVideoWriter(outfile, CV_FOURCC('M', 'J', 'P', 'G'), fps, size, 1);
printf("Saving to \"%s\"...\n", outfile);
image = cvCreateImage(size, IPL_DEPTH_8U, 1);
dst_frame = cvCreateImage(size, IPL_DEPTH_8U, 3);
matrix.width = dst_frame->width;
matrix.height = dst_frame->height;
frame_count = 0;
t0 = cvGetTickCount();
while ((src_frame = cvQueryFrame(capture)) != NULL) {
cvCvtColor(src_frame, image, CV_BGR2GRAY);
matrix.data = (unsigned char *) image->imageData;
proc(&matrix, &args);
cvCvtColor(image, dst_frame, CV_GRAY2BGR);
cvWriteFrame(writer, dst_frame);
frame_count++;
}
t1 = cvGetTickCount();
tps = cvGetTickFrequency() * 1.0e6;
deltatime = (double) (t1 - t0) / tps;
printf("%d frames of %dx%d processed in %.3f seconds.\n",
frame_count, dst_frame->width, dst_frame->height,
deltatime);
cvReleaseVideoWriter(&writer);
cvReleaseImage(&dst_frame);
cvReleaseCapture(&capture);
return EXIT_SUCCESS;
}
示例14: main
int main(int argc, char* argv[])
{
// получаем любую подключённую камеру
CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY); //cvCaptureFromCAM( 0 );
assert( capture );
//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);//1280);
//cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);//960);
// узнаем ширину и высоту кадра
double width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
double height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
printf("[i] %.0f x %.0f\n", width, height );
IplImage* frame=0;
cvNamedWindow("capture", CV_WINDOW_AUTOSIZE);
printf("[i] press Enter for capture image and Esc for quit!\n\n");
int counter=0;
char filename[512];
char text_buf[32];
CvFont myFont;
// cvInitFont(&myFont, СV_FONT_HERSHEY_PLAIN, 0.7, 1, 0, 1, 8);
cvInitFont(&myFont, CV_FONT_HERSHEY_PLAIN, 2, 1, 0, 1, 8);
while(true){
// получаем кадр
frame = cvQueryFrame( capture );
//Filters
cvtColor(frame, pic, CV_BGR2HSV);
GaussianBlur(pic, pic, Size(7,7), 1.5, 1.5);
sprintf(text_buf,"Hello!!!");
cvPutText(frame, text_buf, cvPoint(5,15), &myFont, cvScalar(0,0,255));
// показываем
cvShowImage("capture", frame);
char c = cvWaitKey(33);
if (c == 27) { // нажата ESC
break;
}
else if(c == 13) { // Enter
// сохраняем кадр в файл
sprintf(filename, "Image%d.jpg", counter);
printf("[i] capture... %s\n", filename);
cvSaveImage(filename, frame);
counter++;
}
}
// освобождаем ресурсы
cvReleaseCapture( &capture );
cvDestroyWindow("capture");
return 0;
}
示例15: getCaptureSize
CvSize getCaptureSize(CvCapture *capture)
{
CvSize sz;
sz.width = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
sz.height = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
LOGD("capture size: %dx%d", sz.width, sz.height);
return sz;
}