【发布时间】:2011-11-03 05:52:19
【问题描述】:
我想使用 OpenCV 2.3 访问 RGB 中的像素。 我正在尝试这样,但就像每个像素在帧后都是相等的,因为我没有输出。图片来自我的网络摄像头,我可以看到它们。 顺便说一句,红色 = 0;
谢谢
Mat frame;
Mat oldFrame;
VideoCapture cap(0);
cap >> oldFrame;
sumFramePix = oldFrame.cols * oldFrame.rows;
nbChannels = oldFrame.channels();
cout << "NbcHANNELs : " << nbChannels << endl;
imshow("Video 1", oldFrame);
while(1)
{
cap >> frame;
imshow("Video 1", frame);
for(int i=0; i<frame.rows; i++)
{
for(int j=0; j<frame.cols; j++)
{
if (frame.ptr<uchar>(i)[nbChannels*j+RED] < oldFrame.ptr<uchar>(i)[nbChannels*j+RED])
{
cout << "==============-";
}
}
}
oldFrame = frame;
if(waitKey(300) >= 0) break;
}
【问题讨论】:
标签: c++ image opencv rgb pixel