Ask Your Question

Bezimienny123's profile - activity

2016-03-17 03:55:41 -0600 commented question Windows Phone 8.1 OpenCV

I do changes in code, but this didn't eliminate problem.

2016-03-17 01:36:39 -0600 asked a question Windows Phone 8.1 OpenCV

Hello. I'm currently working on app for Windows Phone 8.1 where I must detect line on image. And i use HoughLines. But currently i'm getting segmentation fault in loop. I use latest version opencv in windows runtime component what i link to C# project. Here is my Windows Runtime Code:

    cv::Mat convertImage(cv::Mat mat) {
        cv::Mat intermediateMat;
        cv::cvtColor(mat, intermediateMat, CV_RGB2GRAY);

        cv::Mat output;
        cv::cvtColor(intermediateMat, output, CV_GRAY2BGR);

        cv::Mat new_image = cv::Mat::zeros(mat.size(), mat.type());
        cv::Mat convert_color = cv::Mat::zeros(mat.size(), CV_8UC1);
        std::vector<cv::Vec2f> lines;
        cv::Canny(output, convert_color, 50, 200, 3);
        cv::Mat convert_color_2 = cv::Mat::zeros(mat.size(), mat.type());
        lines.reserve(1000000);
        try {
            cv::HoughLines(convert_color, lines, 1, 3.1415 / 180, 150, 0, 0);
        }
        catch (cv::Exception ex) {
            throw ex;
        }
        try {
            for (int i = 0; i < lines.size();i++)
            {
                float rho = lines [i][0], theta = lines[i][1];
                cv::Point pt1, pt2;
                double a = cos(theta), b = sin(theta);
                double x0 = a*rho, y0 = b*rho;
                pt1.x = cvRound(x0 + 1000 * (-b));
                pt1.y = cvRound(y0 + 1000 * (a));
                pt2.x = cvRound(x0 - 1000 * (-b));
                pt2.y = cvRound(y0 - 1000 * (a));
                line(convert_color_2, pt1, pt2, cv::Scalar(0, 0, 255), 3, 16);
            }
        }
        catch (cv::Exception ex) {
            throw ex;
        }
        cv::cvtColor(convert_color_2, mat, CV_GRAY2BGR);
        return mat;
    }

Thanks for any help.