2020-09-17 06:34:58 -0600
| received badge | ● Popular Question
(source)
|
2017-11-23 01:50:21 -0600
| received badge | ● Famous Question
(source)
|
2017-03-01 16:53:18 -0600
| received badge | ● Notable Question
(source)
|
2016-11-29 11:50:11 -0600
| received badge | ● Popular Question
(source)
|
2015-11-05 09:33:26 -0600
| received badge | ● Student
(source)
|
2015-11-05 09:31:17 -0600
| asked a question | how to draw the curve line? I'm trying to draw a curve.
But I do not know how to draw the point y, we ask for help. int matWidth = 500;
int matHeight = 500;
int fromPointX = 50;
int fromPointY = 400;
int toPointX = 300;
int toPointY = 200;
ArrayList<Point> pointList = new ArrayList<Point>();
for(int i = fromPointX; i < toPointX; i++) {
Point point = new Point();
point.x = i;
// I do not know how to draw a curve.
point.y = fromPointY++;
pointList.add(point);
}
for(int i = 1; i < pointList.size(); i++) {
Core.line(mat, pointList.get(i-1), pointList.get(i),new Scalar(255,255,0), 5);
}
|
2015-11-04 00:05:28 -0600
| received badge | ● Enthusiast
|
2015-11-03 23:54:04 -0600
| commented question | curved line detection hi uploaded original image! thank you :D |
2015-11-03 23:42:18 -0600
| received badge | ● Editor
(source)
|
2015-11-03 23:14:31 -0600
| asked a question | curved line detection I'm using OpenCV (in Java) to implement curved line detection,
to detection a curve like the yellow one in this image.
I do not know how. Help. original image
detection curve line
MatOfInt4 lines = new MatOfInt4();
Imgproc.HoughLinesP(mat, lines, 1, Math.PI / 180, 20, 15, 10);
for (int i = 0; i < lines.cols(); i++) {
double[] l = lines.get(0, i);
Point startPoint = new Point(l[0], l[1]);
Point endPoint = new Point(l[2], l[3]);
Core.line(mat, startPoint, endPoint, new Scalar(255, 0, 255), 1);
}
|
2015-10-11 09:29:49 -0600
| asked a question | opencv c++ convert to java(2.4.11) Hello everybody... i am trying to convert an c++ to an java code. ㅠ..ㅠ The difficulty is I do not know c ++ syntax. help :D web - http://opencv-code.com/tutorials/auto...
source - https://github.com/bsdnoobz/opencv-co... /**
* Automatic perspective correction for quadrilateral objects. See the tutorial at
* http://opencv-code.com/tutorials/automatic-perspective-correction-for-quadrilateral-objects/
*/
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
cv::Point2f center(0,0);
cv::Point2f computeIntersect(cv::Vec4i a,
cv::Vec4i b)
{
int x1 = a[0], y1 = a[1], x2 = a[2], y2 = a[3], x3 = b[0], y3 = b[1], x4 = b[2], y4 = b[3];
float denom;
if (float d = ((float)(x1 - x2) * (y3 - y4)) - ((y1 - y2) * (x3 - x4)))
{
cv::Point2f pt;
pt.x = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d;
pt.y = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d;
return pt;
}
else
return cv::Point2f(-1, -1);
}
void sortCorners(std::vector<cv::Point2f>& corners,
cv::Point2f center)
{
std::vector<cv::Point2f> top, bot;
for (int i = 0; i < corners.size(); i++)
{
if (corners[i].y < center.y)
top.push_back(corners[i]);
else
bot.push_back(corners[i]);
}
corners.clear();
if (top.size() == 2 && bot.size() == 2){
cv::Point2f tl = top[0].x > top[1].x ? top[1] : top[0];
cv::Point2f tr = top[0].x > top[1].x ? top[0] : top[1];
cv::Point2f bl = bot[0].x > bot[1].x ? bot[1] : bot[0];
cv::Point2f br = bot[0].x > bot[1].x ? bot[0] : bot[1];
corners.push_back(tl);
corners.push_back(tr);
corners.push_back(br);
corners.push_back(bl);
}
}
int main()
{
cv::Mat src = cv::imread("image.jpg");
if (src.empty())
return -1;
cv::Mat bw;
cv::cvtColor(src, bw, CV_BGR2GRAY);
cv::blur(bw, bw, cv::Size(3, 3));
cv::Canny(bw, bw, 100, 100, 3);
std::vector<cv::Vec4i> lines;
cv::HoughLinesP(bw, lines, 1, CV_PI/180, 70, 30, 10);
// Expand the lines
for (int i = 0; i < lines.size(); i++)
{
cv::Vec4i v = lines[i];
lines[i][0] = 0;
lines[i][1] = ((float)v[1] - v[3]) / (v[0] - v[2]) * -v[0] + v[1];
lines[i][2] = src.cols;
lines[i][3] = ((float)v[1] - v[3]) / (v[0] - v[2]) * (src.cols - v[2]) + v[3];
}
std::vector<cv::Point2f> corners;
for (int i = 0; i < lines.size(); i++)
{
for (int j = i+1; j < lines.size(); j++)
{
cv::Point2f pt = computeIntersect(lines[i], lines[j]);
if (pt.x >= 0 && pt.y >= 0)
corners.push_back(pt);
}
}
std::vector<cv::Point2f> approx;
cv::approxPolyDP(cv::Mat(corners), approx, cv::arcLength(cv::Mat(corners), true) * 0.02, true);
if (approx.size() != 4)
{
std::cout << "The object is not quadrilateral!" << std::endl;
return -1;
}
// Get mass center
for (int i = 0; i < corners.size(); i++)
center += corners[i];
center *= (1. / corners.size());
sortCorners(corners, center);
if (corners.size() == 0){
std::cout << "The corners were not sorted correctly!" << std::endl;
return -1;
}
cv::Mat dst = src.clone();
// Draw ... (more) |