阅读和处理图像(OpenCV/C )
Reading and processing images (opencv/c++)
我的项目正在识别图像的面孔。图像具有相同的名称,并偶尔更改
因此,我想每次更改
时加载和处理图像我该如何修改:
while (image==NULL) {
image = cvLoadImage("ayman.jpg", 1);
}
cout << endl << "My image was finally loaded!";
对不起我的英语
好吧,假设您的图像在更改(随机)时的图像有所不同。我们如何检测到它是另一个图像,与上一张图像不同?
我们将提取图像的3个功能,它是:红色通道,绿色通道和蓝色通道的平均值(是向量)。因此,如果图像相同,则3均值是相同的,但是如果它不同,则图像已更改。
所以认为我们处于无限循环(您的while
)。
while(true) {
// we are going to say here if the image has changed or not
}
我们还可以吗?这是代码:
image = cvLoadImage("ayman.jpg", 1);
Scalar meanOfImage = mean(image);
while (true) {
Scalar meanAtThisMoment = mean(image);
// This are the three features (it's in real one, but one vector of 3).
// We are going to compare the three to be more clear.
if (meanAtThisMoment[0] == meanOfImage[0]
&&
meanAtThisMoment[1] == meanOfImage[1]
&&
meanAtThisMoment[2] == meanOfImage[2]) {
cout << endl << "The image hasn't been changed yet.";
image = cvLoadImage("ayman.jpg", 1); // added!! forgot this, sorry
} else {
cout << endl << "The image has been changed!!!";
// and now we set the meanOfImage (the main mean) of the new image to compare with the future images.
meanOfImage = meanAtThisMoment;
}
}
相关文章:
- OpenCV图像大小限制
- 如何将OpenCV图像数据从Python转换为C++?
- ROS中未定义的参考误差到OpenCV图像转换器
- C++:灰度位图标题和实时绘画+opencv图像处理
- 通过插座读取Python中的OpenCV图像
- OPENCV图像处理,向量下标超出范围
- 当摄影机参数已知时,OpenCV图像静置
- 访问linux的OpenCV-2.4.3的OPENCV图像处理库
- C OPENCV图像在Boost线程中不显示
- 图像搜索(C )中的OPENCV图像
- 在OpenCV图像中添加文本标签
- 将点云2数据转换为opencv图像
- OpenCv 图像块,大小错误
- 将opencv图像转换为gdi位图不起作用取决于图像大小
- 如何将labview图像类型转换为opencv图像类型(或Mat)
- 用C++将字节arry转换为OpenCV图像
- 嵌入OpenCV图像
- C++通过套接字发送OpenCV图像
- 为什么我在尝试将opencv图像数据指针转换为char*时出错
- OpenCV图像尺寸,而不读取整个图像