小编Mad*_*man的帖子

OpenCV检测轮廓交叉点

我有2个轮廓A和B,我想检查它们是否相交.A和B都是cv :: Point类型的向量,并且具有不同的大小

为了检查交集,我试图做一个bitwise_and.这是一个例外,因为输入的大小不同.我该如何解决 ?

编辑:

附图应该能够更好地了解这个问题.汽车由蓝色轮廓跟踪,障碍物由粉红色轮廓跟踪.我需要检查交叉点. 在此输入图像描述

c++ opencv

12
推荐指数
1
解决办法
1万
查看次数

OpenCV findContours问题

我有以下代码执行背景减法,然后使用findContours绘制前景对象周围的边界.

// frame - Input frame from a camera.
// output - Output frame to be displayed.
    void process(cv:: Mat &frame, cv:: Mat &output) {

    cv::cvtColor(frame, gray, CV_BGR2GRAY); 

    // initialize background to 1st frame
    if (background.empty())
        gray.convertTo(background, CV_32F);

    // convert background to 8U
    background.convertTo(backImage,CV_8U);

    // compute difference between current image and background
    cv::absdiff(backImage,gray,foreground);

    // apply threshold to foreground image
    cv::threshold(foreground,output,threshold,255,cv::THRESH_BINARY_INV);

    // accumulate background
    cv::accumulateWeighted(gray, background, learningRate, output);

    // Find regions of interest
    std::vector<std::vector<cv::Point> > v; // Detected foreground points

    cv::findContours(output,v,CV_RETR_LIST,CV_CHAIN_APPROX_NONE); …
Run Code Online (Sandbox Code Playgroud)

c++ opencv image-processing background-subtraction

9
推荐指数
1
解决办法
5663
查看次数