Pixcel values in 2 different frames always show to be the same.
I capture 2 different frames yet when I try to compare pixcel values between the 2 frames, they appear to be identical. I am probable misusing Vec3b. Please help an obvious novice. Thanks.
// November 11 2013 Capture and display values of 2 full color frames
#include "stdafx.h"
#include "iostream"
#include "opencv2/core/types_c.h"
#include "opencv2/opencv.hpp"
using namespace cv;
int main(int, char**)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
namedWindow("frame",1);
for(;;)
{
Mat frame;
cap >> frame; // get frame from camera
imshow("frame", frame);
if(waitKey(1000) >= 0) break;
Mat frame1;
cap >> frame1; // get frame1 from camera
imshow("frame1", frame1);
if(waitKey(1000) >= 0) break;
for(int i=0; i<480; i++)
for(int j=0; j<640; j++)
{cv::Vec3b tmp1 = frame1.at<cv::Vec3b>(i,j);std::cout << "i= "<<i<<" j= "<<j<< " frame1 "<<(int)tmp1(0) << " " << (int)tmp1(1) << " " << (int)tmp1(2)<< std::endl;
cv::Vec3b tmp = frame.at<cv::Vec3b>(i,j);std::cout << " frame "<<(int)tmp(0) << " " << (int)tmp(1) << " " << (int)tmp(2)<< std::endl;
if(waitKey(1000) >= 0) break;
}
if(waitKey(1000) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}