本文整理汇总了C++中cvSize函数的典型用法代码示例。如果您正苦于以下问题:C++ cvSize函数的具体用法?C++ cvSize怎么用?C++ cvSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cvSize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char** argv )
{
IplImage *imageOut = 0;
IplImage *frame1,*frame2;
int B = 0;
capture1 = cvCaptureFromAVI( argv[1] );
capture2 = cvCaptureFromAVI( argv[2] );
FPS1 = cvRound( cvGetCaptureProperty(capture1, CV_CAP_PROP_FPS) );
FPS2 = cvRound( cvGetCaptureProperty(capture2, CV_CAP_PROP_FPS) );
FPS = max(FPS1, FPS2); // Use the fastest video speed.
frame1 = cvQueryFrame( capture1 );
frame2 = cvQueryFrame( capture2 );
movieWidth1 = frame1->width;
movieHeight1 = frame1->height;
movieWidth2 = frame2->width;
movieHeight2 = frame2->height;
printf("Got a video source 1 with a resolution of %dx%d at %d fps.\n", movieWidth1, movieHeight1, FPS1);
printf("Got a video source 2 with a resolution of %dx%d at %d fps.\n", movieWidth2, movieHeight2, FPS2);
width = B + max(movieWidth1, movieWidth2) + B;
height = B + movieHeight1 + B + movieHeight2 + B;
CvSize size = cvSize(width, height);
imageOut = cvCreateImage( size, 8, 3 ); // RGB image
imageOut->origin = frame1->origin;
printf("Combining the videos into a resolution of %dx%d at %d fps.\n", width, height, FPS);
int fourCC_code = CV_FOURCC('M','J','P','G'); // M-JPEG codec (apparently isn't very reliable)
int isColor = 1;
printf("Storing stabilized video into '%s'\n", argv[3]);
videoWriter = cvCreateVideoWriter(argv[3], fourCC_code, FPS, size, isColor);
cvNamedWindow( "CombineVids", 1 );
//cvNamedWindow( "CombineVids", 0 );
cvResizeWindow("CombineVids",1000,600);
while (1)
{
frame1 = cvQueryFrame( capture1 );
frame2 = cvQueryFrame( capture2 );
if( !frame1 && !frame2 )
break;
else if(!frame1)
frame1=frame2;
else if(!frame2)
frame2=frame1;
cvSetImageROI( imageOut, cvRect(B, B, movieWidth1, movieHeight1) );
cvCopy( frame1, imageOut, NULL );
cvSetImageROI( imageOut, cvRect(B, B + movieHeight1 + B, movieWidth2, movieHeight2) );
cvCopy( frame2, imageOut, NULL );
cvResetImageROI( imageOut );
cvWriteFrame(videoWriter, imageOut);
cvShowImage( "CombineVids", imageOut );
int c = cvWaitKey(30);
if( (char)c == 27 )
break;
}
return 0;
}
开发者ID:chaithanya-kiran,项目名称:Image-Processing-Video-Editing-Tools,代码行数:66,代码来源:9comvidver.cpp
示例2: computeWordSegmentation
// Function for Computing Word Segmentation
// Inputs :-
// (IplImage*) binImg : Pointer to the 1-Channel Binary Image
// (int*) numWord : It will contain the number of words in text line
// (IplImage**) wordImg : An array of IplImages where each image corresponds to a particular word of text
// Outputs :-
// (unsigned char) errCode : The Error Code of Execution
// Invoked As : errCode = computeWordSegmentation( &binImg , &numWord, &wordImg );
unsigned char computeWordSegmentation( IplImage* binImg , int* numWord, IplImage** wordImg)
{
// Check Inputs
if((binImg->imageSize<=0) || (binImg->nChannels!=1))
{
// Error Code 1: Invalid Input
return(1);
}
// Word Segmentation
int th1 =20;
int baseIndx = -1;
int widthStep = binImg->widthStep;
int count=0,flag=0, start=0,end=0;
for(int x=0 ; x< (binImg->width) ; ++x)
{
// update base index
baseIndx = baseIndx + 1 ;
int currIndx = baseIndx - widthStep;
flag=0;
for(int y =0 ; y < (binImg->height) ; ++y )
{
currIndx = currIndx +widthStep;
if( binImg->imageData[currIndx]<0)//>-1
{
flag=1;
break;
}
}
if(flag==0 or (x == binImg->width -1))
{
if(flag==1)
end = binImg->width -1;
else
end = x-1;
if( end - start > th1)
{
count++;
// Allocate Memory for the Word Image
wordImg[count] = cvCreateImage( cvSize( end-start + 2 , binImg->height) , IPL_DEPTH_8U , 1 );
int bindex = -binImg->widthStep;
int nwidthStep = end - start + 1 + 4 - (end-start + 1)%4;
int bindex1 = -nwidthStep;
for(int l=0;l< binImg->height;l++)
{
bindex = bindex + binImg->widthStep;
bindex1 = bindex1 + nwidthStep;
int cindex = bindex + start - 1;
int cindex1 = bindex1 - 1;
for(int m=0;m<nwidthStep;m++)
{
cindex = cindex + 1;
cindex1 = cindex1 + 1;
wordImg[count]->imageData[cindex1] = binImg->imageData[cindex];
}
}
start = x + 1;
}
else
{
start = x + 1;
}
}
}
*numWord = count;
// Error Code 0 : All well
return( 0 );
}
开发者ID:KarlYang2013,项目名称:Hindi-Text-Detection-and-Recognition-in-Broadcast-Videos,代码行数:86,代码来源:CVDRIKTextRecognition.cpp
示例3: computeLineSegmentation
// Function for Computing Line Segmentation
// Inputs :-
// (IplImage*) binImg : Pointer to the 1-Channel Binary Image
// (int*) numLine : It will contain the number of Lines in text box
// (IplImage**) lineImg : An array of IplImages where each image corresponds to a particular line of text
// Outputs :-
// (unsigned char) errCode : The Error Code of Execution
// Invoked As : errCode = computeLineSegmentation( &binImg , &numLine, &lineImg );
unsigned char computeLineSegmentation( IplImage* binImg , int* numLine, IplImage** lineImg)
{
// Check Inputs
if((binImg->imageSize<=0) || (binImg->nChannels!=1))
{
// Error Code 1: Invalid Input
return(1);
}
// Line Segmentation
int th1 = 0;// may depend on font
int baseIndx = -(binImg->widthStep);
int count=0,flag=0, start=0,end=0;
for(int y=0 ; y< (binImg->height) ; ++y)
{
// update base index
baseIndx = baseIndx + (binImg->widthStep) ;
int currIndx = baseIndx - 1;
flag=0;
for(int x =0 ; x < (binImg->width) ; ++x )
{
currIndx = currIndx +1;
printf("%d\n",binImg->imageData[currIndx]);
if( binImg->imageData[currIndx]<0)//>-1
{
flag=1;
break;
}
}
if(flag==0 or (y==binImg->height -1) )
{
if(flag==1)
end = binImg->height -1;
else
end = y-1;
if( end - start > th1)
{
count++;
// Allocate Memory for the Line Image
lineImg[count] = cvCreateImage( cvSize( binImg->width , end-start + 1 ) , IPL_DEPTH_8U , 1 );
int bindex = (start-1)*(binImg->widthStep);
int bindex1 = -binImg->widthStep;
for(int l=start;l<=end;l++)
{
bindex = bindex + binImg->widthStep;
bindex1 = bindex1 + binImg->widthStep;
int cindex = bindex - 1;
int cindex1 = bindex1 - 1;
for(int m=0;m< binImg->width;m++)
{
cindex++;
cindex1++;
lineImg[count]->imageData[cindex1] = binImg->imageData[cindex];
}
}
start = y+1;
}
else
{
start = y+1;
}
}
}
*numLine = count;
// Error Code 0 : All well
return( 0 );
}
开发者ID:KarlYang2013,项目名称:Hindi-Text-Detection-and-Recognition-in-Broadcast-Videos,代码行数:81,代码来源:CVDRIKTextRecognition.cpp
示例4: compare
CvScalar calcQualityIndex :: compare(IplImage *source1, IplImage *source2, Colorspace space)
{
IplImage *src1,* src2;
src1 = colorspaceConversion(source1, space);
src2 = colorspaceConversion(source2, space);
int x = src1->width, y = src1->height;
int nChan = src1->nChannels, d = IPL_DEPTH_32F;
CvSize size = cvSize(x, y);
//creating FLOAT type images of src1 and src2
IplImage *img1 = cvCreateImage(size, d, nChan);
IplImage *img2 = cvCreateImage(size, d, nChan);
//Image squares
IplImage *img1_sq = cvCreateImage(size, d, nChan);
IplImage *img2_sq = cvCreateImage(size, d, nChan);
IplImage *img1_img2 = cvCreateImage(size, d, nChan);
cvConvert(src1, img1);
cvConvert(src2, img2);
//Squaring the images thus created
cvPow(img1, img1_sq, 2);
cvPow(img2, img2_sq, 2);
cvMul(img1, img2, img1_img2, 1);
IplImage *mu1 = cvCreateImage(size, d, nChan);
IplImage *mu2 = cvCreateImage(size, d, nChan);
IplImage *mu1_sq = cvCreateImage(size, d, nChan);
IplImage *mu2_sq = cvCreateImage(size, d, nChan);
IplImage *mu1_mu2 = cvCreateImage(size, d, nChan);
IplImage *sigma1_sq = cvCreateImage(size, d, nChan);
IplImage *sigma2_sq = cvCreateImage(size, d, nChan);
IplImage *sigma12 = cvCreateImage(size, d, nChan);
//PRELIMINARY COMPUTING
//average smoothing is performed
cvSmooth(img1, mu1, CV_BLUR, B, B);
cvSmooth(img2, mu2, CV_BLUR, B, B);
//gettting mu, mu_sq, mu1_mu2
cvPow(mu1, mu1_sq, 2);
cvPow(mu2, mu2_sq, 2);
cvMul(mu1, mu2, mu1_mu2, 1);
//calculating sigma1, sigma2, sigma12
cvSmooth(img1_sq, sigma1_sq, CV_BLUR, B, B);
cvSub(sigma1_sq, mu1_sq, sigma1_sq);
cvSmooth(img2_sq, sigma2_sq, CV_BLUR, B, B);
cvSub(sigma2_sq, mu2_sq, sigma2_sq);
cvSmooth(img1_img2, sigma12, CV_BLUR, B, B);
cvSub(sigma12, mu1_mu2, sigma12);
//Releasing unused images
cvReleaseImage(&img1);
cvReleaseImage(&img2);
cvReleaseImage(&img1_sq);
cvReleaseImage(&img2_sq);
cvReleaseImage(&img1_img2);
// creating buffers for numerator and denominator
IplImage *numerator1 = cvCreateImage(size, d, nChan);
IplImage *numerator = cvCreateImage(size, d, nChan);
IplImage *denominator1 = cvCreateImage(size, d, nChan);
IplImage *denominator2 = cvCreateImage(size, d, nChan);
IplImage *denominator = cvCreateImage(size, d, nChan);
// FORMULA to calculate Image Quality Index
// (4*sigma12)
cvScale(sigma12, numerator1, 4);
// (4*sigma12).*(mu1*mu2)
cvMul(numerator1, mu1_mu2, numerator, 1);
// (mu1_sq + mu2_sq)
cvAdd(mu1_sq, mu2_sq, denominator1);
// (sigma1_sq + sigma2_sq)
cvAdd(sigma1_sq, sigma2_sq, denominator2);
//Release images
cvReleaseImage(&mu1);
cvReleaseImage(&mu2);
cvReleaseImage(&mu1_sq);
cvReleaseImage(&mu2_sq);
cvReleaseImage(&mu1_mu2);
cvReleaseImage(&sigma1_sq);
cvReleaseImage(&sigma2_sq);
cvReleaseImage(&sigma12);
cvReleaseImage(&numerator1);
// ((mu1_sq + mu2_sq).*(sigma1_sq + sigma2_sq))
cvMul(denominator1, denominator2, denominator, 1);
//.........这里部分代码省略.........
开发者ID:moravianlibrary,项目名称:differ,代码行数:101,代码来源:iqi.cpp
示例5: CVAPI
CvMat* projPoints1, CvMat* projPoints2,
CvMat* points4D);
CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
CvMat* new_points1, CvMat* new_points2);
/* Computes the optimal new camera matrix according to the free scaling parameter alpha:
alpha=0 - only valid pixels will be retained in the undistorted image
alpha=1 - all the source image pixels will be retained in the undistorted image
*/
CVAPI(void) cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
const CvMat* dist_coeffs,
CvSize image_size, double alpha,
CvMat* new_camera_matrix,
CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
CvRect* valid_pixel_ROI CV_DEFAULT(0),
int center_principal_point CV_DEFAULT(0));
/* Converts rotation vector to rotation matrix or vice versa */
CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
CvMat* jacobian CV_DEFAULT(0) );
/* Finds perspective transformation between the object plane and image (view) plane */
CVAPI(int) cvFindHomography( const CvMat* src_points,
const CvMat* dst_points,
CvMat* homography,
int method CV_DEFAULT(0),
double ransacReprojThreshold CV_DEFAULT(3),
CvMat* mask CV_DEFAULT(0));
开发者ID:AhmedAbdelmajied,项目名称:Android-OpenCV-FaceDetectionwithEyes,代码行数:30,代码来源:calib3d.hpp
示例6: main
void main()
{
// connect camera
camera1 = new CPGRCamera();
camera2 = new CPGRCamera();
camera1->open();
camera2->open();
camera1->start();
camera2->start();
input1 = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 4);
temp1 = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 4);
gray1 = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 1);
input2 = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 4);
temp2 = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 4);
gray2 = cvCreateImage(cvSize(WIDTH, HEIGHT), IPL_DEPTH_8U, 1);
cvNamedWindow("image1");
cvNamedWindow("image2");
// initialize tracker
IplImage* referenceImage = cvLoadImage("reference.png", 0);
tracker1 = new windage::ModifiedSURFTracker();
((windage::ModifiedSURFTracker*)tracker1)->Initialize(778.195, 779.430, 324.659, 235.685, -0.333103, 0.173760, 0.000653, 0.001114, 45);
((windage::ModifiedSURFTracker*)tracker1)->RegistReferenceImage(referenceImage, 267.0, 200.0, 4.0, 8);
((windage::ModifiedSURFTracker*)tracker1)->InitializeOpticalFlow(WIDTH, HEIGHT, 10, cvSize(15, 15), 3);
((windage::ModifiedSURFTracker*)tracker1)->SetOpticalFlowRunning(true);
tracker1->GetCameraParameter()->InitUndistortionMap(WIDTH, HEIGHT);
tracker2 = new windage::ModifiedSURFTracker();
((windage::ModifiedSURFTracker*)tracker2)->Initialize(778.195, 779.430, 324.659, 235.685, -0.333103, 0.173760, 0.000653, 0.001114, 45);
((windage::ModifiedSURFTracker*)tracker2)->RegistReferenceImage(referenceImage, 267.0, 200.0, 4.0, 8);
((windage::ModifiedSURFTracker*)tracker2)->InitializeOpticalFlow(WIDTH, HEIGHT, 10, cvSize(15, 15), 3);
((windage::ModifiedSURFTracker*)tracker2)->SetOpticalFlowRunning(true);
tracker2->GetCameraParameter()->InitUndistortionMap(WIDTH, HEIGHT);
// initialize ar tools
arTool = new windage::ARForOpenGL();
((windage::ARForOpenGL*)arTool)->Initialize(WIDTH, HEIGHT, true);
((windage::ARForOpenGL*)arTool)->AttatchCameraParameter(tracker1->GetCameraParameter());
// initialize spatial sensors
cubeGroup = new CubeSensorGroup();
((CubeSensorGroup*)cubeGroup)->Initialize(1, Vector3(75, 75, 75));
extendedCubeGroup = new CubeSensorGroup();
((CubeSensorGroup*)extendedCubeGroup)->Initialize(2, Vector3(0, 0, 0), 3, 10.0, 15.0);
sensorDetector = new DETECTOR_TYPE();
((DETECTOR_TYPE*)sensorDetector)->Initialize(ACTIVATION_TRESHOLD);
((DETECTOR_TYPE*)sensorDetector)->AttatchCameraParameter(0, tracker1->GetCameraParameter());
((DETECTOR_TYPE*)sensorDetector)->AttatchCameraParameter(1, tracker2->GetCameraParameter());
extendedSensorDetector = new DETECTOR_TYPE();
((DETECTOR_TYPE*)extendedSensorDetector)->Initialize(ACTIVATION_TRESHOLD);
((DETECTOR_TYPE*)extendedSensorDetector)->AttatchCameraParameter(0, tracker1->GetCameraParameter());
((DETECTOR_TYPE*)extendedSensorDetector)->AttatchCameraParameter(1, tracker2->GetCameraParameter());
// attatch sensors
sensorDetector->AttatchSpatialSensors(cubeGroup->GetSensors());
extendedSensorDetector->AttatchSpatialSensors(extendedCubeGroup->GetSensors());
// initialize rendering engine
OpenGLRenderer::init(WIDTH, HEIGHT);
OpenGLRenderer::setLight();
glutDisplayFunc(display);
glutIdleFunc(idle);
glutKeyboardFunc(keyboard);
glutMainLoop();
camera1->stop();
camera1->close();
camera2->stop();
camera2->close();
}
开发者ID:Barbakas,项目名称:windage,代码行数:76,代码来源:main.cpp
示例7: dc1394_capture_dequeue
bool CvCaptureCAM_DC1394_v2_CPP::grabFrame()
{
dc1394capture_policy_t policy = DC1394_CAPTURE_POLICY_WAIT;
bool code = false, isColor;
dc1394video_frame_t *dcFrame = 0, *fs = 0;
int i, nch;
if (!dcCam || (!started && !startCapture()))
return false;
dc1394_capture_dequeue(dcCam, policy, &dcFrame);
if (!dcFrame)
return false;
if (/*dcFrame->frames_behind > 1 ||*/ dc1394_capture_is_frame_corrupt(dcCam, dcFrame) == DC1394_TRUE)
{
goto _exit_;
}
isColor = dcFrame->color_coding != DC1394_COLOR_CODING_MONO8 &&
dcFrame->color_coding != DC1394_COLOR_CODING_MONO16 &&
dcFrame->color_coding != DC1394_COLOR_CODING_MONO16S;
if (nimages == 2)
{
fs = (dc1394video_frame_t*)calloc(1, sizeof(*fs));
//dc1394_deinterlace_stereo_frames(dcFrame, fs, DC1394_STEREO_METHOD_INTERLACED);
dc1394_deinterlace_stereo_frames_fixed(dcFrame, fs, DC1394_STEREO_METHOD_INTERLACED);
dc1394_capture_enqueue(dcCam, dcFrame); // release the captured frame as soon as possible
dcFrame = 0;
if (!fs->image)
goto _exit_;
isColor = colorStereo;
}
nch = isColor ? 3 : 1;
for (i = 0; i < nimages; i++)
{
IplImage fhdr;
dc1394video_frame_t f = fs ? *fs : *dcFrame, *fc = &f;
f.size[1] /= nimages;
f.image += f.size[0] * f.size[1] * i; // TODO: make it more universal
if (isColor)
{
if (!frameC)
frameC = (dc1394video_frame_t*)calloc(1, sizeof(*frameC));
frameC->color_coding = nch == 3 ? DC1394_COLOR_CODING_RGB8 : DC1394_COLOR_CODING_MONO8;
if (nimages == 1)
{
dc1394_convert_frames(&f, frameC);
dc1394_capture_enqueue(dcCam, dcFrame);
dcFrame = 0;
}
else
{
f.color_filter = bayerFilter;
dc1394_debayer_frames(&f, frameC, bayer);
}
fc = frameC;
}
if (!img[i])
img[i] = cvCreateImage(cvSize(fc->size[0], fc->size[1]), 8, nch);
cvInitImageHeader(&fhdr, cvSize(fc->size[0], fc->size[1]), 8, nch);
cvSetData(&fhdr, fc->image, fc->size[0]*nch);
// Swap R&B channels:
if (nch==3)
cvConvertImage(&fhdr,&fhdr,CV_CVTIMG_SWAP_RB);
if( rectify && cameraId == VIDERE && nimages == 2 )
{
if( !maps[0][0] || maps[0][0]->width != img[i]->width || maps[0][0]->height != img[i]->height )
{
CvSize size = cvGetSize(img[i]);
cvReleaseImage(&maps[0][0]);
cvReleaseImage(&maps[0][1]);
cvReleaseImage(&maps[1][0]);
cvReleaseImage(&maps[1][1]);
maps[0][0] = cvCreateImage(size, IPL_DEPTH_16S, 2);
maps[0][1] = cvCreateImage(size, IPL_DEPTH_16S, 1);
maps[1][0] = cvCreateImage(size, IPL_DEPTH_16S, 2);
maps[1][1] = cvCreateImage(size, IPL_DEPTH_16S, 1);
char buf[4*4096];
if( getVidereCalibrationInfo( buf, (int)sizeof(buf) ) &&
initVidereRectifyMaps( buf, maps[0], maps[1] ))
;
else
rectify = false;
}
cvRemap(&fhdr, img[i], maps[i][0], maps[i][1]);
}
else
cvCopy(&fhdr, img[i]);
}
code = true;
//.........这里部分代码省略.........
开发者ID:2693,项目名称:opencv,代码行数:101,代码来源:cap_dc1394_v2.cpp
示例8: main
int main(int argc, char** argv)
{
FILE *fp;
IplImage* frame_in = 0; //聲明IplImage指針
//開新視窗
cvNamedWindow( "ori", 1 );
cvNamedWindow( "DIBR", 1 );
//////////資料輸入
frame_in = cvLoadImage("D:\\3-2(d).bmp");
///////找尋影像的大小
int height = frame_in->height;
int width = frame_in->width;
int step = frame_in->widthStep/sizeof(uchar);//step = frame_in->widthStep;
printf("h = %d w = %d s = %d\n",height,width,step);
/////宣告暫存器
int i,j,k,l;
int avg_reg = 0,diff_bom,diff_right,diff_top,diff_li;
int reg_A,reg_B,reg_C,reg_D;
/////宣告影像空間CV
IplImage* frame_DIBR = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
IplImage* frame_gray = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,1);
IplImage* frame_avg = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
IplImage* frame_reg = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
IplImage* frame_out = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,3);
for( i=0 ; i < height ; i++ ){
for( j=0 ; j < width ; j++ ){
//Y[i][j] = frame_gray->imageData[i*width+j];
B[i][j] = frame_in->imageData[i*step+j*3+0];
G[i][j] = frame_in->imageData[i*step+j*3+1];
R[i][j] = frame_in->imageData[i*step+j*3+2];
Y[i][j] = R[i][j]*(0.299) + G[i][j]*(0.587) + B[i][j]*(0.114);
/*if (i>=0)
Y[i][j]=10;
if (i>=12)
Y[i][j]=100;
if (i>=50)
Y[i][j]=200; */
depth_floor[i][j] = (int)floor((double)((back_TH*i/height)));
FF[i][j] = 0;
}//end j
}//end i
/////////////////演算法
for( i=0 ; i < height ; i++ ){
for( j=0 ; j < width ; j++ ){
if ((i%4)==0 && (j%4)==0){
avg_R[i][j] = R[i][j]+R[i][j+1]+R[i][j+2]+R[i][j+3]+
R[i+1][j]+R[i+1][j+1]+R[i+1][j+2]+R[i+1][j+3]+
R[i+2][j]+R[i+2][j+1]+R[i+2][j+2]+R[i+2][j+3]+
R[i+3][j]+R[i+3][j+1]+R[i+3][j+2]+R[i+3][j+3];
avg_G[i][j] = G[i][j]+G[i][j+1]+G[i][j+2]+G[i][j+3]+
G[i+1][j]+G[i+1][j+1]+G[i+1][j+2]+G[i+1][j+3]+
G[i+2][j]+G[i+2][j+1]+G[i+2][j+2]+G[i+2][j+3]+
G[i+3][j]+G[i+3][j+1]+G[i+3][j+2]+G[i+3][j+3];
avg_B[i][j] = B[i][j]+B[i][j+1]+B[i][j+2]+B[i][j+3]+
B[i+1][j]+B[i+1][j+1]+B[i+1][j+2]+B[i+1][j+3]+
B[i+2][j]+B[i+2][j+1]+B[i+2][j+2]+B[i+2][j+3]+
B[i+3][j]+B[i+3][j+1]+B[i+3][j+2]+B[i+3][j+3];
for( k=0 ; k < 4 ; k++ )
for( l=0 ; l < 4 ; l++ ){
avg_R[i+k][j+l] = avg_R[i][j];
avg_G[i+k][j+l] = avg_G[i][j];
avg_B[i+k][j+l] = avg_B[i][j];
}
}
}//end j
}//end i
for( i=0 ; i < height ; i=i+4 ){
for( j=0 ; j < width ; j=j+4 ){
if ((i%4)==0 && (j%4)==0){
//diff_top = abs(avg[i][j]-avg[i-4][j]);
//diff_li = abs(avg[i][j]-avg[i][j-4]);
diff_bom = abs(avg_R[i][j]-avg_R[i+4][j])+abs(avg_G[i][j]-avg_G[i+4][j])+abs(avg_B[i][j]-avg_B[i+4][j]);
diff_right = abs(avg_R[i][j]-avg_R[i][j+4])+abs(avg_G[i][j]-avg_G[i][j+4])+abs(avg_B[i][j]-avg_B[i][j+4]);
// printf("[%d][%d] avg = %d avg_right = %d avg_bom = %d bom = %d right = %d\n",i+k,j+l,avg[i][j],avg[i][j+4],avg[i+4][j],diff_bom,diff_right);
// printf("FF = %d FF_R = %d FF_B = %d\n",FF[i][j],FF[i][j+4],FF[i+4][j]);
}
/*printf("top = %d li = %d\n",diff_top,diff_li);
_getch();*/
for( k=0 ; k <= 3 ; k++ )
for( l=0 ; l <= 3 ; l++ ){
// printf("[%d][%d] bom = %d right = %d\n",i+k,j+l,diff_bom,diff_right);
/*if (i == 0 ){///第一行皆為0
depth_out[i+k][j+l] = 0;
FF[i+k][j+l] = 1;
printf("1\n");
}else*/ if (diff_bom<=TH_diff && diff_right<=TH_diff && FF[i+4][j] == 0 && FF[i][j+4] == 0 ){ //下右皆為0,直接給值
if (FF[i][j] == 0){
depth_out[i+k][j+l] = depth_floor[i][j] ;
//.........这里部分代码省略.........
开发者ID:Gavin654,项目名称:cv,代码行数:101,代码来源:MST_RGB.cpp
示例9: cvCreateImage
IplImage* PlateFinder::FindPlate (IplImage *src) {
IplImage* plate;
IplImage* contourImg = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); // anh tim contour
IplImage* grayImg = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1); // anh xam
cvCvtColor(src, grayImg, CV_RGB2GRAY);
IplImage* cloneImg = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 3);
cloneImg = cvCloneImage(src);
// tien xu ly anh
cvCopy(grayImg, contourImg);
cvNormalize(contourImg, contourImg, 0, 255, CV_MINMAX);
ImageRestoration(contourImg);
IplImage* rectImg = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 3);
cvMerge(contourImg, contourImg, contourImg, NULL, rectImg); // tron anh
// tim contour cua buc anh
CvMemStorage *storagePlate = cvCreateMemStorage(0);
CvSeq *contours = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint), storagePlate);
cvFindContours(contourImg, storagePlate, &contours, sizeof(CvContour), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));
//cvShowImage("contourImg", contourImg);
int xmin, ymin, xmax, ymax, w, h, s, r;
int count;
double ratio; // ty le chieu rong tren chieu cao
CvRect rectPlate;
// luu lai cac anh co kha nang la bien so
IplImage** plateArr = new IplImage *[5];
int j = 0;
for (int i = 0; i < 5; i++)
{
plateArr[i] = NULL;
}
while (contours) {
count = contours->total;
CvPoint *PointArray = new CvPoint[count];
cvCvtSeqToArray (contours, PointArray, CV_WHOLE_SEQ);
for (int i = 0; i < count; i++)
{
if (i == 0)
{
xmin = xmax = PointArray[i].x;
ymin = ymax = PointArray[i].y;
}
if (PointArray[i].x > xmax) {
xmax = PointArray[i].x;
}
if (PointArray[i].x < xmin) {
xmin = PointArray[i].x;
}
if (PointArray[i].y > ymax) {
ymax = PointArray[i].y;
}
if (PointArray[i].y < ymin) {
ymin = PointArray[i].y;
}
}
w = xmax - xmin;
h = ymax - ymin;
s = w * h;
cvRectangle (rectImg, cvPoint(xmin, ymin), cvPoint(xmax, ymax), RED);
// loai bo nhung hinh chu nhat co ti le khong dung
if (s != 0) {
r = (contourImg->height * contourImg->width) / s;
} else {
r = 1000;
}
if (w == 0 && h == 0) {
ratio = 0;
} else {
ratio = (double)w/h;
}
if (r > 30 && r < 270) {
// ve ra hcn mau xanh la
cvRectangle (rectImg, cvPoint(xmin, ymin), cvPoint(xmax, ymax), GREEN);
if (ratio > 2.6 && ratio < 7) {
cvRectangle (rectImg, cvPoint(xmin, ymin), cvPoint(xmax, ymax), BLUE);
if (w > 80 && w < 250 && h > 25 && h < 150) {
rectPlate = cvRect (xmin, ymin, w, h);
cvRectangle (cloneImg, cvPoint(rectPlate.x, rectPlate.y),
cvPoint(rectPlate.x + rectPlate.width, rectPlate.y + rectPlate.height), RED, 3);
// cat bien so
plate = cvCreateImage(cvSize(rectPlate.width, rectPlate.height), IPL_DEPTH_8U, 3);
//.........这里部分代码省略.........
开发者ID:duyz112,项目名称:ANPR-Demo,代码行数:101,代码来源:PlateFinder.cpp
示例10: OnNewvision
int OnNewvision(IplImage* currImageBefore, IplImage* maskImage)
{
//int pAPosition[6][2]={0};//pointArrayPosition
//pAPosition[0][0]=0; pAPosition[0][1]=6;
//pAPosition[1][0]=6; pAPosition[1][1]=0;
//pAPosition[2][0]=12;pAPosition[2][1]=6;
//pAPosition[3][0]=0; pAPosition[3][1]=9;
//pAPosition[4][0]=6; pAPosition[4][1]=12;
//pAPosition[5][0]=12;pAPosition[5][1]=9;
//ListPoint pointSet1;
//pointSet1.Item = (ArrayPoint*)MallocArrayPoint();
//for (int dIndex = 0; dIndex <3; dIndex++)
//{//cvPoint(wIndex, hIndex)
// pointSet1.Item->push_back(cvPoint(pAPosition[dIndex][0], pAPosition[dIndex][1]));
//}
//
//cvCircleObj outCircle1;
//if(pointSet1.Item->size() == 0)
// return;
//FitCircleObj(pointSet1, &outCircle1);
//ListPoint pointSet2;
//pointSet2.Item = (ArrayPoint*)MallocArrayPoint();
//for (int dIndex = 3; dIndex <6; dIndex++)
//{//cvPoint(wIndex, hIndex)
// pointSet2.Item->push_back(cvPoint(pAPosition[dIndex][0], pAPosition[dIndex][1]));
//}
//cvCircleObj outCircle2;
//if(pointSet2.Item->size() == 0)
// return;
//FitCircleObj(pointSet2, &outCircle2);
//IplImage* currImage1 = cvCreateImage(cvSize(2000, 3000), IPL_DEPTH_8U, 1);
//memset(currImage1->imageData, 0, currImage1->height*currImage1->widthStep*sizeof(unsigned char));
//int bwPosition = 0;
//for (int hIndex = 0; hIndex < currImage1->width; hIndex++)
//{
// int y1 = 0, y2 = 0;
// y1 = sqrt( outCircle1.Radius * outCircle1.Radius - hIndex * hIndex);
// y2 = sqrt( outCircle2.Radius * outCircle2.Radius - hIndex * hIndex);
// for (int wIndex = 0; wIndex < currImage1->height; wIndex++)
// {
// bwPosition = hIndex*currImage1->widthStep + wIndex;
// if( wIndex < y1)
// currImage1->imageData[bwPosition] = 0;
// else if (wIndex > y1 && wIndex < y2)
// currImage1->imageData[bwPosition] = 255;
// else
// currImage1->imageData[bwPosition] = 0;
// }
//}
//cvShowImage("currImage1",currImage1);
//cvWaitKey(0);
//cvReleaseImage(&currImage1);
//return;
int hIndex = 0, wIndex = 0, ImagePosition = 0, TempPosition = 0, colorValue = 0;
bool leakLight = false; int LeakLightNum = 5;
//IplImage* currImageBefore = cvLoadImage("00.bmp", CV_LOAD_IMAGE_GRAYSCALE);
if (currImageBefore == NULL)
return 1;
if (maskImage == NULL)
{
return 2;
}
IplImage* currImage = cvCreateImage(cvSize(currImageBefore->width, currImageBefore->height), IPL_DEPTH_8U, 1);
memset(currImage->imageData, 0, currImage->height*currImage->widthStep*sizeof(unsigned char));
//使用Mask
cvCopy(currImageBefore, currImage, maskImage);
//cvShowImage("currImage",currImage);
//cvWaitKey(0);
IplImage* EdgeImage = cvCreateImage(cvSize(currImageBefore->width, currImageBefore->height), IPL_DEPTH_8U, 1);
memset(EdgeImage->imageData, 0, EdgeImage->height*EdgeImage->widthStep*sizeof(unsigned char));
cvCanny(currImage, EdgeImage, 50, 180, 3);
//cvShowImage("EdgeImage", EdgeImage);
//cvWaitKey(0);
int edgeTempPosition = 0;
for (int hIndex = 1; hIndex < EdgeImage->height - 1; hIndex++)
{
for (int wIndex = 1; wIndex < EdgeImage->width - 1; wIndex++)
{
edgeTempPosition = hIndex*EdgeImage->widthStep + wIndex;
if (EdgeImage->imageData[edgeTempPosition] == 255)
if (maskImage->imageData[edgeTempPosition + 1] == 0
//.........这里部分代码省略.........
开发者ID:Doufang,项目名称:PistonRing,代码行数:101,代码来源:CameraPublic.cpp
示例11: face_detect
// Function to detect and draw any faces that is present in an image
bool face_detect( IplImage* srcImg, std::vector<CvRect> *vectFaces, CvHaarClassifierCascade* cascade, bool detect_only)
{
// Create memory for calculations
static CvMemStorage* storage = 0;
// Create two points to represent the face locations
CvPoint pt1, pt2;
int i;
if( !cascade )
{
MY_LOG("%s: faceCascade is NULL", __FILE__);
return false;
}
// Allocate the memory storage
storage = cvCreateMemStorage(0);
// Clear the memory storage which was used before
cvClearMemStorage( storage );
int max_width = 0;
// Find whether the cascade is loaded, to find the biggest face. If yes, then:
if( cascade )
{
// There can be more than one face in an image. So create a growable sequence of faces.
// Detect the objects and store them in the sequence
DURATION_START;
CvSeq* faces = cvHaarDetectObjects( srcImg, cascade, storage,
1.1, 2, CV_HAAR_DO_CANNY_PRUNING
, cvSize(20, 20)
);
DURATION_STOP("cvHaarDetectObjects()");
// Loop the number of faces found.
for( i = 0, max_width=0; i < faces->total; i++ )
{
// Create a new rectangle for the face
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
if(vectFaces != NULL) {
vectFaces -> push_back(*r);
}
MY_LOG("%s: found face <%d,%d> with %dx%d\n", __func__, r->x, r->y, r->width, r->height);
if(!detect_only) {
// Draw the rectangle in the input image
cvRectangle( srcImg, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 );
}
if(max_width < r->width) {
pt1.x = r->x;
pt2.x = (r->x + r->width);
pt1.y = r->y;
pt2.y = (r->y + r->height);
max_width = r->width;
}
}
if(max_width <= 4) {
return false;
}
//printf("%s: (%d,%d), (%d,%d) -> (%d * %d)\n", __func__, pt1.x, pt1.y, pt2.x, pt2.y, (pt2.x - pt1.x) , (pt2.y - pt1.y));
//cvSetImageROI(srcImg, cvRect(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y));
//// __android_log_print(ANDROID_LOG_DEBUG, "run to here ", "func:%s, line:%d", __func__,__LINE__);
//// printf("%s: srcImg ROI: (%d * %d)\n",__func__, cvGetImageROI(srcImg).width, cvGetImageROI(srcImg).height );
//IplImage *tmpImg2 = cvCreateImage( cvSize(cvGetImageROI(srcImg).width, cvGetImageROI(srcImg).height), IPL_DEPTH_8U, 1);
//IplImage *tmpImg = srcImg;
////color depth
//if(srcImg->nChannels != 1) {
// cvCvtColor(srcImg, tmpImg2, CV_BGR2GRAY);
// tmpImg = tmpImg2;
//}
////resize
//*dstImg = cvCreateImage(cvSize(FACE_SIZE, FACE_SIZE), IPL_DEPTH_8U, 1);
//cvResize(tmpImg, *dstImg, CV_INTER_CUBIC);
////__android_log_print(ANDROID_LOG_DEBUG, "run to here ", "func:%s, line:%d", __func__,__LINE__);
//cvResetImageROI(srcImg);
//cvReleaseImage(&tmpImg2);
////__android_log_print(ANDROID_LOG_DEBUG, "run to here ", "func:%s, line:%d", __func__,__LINE__);
return true;
}
return false;
}
开发者ID:finalx,项目名称:finalx-labs-all,代码行数:99,代码来源:face_detect.cpp
示例12: _tmain
//////////////////////////////////
// main()
//
int _tmain(int argc, _TCHAR* argv[])
{
// try_conv();
if( !initAll() )
exitProgram(-1);
// Capture and display video frames until a face
// is detected
int frame_count = 0;
while( (char)27!=cvWaitKey(1) )
{
//Retrieve next image and
// Look for a face in the next video frame
//read into pfd_pVideoFrameCopy
if (!captureVideoFrame()){
if (frame_count==0)
throw exception("Failed before reading anything");
break; //end of video..
}
++frame_count;
CvSeq* pSeq = 0;
detectFaces(pfd_pVideoFrameCopy,&pSeq);
//Do some filtration of pSeq into pSeqOut, based on history etc,
//update data structures (history ,face threads etc.)s
list<Face> & faces_in_this_frame = FdProcessFaces(pfd_pVideoFrameCopy,pSeq);
//== draw rectrangle for each detected face ==
if (!faces_in_this_frame.empty()){ //faces detected (??)
int i = 0;
for(list<Face>::iterator face_itr = faces_in_this_frame.begin(); face_itr != faces_in_this_frame.end(); ++face_itr)
{
CvPoint pt1 = cvPoint(face_itr->x,face_itr->y);
CvPoint pt2 = cvPoint(face_itr->x + face_itr->width,face_itr->y + face_itr->height);
if (face_itr->frame_id == frame_count) //detected for this frame
cvRectangle( pfd_pVideoFrameCopy, pt1, pt2, colorArr[i++%3],3,8,0);
else //from a previous frame
cvRectangle( pfd_pVideoFrameCopy, pt1, pt2, colorArr[i++%3],1,4,0);
}
}else{ //no faces detected
Sleep(100);
}
cvShowImage( DISPLAY_WINDOW, pfd_pVideoFrameCopy );
cvReleaseImage(&pfd_pVideoFrameCopy);
} //end input while
cout << "==========================================================" << endl;
cout << "========== Input finished ================================" << endl;
cout << "==========================================================" << endl << endl;
cout << "Press a key to continue with history playback" <<endl;
char cc = fgetc(stdin);
cout << "==========================================================" << endl;
cout << "==== Playback history + rectangles + =====" << endl;
cout << "==== create output video(s) =====" << endl;
cout << "==========================================================" << endl << endl;
list<FDHistoryEntry> & pHistory = FdGetHistorySeq();
//== VIDEO WRITER START =====================
int isColor = 1;
int fps = 12;//30;//25; // or 30
int frameW = 640; // 744 for firewire cameras
int frameH = 480; // 480 for firewire cameras
CvVideoWriter * playbackVidWriter=cvCreateVideoWriter((OUTPUT_PLAYBACK_VIDEOS_DIR + "\\playback.avi").c_str(),
PFD_VIDEO_OUTPUT_FORMAT,
fps,cvSize(frameW,frameH),isColor);
CvVideoWriter * croppedVidWriter = 0;
if (!playbackVidWriter) {
cerr << "can't create vid writer" << endl;
exitProgram(-1);
}
bool wasWrittenToVideo = false;
//== VIDEO WRITER END =====================
int index = 0;
// play recorded sequence----------------------------
// i.e. just what's in the history
int playback_counter = 0;
cout << "start finding consensus rect " << endl;
//find min max
bool found =false;
int min_x = INT_MAX,//pFaceRect->x,
max_x = 0,//pFaceRect->x+pFaceRect->width,
min_y = INT_MAX,//pFaceRect->y,
max_y = 0;//pFaceRect->y+pFaceRect->height;
for (list<FDHistoryEntry>::iterator itr = pHistory.begin() ; itr != pHistory.end(); ++itr)
{
CvSeq* pFacesSeq = itr->pFacesSeq;
assert(pFacesSeq);
//TODO Might want to convert to Face here
CvRect * pFaceRect = (CvRect*)cvGetSeqElem(pFacesSeq, 0); //works only on first rec series
//.........这里部分代码省略.........
开发者ID:witwall,项目名称:planetariumfd,代码行数:101,代码来源:PlanetariumFD.cpp
示例13: cvCreateImage
void *ControlThread(void *unused)
{
int i=0;
char fileName[30];
NvMediaTime pt1 ={0}, pt2 = {0};
NvU64 ptime1, ptime2;
struct timespec;
IplImage* imgOrigin;
IplImage* imgCanny;
// cvCreateImage
imgOrigin = cvCreateImage(cvSize(RESIZE_WIDTH, RESIZE_HEIGHT), IPL_DEPTH_8U, 3);
imgCanny = cvCreateImage(cvGetSize(imgOrigin), IPL_DEPTH_8U, 1);
int angle, speed;
IplImage* imgOrigin;
IplImage* imgResult;
unsigned char status;
unsigned int gain;
CarControlInit();
PositionControlOnOff_Write(UNCONTROL);
SpeedControlOnOff_Write(1);
//speed controller gain set
//P-gain
gain = SpeedPIDProportional_Read(); // default value = 10, range : 1~50
printf("SpeedPIDProportional_Read() = %d \n", gain);
gain = 20;
SpeedPIDProportional_Write(gain);
//I-gain
gain = SpeedPIDIntegral_Read(); // default value = 10, range : 1~50
printf("SpeedPIDIntegral_Read() = %d \n", gain);
gain = 20;
SpeedPIDIntegral_Write(gain);
//D-gain
gain = SpeedPIDDifferential_Read(); // default value = 10, range : 1~50
printf("SpeedPIDDefferential_Read() = %d \n", gain);
gain = 20;
SpeedPIDDifferential_Write(gain);
angle = 1460;
SteeringServoControl_Write(angle);
// cvCreateImage
imgOrigin = cvCreateImage(cvSize(RESIZE_WIDTH, RESIZE_HEIGHT), IPL_DEPTH_8U, 3);
imgResult = cvCreateImage(cvGetSize(imgOrigin), IPL_DEPTH_8U, 1);
int flag = 1;
while(1)
{
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond, &mutex);
GetTime(&pt1);
ptime1 = (NvU64)pt1.tv_sec * 1000000000LL + (NvU64)pt1.tv_nsec;
Frame2Ipl(imgOrigin); // save image to IplImage structure & resize image from 720x480 to 320x240
pthread_mutex_unlock(&mutex);
cvCanny(imgOrigin, imgCanny, 100, 100, 3);
sprintf(fileName, "captureImage/imgCanny%d.png", i);
cvSaveImage(fileName , imgCanny, 0);
Frame2Ipl(imgOrigin, imgResult); // save image to IplImage structure & resize image from 720x480 to 320x240
pthread_mutex_unlock(&mutex);
//cvCanny(imgOrigin, imgCanny, 100, 100, 3);
sprintf(fileName, "captureImage/imgyuv%d.png", i);
cvSaveImage(fileName , imgOrigin, 0);
//sprintf(fileName, "captureImage/imgOrigin%d.png", i);
//cvSaveImage(fileName, imgOrigin, 0);
// TODO : control steering angle based on captured image ---------------
//speed set
speed = DesireSpeed_Read();
printf("DesireSpeed_Read() = %d \n", speed);
//speed = -10;
//DesireSpeed_Write(speed);
if(flag == 1){
if(greenlight>1000)
{
printf("right go\n");
Winker_Write(LEFT_ON);
usleep(1000000);
//Winker_Write(ALL_OFF);
angle = 1400;
SteeringServoControl_Write(angle);
//.........这里部分代码省略.........
开发者ID:DonghunP,项目名称:carSDK,代码行数:101,代码来源:captureOpenCV.c
示例14: process_image
void process_image()
{
// std::cout << "Checking publish count: " << image_in->publish_count << std::endl;
// image_in->lock_atom();
if (image_in->publish_count > 0) {
cvSetData(cvimage_in, codec_in->get_raster(), 3*704);
cvConvertImage(cvimage_in, cvimage_bgr, CV_CVTIMG_SWAP_RB);
// image_in->unlock_atom();
CvSize board_sz = cvSize(12, 12);
CvPoint2D32f* corners = new CvPoint2D32f[12*12];
int corner_count = 0;
//This function has a memory leak in the current version of opencv!
int found = cvFindChessboardCorners(cvimage_bgr, board_sz, corners, &corner_count,
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
IplImage* gray = cvCreateImage(cvSize(cvimage_bgr->width, cvimage_bgr->height), IPL_DEPTH_8U, 1);
cvCvtColor(cvimage_bgr, gray, CV_BGR2GRAY);
cvFindCornerSubPix(gray, corners, corner_count,
cvSize(5, 5), cvSize(-1, -1),
cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 0.01f ));
cvReleaseImage(&gray);
if (take_pic && corner_count == 144) {
std::stringstream ss;
img_cnt++;
ss << dir_name << "/Image" << img_cnt << ".jpg";
// std::ofstream imgfile(ss.str().c_str());
// imgfile.write((char*)image_in->jpeg_buffer, image_in->compressed_size);
// imgfile.close();
cvSaveImage(ss.str().c_str(), cvimage_bgr);
ss.str("");
ss << dir_name << "/Position" << img_cnt << ".txt";
std::ofstream posfile(ss.str().c_str());
observe->lock_atom();
posfile << "P: " << observe->pan_val << std::endl
<< "T: " << observe->tilt_val << std::endl
<< "Z: " << observe->lens_zoom_val << std::endl
<< "F: " << observe->lens_focus_val;
observe->unlock_atom();
posfile.close();
take_pic = false;
}
float maxdiff = 0;
for(int c=0; c<12*12; c++) {
float diff = sqrt( pow(corners[c].x - last_corners[c].x, 2.0) +
pow(corners[c].y - last_corners[c].y, 2.0));
last_corners[c].x = corners[c].x;
last_corners[c].y = corners[c].y;
if (diff > maxdiff) {
maxdiff = diff;
}
}
printf("Max diff: %g\n", maxdiff);
cvDrawChessboardCorners(cvimage_bgr, board_sz, corners, corner_count, found);
if (undistort) {
cvUndistort2(cvimage_bgr, cvimage_undistort, intrinsic_matrix, distortion_coeffs);
} else {
cvCopy(cvimage_bgr, cvimage_undistort);
}
CvFont font;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.8, 0.8, 0, 2);
std::stringstream ss;
observe->lock_atom();
ss << "P: " << observe->pan_val;
ss << " T: " << observe->tilt_val;
ss << " Z: " << observe->lens_zoom_val;
ss << " F: " << observe->lens_focus_val;
observe->unlock_atom();
cvPutText(cvimage_undistort, ss.str().c_str(), cvPoint(15,30), &font, CV_RGB(255,0,0));
ss.str("");
ss << "Found " << corner_count << " corners";
if (centering) {
ss << " -- Autocentering";
}
//.........这里部分代码省略.........
开发者ID:goretkin,项目名称:kwc-ros-pkg,代码行数:101,代码来源:calibrator.cpp
示例15: RunBlobTrackingAuto2323
//将所有模块连接使用的函数
//根据这个来修改自己的
int RunBlob
|
请发表评论