相关疑难解决方法(0)

OpenCV C++/Obj-C:检测一张纸/方形检测

我在我的测试应用程序中成功实现了OpenCV平方检测示例,但现在需要过滤输出,因为它非常混乱 - 或者我的代码是错误的?

我对本文的四个角点感兴趣,以减少偏斜(如此)和进一步处理......

输入输出: 输入输出

原始图片:

点击

码:

double angle( cv::Point pt1, cv::Point pt2, cv::Point pt0 ) {
    double dx1 = pt1.x - pt0.x;
    double dy1 = pt1.y - pt0.y;
    double dx2 = pt2.x - pt0.x;
    double dy2 = pt2.y - pt0.y;
    return (dx1*dx2 + dy1*dy2)/sqrt((dx1*dx1 + dy1*dy1)*(dx2*dx2 + dy2*dy2) + 1e-10);
}

- (std::vector<std::vector<cv::Point> >)findSquaresInImage:(cv::Mat)_image
{
    std::vector<std::vector<cv::Point> > squares;
    cv::Mat pyr, timg, gray0(_image.size(), CV_8U), gray;
    int thresh = 50, N = 11;
    cv::pyrDown(_image, pyr, cv::Size(_image.cols/2, _image.rows/2));
    cv::pyrUp(pyr, …
Run Code Online (Sandbox Code Playgroud)

c++ opencv image-processing objective-c computer-vision

171
推荐指数
3
解决办法
11万
查看次数

方检测未找到方块

我使用的程序squares.c的OpenCV库的样本中找到.它适用于每个图像,但我真的无法弄清楚为什么它不能识别该图像中绘制的正方形

http://desmond.imageshack.us/Himg12/scaled.php?server=12&filename=26725680.jpg&res=medium

CANNY之后:http: //img847.imageshack.us/img847/6787/canny.jpg

DILATE之后:http: //img593.imageshack.us/img593/3010/dilate.jpg

RESULT图像(红色) http://img267.imageshack.us/img267/8016/resultuq.jpg

如您所见,未检测到方形.

在检测之后,我需要提取广场中包含的区域......没有投资回报率怎么可能?

c c++ opencv image-processing object-detection

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

找到论文的一角

我是openCV的新手,因此在过去的3到4天里一直在努力,我已经检测到纸张边界,现在我想在角落上绘制4个圆圈.

我从这段代码中画出边界

const cv::Point* p = &squares[i][0];

int n = (int)squares[i].size();

polylines(image, &p,&n, 1, true, Scalar(255,255,0), 5, CV_AA);
Run Code Online (Sandbox Code Playgroud)

我是openCV的新手,所以在我看来我有左上角点p-> x和p-> y,但是我如何得到其他角落,我也对这个折线方法中的参数&n感到困惑,这个折线方法怎么样绘制完整的矩形?

当我使用边界矩形时,它并不完美,它给纸张侧面留下了一点空间.

任何帮助都非常感谢

代码是:

- (cv::Mat)finshWork:(cv::Mat &)image
{
// read in the apple (change path to the file)
Mat img0 =image;// imread("/home/philipp/img/apple.jpg", 1);

Mat img1;
cvtColor(img0, img1, CV_RGB2GRAY);

// apply your filter
Canny(img1, img1, 100, 200);

// find the contours
vector< vector<cv::Point> > contours;
findContours(img1, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

/////for SQUARE CODE
std::vector<std::vector<cv::Point> > squares;
std::vector<cv::Point> approx;
for( size_t i = …
Run Code Online (Sandbox Code Playgroud)

iphone opencv image-processing objective-c ios

11
推荐指数
1
解决办法
7626
查看次数