第一次发帖,希望我以正确的方式放置代码.
我想检测和视频计数的车辆,所以如果你看一下我的代码下面我发现图像的轮廓阈值和扩张后,然后我用drawContours和矩形中绘制所检出的轮廓框.
我试着在drawContours/rectangle if语句中添加一个过滤器,说明矩形的面积是否大于40,000,然后不要绘制它.
现在,如果你看一下我附上的图片,你会发现在较大的矩形内部绘制了矩形,我不想这样做.在此输入图像描述.这些矩形的面积小于40,000但是由于某种原因它们被绘制.
我打算使用矩形来计算图像上的汽车,但如果这不是最好的方法,我会接受建议.
谢谢.
using namespace cv;
using namespace std;
int main()
{
VideoCapture TestVideo; //Declare video capture
Mat frame; //declare Mat as frame to grab
TestVideo.open("FroggerHighway.mp4"); //open the test video from the project directory
if (!TestVideo.isOpened()) //If its not open declare the error
{
cout << "Video did not open." << endl;
waitKey(0);
}
if (TestVideo.get(CV_CAP_PROP_FRAME_COUNT) < 1) //If the frame count is less than 1, basically an error checker
{
cout << "Video …Run Code Online (Sandbox Code Playgroud) c++ opencv image-processing image-recognition opencv-contour