我在操作.
在那之后,在 Mat 上进行简单的迭代来寻找角落像素 是微不足道的,我在 回答.
#include #include int main(int argc, char* argv[]){cv::Mat img = cv::imread(argv[1]);std::cout <<原始图像尺寸:" <积分;cv::Mat_::iterator it = gray.begin();cv::Mat_::iterator end = gray.end();for (; it != end; it++){如果它)points.push_back(it.pos());}//从这些点,算出ROI的大小int 左、右、上、下;for (int i = 0; i 右)右 = 点 [i].x;if (points[i].y < top)顶部 = 点 [i].y;如果(点 [i].y > 底部)底部 = 点 [i].y;}std::vectorbox_points;box_points.push_back(cv::Point(left, top));box_points.push_back(cv::Point(left, bottom));box_points.push_back(cv::Point(right, bottom));box_points.push_back(cv::Point(right, top));//计算 ROI 的最小边界框//注意:由于某些未知原因,框的宽度/高度发生了切换.cv::RotatedRect box = cv::minAreaRect(cv::Mat(box_points));std::cout <<框 w:"<<box.size.width <<" h:" <<box.size.height <<std::endl;//在原始图像中绘制边界框(调试目的)//cv::Point2f 顶点[4];//box.points(vertices);//for (int i = 0; i <4; ++i)//{//cv::line(img, vertices[i], vertices[(i + 1) % 4], cv::Scalar(0, 255, 0), 1, CV_AA);/
断言失败(size.width>0 && size.height&gAssertion failed (size.widthgt;0 amp;amp; size.heightgt;0)(断言失败(size.width0 amp;amp; size.height0))
在 C++ 中旋转图像而不使用 OpenCV 函数Rotate an image in C++ without using OpenCV functions(在 C++ 中旋转图像而不使用 OpenCV 函数)
OpenCV:处理每一帧OpenCV: process every frame(OpenCV:处理每一帧)
为什么我不能在 openCV 中打开 avi 视频?Why can#39;t I open avi video in openCV?(为什么我不能在 openCV 中打开 avi 视频?)
OpenCV 无法设置 SVM 参数OpenCV unable to set up SVM Parameters(OpenCV 无法设置 SVM 参数)
使用 cvtColor 转换单一颜色Convert a single color with cvtColor(使用 cvtColor 转换单一颜色)