本文整理汇总了C++中cvCreateCameraCapture函数的典型用法代码示例。如果您正苦于以下问题:C++ cvCreateCameraCapture函数的具体用法?C++ cvCreateCameraCapture怎么用?C++ cvCreateCameraCapture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cvCreateCameraCapture函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
int chessboard_search = 0;
cvNamedWindow("leftimage", CV_WINDOW_AUTOSIZE);
cvNamedWindow("rightimage", CV_WINDOW_AUTOSIZE);
CvCapture *capture_left, *capture_right;
printf("Using webcam\n");
capture_left = cvCreateCameraCapture(CAM_LEFT );
capture_right = cvCreateCameraCapture(CAM_RIGHT);
/* cvSetCaptureProperty(capture_left,
CV_CAP_PROP_FRAME_WIDTH, SCREEN_WIDTH/2);
cvSetCaptureProperty(capture_right,
CV_CAP_PROP_FRAME_WIDTH, SCREEN_WIDTH/2);
*/
if (capture_left == NULL)
fatal("can't find left webcam (seen from computers eyes)");
if (capture_right == NULL)
fatal("can't find right webcam (seen from computers eyes)");
IplImage *frame_left, *frame_right;
/* process frames */
while (1) {
/* get next frame */
frame_left = cvQueryFrame(capture_left);
frame_right = cvQueryFrame(capture_right);
if (!frame_left || !frame_right)
break;
/* search for chessboard */
if (chessboard_search) {
chessboard_finder(frame_left);
chessboard_finder(frame_right);
}
/* show frames in window */
cvShowImage("leftimage", frame_left);
cvShowImage("rightimage", frame_right);
char c = cvWaitKey(33);
if (c == 27)
break;
if (c == 99) { /* pushed c */
chessboard_search = !(chessboard_search);
printf("Chessboard search is turned %s.\n",
(chessboard_search) ? "on" : "off");
}
}
cvReleaseCapture(&capture_left);
cvReleaseCapture(&capture_right);
cvDestroyWindow("leftimage");
cvDestroyWindow("rightimage");
return 0;
}
开发者ID:NerdToMars,项目名称:tjpstereovision,代码行数:60,代码来源:webcamviewer.c
示例2: cvCreateFileCapture
//--------------------------------------------------------------------------------------
// Name: CVInit()
// Desc: Initializate OpenCV
//--------------------------------------------------------------------------------------
bool GLCVUtils::CVInit (int mode)
{
if (mode == VIDEO_FILE)
{
capture = cvCreateFileCapture ("Ratatouille.avi");
if (! capture) printf ("\n\n\nerror creating file capture\n\n\n");
}
else if (mode == CAMERA)
{
// create capture
capture = cvCreateCameraCapture (0);
if (! capture)
{
printf ("\nError creating capture");
return false;
}
// sets camera (hardware) resolution
cvSetCaptureProperty (capture, CV_CAP_PROP_FRAME_WIDTH, TEXTURE_W);
cvSetCaptureProperty (capture, CV_CAP_PROP_FRAME_HEIGHT, TEXTURE_H);
}
else
{
printf ("\nWrong Mode");
}
return true;
}
开发者ID:andrecurvello,项目名称:gesture-recognition,代码行数:35,代码来源:glcvutils.cpp
示例3: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
CvCapture* kameraku;
kameraku=cvCreateCameraCapture(1);
assert(kameraku!=NULL);
IplImage* framemurah;//=cvQueryFrame(kameraku);
IplImage* framegray;//=cvCreateImage(cvSize( framemurah->width, framemurah->height ), IPL_DEPTH_8U, 1 );
//cvCvtColor(framemurah,framegray,CV_RGB2GRAY );
while(1){
framemurah=cvQueryFrame(kameraku);
//if(!framemurah) break;
cvNamedWindow("Kamera1", CV_WINDOW_AUTOSIZE);
cvShowImage("Kamera1", framemurah);
char c = cvWaitKey(33);
framegray=cvCreateImage(cvSize( framemurah->width, framemurah->height ), IPL_DEPTH_8U, 1 );
cvCvtColor(framemurah,framegray,CV_RGB2GRAY);//konvert RGB to Gray
//cvThreshold(framemurah,framegray, g_thresh, 255, CV_THRESH_BINARY);
cvThreshold(framegray,framegray, 50, 255, CV_THRESH_BINARY);
cvNamedWindow("Kamera2", CV_WINDOW_AUTOSIZE);
cvShowImage("Kamera2", framegray);
char v = cvWaitKey(33);
//if(c==27) break;
}
cvReleaseCapture(&kameraku);
cvDestroyWindow("Kamera1");
cvDestroyWindow("Kamera2");
}
开发者ID:rizkiutama,项目名称:rgb_grayscale,代码行数:32,代码来源:v.1.0.cpp
示例4: main
int main(int args,char *argv[]){
// 视频结构
CvCapture *capture = NULL;
// 获得摄像头数据
// CV_CAP_ANY 自动
capture = cvCreateCameraCapture(CV_CAP_ANY);
if (!capture) {
exit(0);
}
cvNamedWindow("camera",CV_WINDOW_AUTOSIZE);
// 图片结构
IplImage *image = NULL;
while(image = cvQueryFrame(capture)){
// 反色处理
cvNot(image,image);
// 现实图像
cvShowImage("camera",image);
// 监听键盘输入,如果有输入则跳出while
if( cvWaitKey(2) >= 0 )
break;
}
// 释放视频
cvReleaseCapture(&capture);
return 0;
}
开发者ID:itrufeng,项目名称:learncv,代码行数:25,代码来源:main.cpp
示例5: cvReleaseCapture
void ColibriMainWindow::on_camButton_toggled(bool checked)
{
if(!checked) {
if(m_timer.isActive())
m_timer.stop();
// Stop thread
if(m_pColibriThread) {
m_pColibriThread->stop();
m_pColibriThread->setCapture(NULL);
}
cvReleaseCapture(&capture);
capture = NULL;
return;
}
if(!capture) {
int retry = 0;
do {
capture = cvCreateCameraCapture (retry);
fprintf(stderr, "[Colibri] %s:%d : capture #%d =%p\n", __func__, __LINE__,
retry, capture);
retry++;
} while(!capture && retry < 5);
}
if(!capture) {
QMessageBox::critical(NULL, tr("No webcam"),
tr("Unable to find webcam. Please try disconnect/reconnect."));
return ; }
startBackgroundThread();
}
开发者ID:cseyve,项目名称:piaf,代码行数:34,代码来源:colibrimainwindow.cpp
示例6: 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;
}
*/
}
开发者ID:trago,项目名称:scannCIO,代码行数:27,代码来源:camera.cpp
示例7: main
int main()
{
int thresh=25;
CvCapture* capture;
capture = cvCreateCameraCapture(-1);
IplImage *frame,*res;
char win[]="video_stream";
char win2[]="outline_feed";
cvNamedWindow(win,CV_WINDOW_AUTOSIZE);
cvNamedWindow(win2,CV_WINDOW_AUTOSIZE);
cvCreateTrackbar("Threshold",win2,&thresh,128);
while(1)
{
frame=cvQueryFrame(capture);
res = findedge(frame,thresh);
clearnoise(res,0, 3);
clearnoise(res,1, 3);
cvShowImage(win,frame);
cvShowImage(win2,res);
if(cvWaitKey(50)==27)
break;
}
cvReleaseImage(&frame);
cvReleaseImage(&res);
cvReleaseCapture(&capture);
cvDestroyWindow(win);
cvDestroyWindow(win2);
return 0;
}
开发者ID:nevinvalsaraj,项目名称:image-processing-opencv,代码行数:31,代码来源:findedges_naive.cpp
示例8: main
////////////////////////////////////////////////////////////////////////////
// MAIN ////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
///
/// Main program.
///
int main( int argc, char *argv[] )
{
CvCapture *video;
IplImage *frame;
char *win_name = "Captured Frame";
char key = 0;
video = cvCreateCameraCapture( -1 );
// video = cvCreateFileCapture( argv[1] );
if ( !video ) {
fprintf( stderr, "unable to capture source\n" );
exit( 1 );
} else {
printf( "capture source opened.\n" );
}
printCaptureProperties( video );
printf( "Press 'q' to quit.\n" );
while ( ( frame = cvQueryFrame( video ) ) && ( char ) key != 'q' ) {
cvNamedWindow( win_name, 1 );
cvShowImage( win_name, frame );
key = cvWaitKey( 5 );
}
cvDestroyWindow( win_name );
cvReleaseCapture( &video );
return 0;
}
开发者ID:notooth,项目名称:reconos,代码行数:38,代码来源:camgrab.c
示例9: main
int main() {
// Image & hsvImage
//IplImage *hsv;
// Video Capture
CvCapture *capture;
// Key for keyboard event
char key;
// Number of tracked pixels
int nbPixels;
// Next position of the object we overlay
CvPoint objectNextPos;
// Initialize the video Capture (200 => CV_CAP_V4L2)
capture = cvCreateCameraCapture(200);
// Check if the capture is ok
if (!capture) {
printf("Can't initialize the video capture.\n");
return -1;
}
// Create the windows
cvNamedWindow("Test Color Tracking", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Test Mask", CV_WINDOW_AUTOSIZE);
cvMoveWindow("Test Color Tracking", 0, 100);
cvMoveWindow("Test Mask", 650, 100);
// Mouse event to select the tracked color on the original image
cvSetMouseCallback("Test Color Tracking", getObjectColor);
// While we don't want to quit
while(key != 'Q' && key != 'q') {
// We get the current image
image = cvQueryFrame(capture);
// If there is no image, we exit the loop
if(!image)
continue;
objectNextPos = binarisation(image, &nbPixels);
addObjectToVideo(image, objectNextPos, nbPixels);
// We wait 10 ms
key = cvWaitKey(10);
}
// Destroy the windows we have created
cvDestroyWindow("Test Color Tracking");
cvDestroyWindow("Test Mask");
// Destroy the capture
cvReleaseCapture(&capture);
return 0;
}
开发者ID:alahache,项目名称:filrouge-tmb,代码行数:60,代码来源:track_base_openCv.cpp
示例10: main
int main(int argc, char *argv[]) {
// Face detection
if (initFacedetect() < 0)
exit(-1);
numImgs = argc - 1;
imgPaths = argv + 1;
if (numImgs == 0) {
// Camera input
//capture = cvCaptureFromCAM(-1);
capture = cvCreateCameraCapture(-1);
if (capture == NULL) {
printf("Couldn't start camera\n");
exit(-1);
}
}
cvNamedWindow("preview", 1);
videoFunc();
cvDestroyWindow("preview");
if (numImgs == 0)
cvReleaseCapture(&capture);
deinit_opt_flow();
SDL_Quit();
return 0;
}
开发者ID:mifi,项目名称:facetracker,代码行数:32,代码来源:main.c
示例11: Qt_Gui_by_ABK
int Qt_Gui_by_ABK (int a,char *b[])
{
CvCapture *capture ;
IplImage *frame=0;
capture = cvCreateCameraCapture(0);
int n = 0;
//resoulution
// cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,1024);
//cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,768);
QApplication app(a,b,true);
QLabel label ;
QSplashScreen * splash = new QSplashScreen;
while(1)
{
frame = cvQueryFrame(capture);
printf("the camera resoulution is %dx%d\n",frame->width,frame->height);
cvCvtColor(frame,frame,CV_BGR2RGB);
QImage image =QImage((uchar*)frame->imageData,frame->width,frame->height,QImage::Format_RGB888);
splash->setPixmap(QPixmap::fromImage(image));
splash->show();
//label.update();
n++;
}
return app.exec();
}
开发者ID:JackABK,项目名称:Codec_Engine_Video_Process_on_the_BBxM,代码行数:31,代码来源:QtGui_test.c
示例12: main
int main( int argc, char** argv )
{
cvNamedWindow( "Press Any Key to Quit", CV_WINDOW_AUTOSIZE );
CvCapture *capture = cvCreateCameraCapture(0);
if( capture == NULL )
{
printf( "\n!ERROR! - Could not open camera at /dev/video0\n\n" );
printf( "\nIf you are using VMWare, verify that the camera is connected" );
printf( "\nto the VMWare image by selecting 'Virtual Machine' in the" );
printf( "\nVMWare player window header above. " );
printf( "\nThen select 'removable devices' and verify your camera is connected.\n\n\n" );
assert(0);
}
IplImage *frame;
while(1)
{
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "Press Any Key to Quit", frame );
char c = cvWaitKey(33);
if( c != -1 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "Press Any Key to Quit" );
}
开发者ID:challinan,项目名称:opencv-examples,代码行数:28,代码来源:framework.cpp
示例13: cvCreateCameraCapture
void VideoReader::useCamera(int idCamera)
{
auto tmp = cvCreateCameraCapture(idCamera);
if( ! tmp )
throw Exception::buildException("Can't use this camera as source", "VideoReader", "useCamera", EPC);
m_video = tmp;
}
开发者ID:Neckara,项目名称:ProjetSI2,代码行数:7,代码来源:videoreader.cpp
示例14: main
int main(int argc, char** argv) {
CvCapture* capture = 0;
IplImage* input = 0;
IplImage* output = 0;
int tick = 0, prev_tick = 0;
double now = 0.0;
CvFont font;
char buffer[256];
const char* windowName = "median";
if (argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0]))) {
capture = cvCreateCameraCapture(argc == 2 ? argv[1][0] - '0' : 0);
} else if (argc == 2) {
capture = cvCreateFileCapture(argv[1]);
}
if (!capture) {
fprintf(stderr, "ERROR: capture is NULL \n");
return (-1);
}
cvNamedWindow(windowName, CV_WINDOW_AUTOSIZE);
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0.0, 1, 0);
input = cvQueryFrame(capture);
if (!input) {
fprintf(stderr, "Could not query frame...\n");
return (-1);
}
output = cvCreateImage(cvSize(input->width, input->height), IPL_DEPTH_8U, 3);
while (1) {
input = cvQueryFrame(capture);
if (!input) {
fprintf(stderr, "Could not query frame...\n");
break;
}
process(input, output);
sprintf(buffer, "%3.1lfms", now / 1000);
cvPutText(output, buffer, cvPoint(50, 150), &font, CV_RGB(255, 0, 0));
cvShowImage(windowName, output);
//If a certain key pressed
if (cvWaitKey(10) >= 0) {
break;
}
tick = cvGetTickCount();
now = (tick - prev_tick) / cvGetTickFrequency();
prev_tick = tick;
}
cvReleaseImage(&output);
cvReleaseCapture(&capture);
cvDestroyWindow(windowName);
return 0;
}
开发者ID:rito96,项目名称:3Asemester,代码行数:60,代码来源:median.c
示例15: cvCreateCameraCapture
void MyDisplay::camera_negatif()
{
capture = cvCreateCameraCapture(CV_CAP_ANY);
while (1){
frame = cvQueryFrame(capture);
img_nvg = cvCreateImage(cvGetSize(frame), frame->depth, 1);
//conversion en niveau de gris
cvConvertImage(frame, img_nvg, 0);
stretch_histogram_NVG(img_nvg);
negatif(img_nvg);
//frame = negatif(frame);
cvShowImage("test", img_nvg);
int key = cvWaitKey(1);
if (key == 'q')
{
break;
}
else {
//nothing to do
}
}
cvReleaseCapture(&capture);
}
开发者ID:estei-master,项目名称:segment_SOL,代码行数:27,代码来源:mydisplay.cpp
示例16: init_fish
int init_fish(){
cvNamedWindow( "set_HSV", CV_WINDOW_NORMAL);
cvNamedWindow( "Camera", CV_WINDOW_NORMAL);
set_mouse_bar("Camera");
g_capture = cvCreateCameraCapture( 0 );
if(g_capture == NULL){
printf("no camra in comp\n");
exit(0);
}
frame = cvQueryFrame( g_capture );
cvCvtColor(frame,frame,CV_RGB2HSV);
cl_frame = cvCloneImage(frame);
cl_frame_temp = cvCloneImage(frame);
frameSize = cvGetSize(frame);
gr_frame = cvCreateImage(frameSize,IPL_DEPTH_8U,1);
// set_trac_bar("set_HSV");
onTrackbarSlide(0);
g_msPrm.isDrawing = 0;
g_msPrm.image = cl_frame;
g_msPrm.box = cvRect( 0, 0, 1, 1 );
mouse("Camera",&g_msPrm);
return 0;
}
开发者ID:gomord,项目名称:opencv2,代码行数:26,代码来源:fish.c
示例17: 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;
}
开发者ID:zzzsss,项目名称:two_b,代码行数:26,代码来源:the_project.cpp
示例18: main
int main(int argc, char **argv) {
/* init camera */
CvCapture* pCapture = cvCreateCameraCapture(0);
cvSetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_WIDTH, 320);
cvSetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_HEIGHT, 240);
//cvSetCaptureProperty(pCapture, CV_CAP_PROP_FPS, 5);
IplImage *pFrame = 0;
if (NULL == pCapture) {
fprintf(stderr, "Can't initialize webcam!\n");
return 1;
}
pFrame = cvQueryFrame(pCapture); // query a frame
if(NULL == pFrame) {
fprintf(stderr, "Can't get a frame!\n" );
return 1;
}
const char *pImageFileName = "webcam.jpg";
cvSaveImage(pImageFileName, pFrame);
cvReleaseCapture(&pCapture); // free memory
return 0;
}
开发者ID:MAGI-Yang,项目名称:Face,代码行数:28,代码来源:cam.c
示例19: main
int main()
{
CvCapture *capture;
IplImage *frame;
capture=cvCreateCameraCapture(0);
cvNamedWindow("Webcam",0);
CvVideoWriter *writer = NULL;
char AviFileName[]="Output.avi";
int AviForamt = 1;
int FPS = 20;
CvSize AviSize = cvSize(640,480);
int AviColor = 1;
writer=cvCreateVideoWriter(AviFileName, CV_FOURCC('P','I','M','1'), FPS,AviSize,AviColor);
if(writer == NULL)
printf("writer null..\n");
int i=0;
while(true)
{
frame = cvQueryFrame(capture);
cvWriteFrame(writer,frame);
cvShowImage("Webcam",frame);
printf("%d\n",i);
if(cvWaitKey(20)>0) break;
i++;
}
cvReleaseCapture(&capture);
cvReleaseVideoWriter(&writer);
cvDestroyWindow("Webcam");
}
开发者ID:SunnerLi,项目名称:opt,代码行数:35,代码来源:record.c
示例20: main
int main()
{
int low=0,high=128;
CvCapture* capture;
capture = cvCreateCameraCapture(-1);
IplImage *frame,*grey,*res;
char win[]="video_stream";
char win2[]="outline_feed";
cvNamedWindow(win,CV_WINDOW_AUTOSIZE);
cvNamedWindow(win2,CV_WINDOW_AUTOSIZE);
cvCreateTrackbar("Low",win2,&low,128);
cvCreateTrackbar("High",win2,&high,128);
frame=cvQueryFrame(capture);
grey=cvCreateImage(cvSize(frame->width,frame->height),IPL_DEPTH_8U,1);
res=cvCreateImage(cvSize(frame->width,frame->height),IPL_DEPTH_8U,1);
while(1)
{
frame=cvQueryFrame(capture);
cvCvtColor(frame,grey,CV_BGR2GRAY);
cvCanny(grey,res,low,high,3);
cvShowImage(win,frame);
cvShowImage(win2,res);
char c=cvWaitKey(33);
if(c==27)
break;
}
cvReleaseImage(&frame);
cvReleaseImage(&res);
cvReleaseCapture(&capture);
cvDestroyWindow(win);
cvDestroyWindow(win2);
return 0;
}
开发者ID:nevinvalsaraj,项目名称:image-processing-opencv,代码行数:35,代码来源:cannyedges.cpp
注:本文中的cvCreateCameraCapture函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论