Ask Your Question

Revision history [back]

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 = arho, y0 = brho; 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.

click to hide/show revision 2
No.2 Revision

updated 2016-03-17 02:08:18 -0500

berak gravatar image

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: Code:

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

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

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> 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 = arho, a*rho, y0 = brho; 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.