Jestem niezmiernie nową wizją komputerową i biblioteką opencv.Stwórz matę z wektora <point2f>
Zrobiłem trochę wyszukiwania w celu znalezienia sposobu, aby utworzyć nowy obraz z wektora Point2fs i nie znalazłem żadnych przykładów, które działają. Widziałem vector<Point>
to Mat
, ale kiedy używam tych przykładów, zawsze dostaję błędy.
Pracuję z przykładu this i każda pomoc będzie mile widziana.
Kod: Przechodzę w occludedSquare.
resize(occludedSquare, occludedSquare, Size(0, 0), 0.5, 0.5);
Mat occludedSquare8u;
cvtColor(occludedSquare, occludedSquare8u, CV_BGR2GRAY);
//convert to a binary image. pixel values greater than 200 turn to white. otherwize black
Mat thresh;
threshold(occludedSquare8u, thresh, 170.0, 255.0, THRESH_BINARY);
GaussianBlur(thresh, thresh, Size(7, 7), 2.0, 2.0);
//Do edge detection
Mat edges;
Canny(thresh, edges, 45.0, 160.0, 3);
//Do straight line detection
vector<Vec2f> lines;
HoughLines(edges, lines, 1.5, CV_PI/180, 50, 0, 0);
//imshow("thresholded", edges);
cout << "Detected " << lines.size() << " lines." << endl;
// compute the intersection from the lines detected...
vector<Point2f> intersections;
for(size_t i = 0; i < lines.size(); i++)
{
for(size_t j = 0; j < lines.size(); j++)
{
Vec2f line1 = lines[i];
Vec2f line2 = lines[j];
if(acceptLinePair(line1, line2, CV_PI/32))
{
Point2f intersection = computeIntersect(line1, line2);
intersections.push_back(intersection);
}
}
}
if(intersections.size() > 0)
{
vector<Point2f>::iterator i;
for(i = intersections.begin(); i != intersections.end(); ++i)
{
cout << "Intersection is " << i->x << ", " << i->y << endl;
circle(occludedSquare8u, *i, 1, Scalar(0, 255, 0), 3);
}
}
//Make new matrix bounded by the intersections
...
imshow("localized", localized);
chcę wziąć punkty muszę utworzyć ROI i stamtąd stworzyć nową matrycę. Czy to jest bardziej jasne? Nie jestem do końca pewien, na czym polega różnica pomiędzy tworzeniem Maty punktów i punktów rysowania w macierzy. – myselfesteem