OpenCV, Mat operation example of sum(sqrt( A.-B) )

Simple Mat operation using opencv.
But it always not remember well.

vector< float> v1;
 vector< float> v2;
 for(int i=0; i<5; ++i)

 Mat AA(v1.size(),1,CV_32FC1); 
 //copy vector to mat  
 //create Mat  
 Mat BB(v2.size(),1,CV_32FC1); 
 //copy vector to mat  

 cout << "AA: " << AA << endl;
 cout << "BB: " << BB << endl << endl;

 Mat CC = AA-BB;
 cout << "CC = AA-BB : " << CC << endl << endl;
 CC = CC.mul(CC);
 cout << "CC.*CC or CC^2 : " << CC << endl << endl;
 cv::sqrt(CC, CC);
 cout << "sqrt(CC.) : " << CC << endl << endl;
 cv::Scalar rr = cv::sum(CC);
 float rrr = rr(0);
 cout << "sum(CC.) : " << rrr << endl << endl;


Popular posts from this blog

OpenCV Stitching example (Stitcher class, Panorama)

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Real-time N camera stitching Class.

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Optical Flow sample source code using OpenCV

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

(OpenCV Study) calcOpticalFlowFarneback example source code ( dense optical flow )

yuv422(YUYV) to RGB and RGB to yuv422(YUYV), (Using OpenCV and TBB)

OpenCV Drawing Example, (line, circle, rectangle, ellipse, polyline, fillConvexPoly, putText, drawContours)