使用Mat OpenCV访问像素
Access pixels with Mat OpenCV
我想用OpenCV 2.3访问RGB中的像素。我试着这样做,但每一帧的像素都是相等的,因为我没有输出。图片来自我的网络摄像头,我可以看到它们。Btw RED=0;
THX
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;
}
更改
oldFrame = frame;
至
oldFrame = frame.clone();
您正在创建两个指向相同数据的Mat对象。clone()
进行深度复制。
相关文章:
- 访问随机图像像素的快速方法,最多一次
- OpenCV 像素访问点与 at() - 不同的值
- 如何使用 freetype2 访问单色位图中的像素状态
- 访问和更改基于另一个图像的像素颜色-opencv c++
- OpenCV 访问像素的颜色值
- 如何在OpenCV Cuda(GpuMat)中访问像素
- 使用glgetTeximage()访问像素
- 如何在opencv C++中访问特定的超像素
- OpenCV VisualStudio,C 代码错误尝试访问像素
- 从SDL_Texture访问像素颜色
- 不能通过基于指针的访问像素强度来分割 RGB 图像
- 访问 openCV 中某个图像中所有像素的 RGB 值
- 如何使用OpenCV快速访问像素值C++
- 访问图像像素;MatIterator_<> 和 Mat::at 运算符的比较
- 提高 OpenCV 中垫像素访问的性能
- 如何访问指向 QWidget 像素的指针
- 在OpenCV Android中访问相机帧像素
- 快速像素访问 opencv
- OpenCV积分图像像素访问错误
- OpenCV单个像素访问