Base class for detecting lanedetect from an image (cv::Mat).
Input is an image (cv::Mat).
Output road line type and points marked road line.
Sample code:
Note: The input image size is 640x480
auto det = vitis::ai::RoadLine::create
("vpgnet_pruned_0_99");
auto image = cv::imread("sample_lanedetect.jpg");
// Mat image;
// resize(img, image, Size(640, 480));
if (image.empty()) {
cerr << "cannot load " << argv[1] << endl;
abort();
}
vector<int> color1 = {0, 255, 0, 0, 100, 255};
vector<int> color2 = {0, 0, 255, 0, 100, 255};
vector<int> color3 = {0, 0, 0, 255, 100, 255};
RoadLineResult results = det->run(image);
for (auto &line : results.lines) {
vector<Point> points_poly = line.points_cluster;
// for (auto &p : points_poly) {
// std::cout << p.x << " " << (int)p.y << std::endl;
//}
int type = line.type < 5 ? line.type : 5;
if (type == 2 && points_poly[0].x < image.rows * 0.5)
continue;
cv::polylines(image, points_poly, false,
Scalar(color1[type], color2[type], color3[type]), 3,
cv::LINE_AA, 0);
}
Display of the model results:
Figure 1. result image
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::RoadLine
class:
Type | Member | Arguments |
---|---|---|
std::unique_ptr<
RoadLine
> |
create |
|
int | getInputWidth |
|
int | getInputHeight |
|
size_t | get_input_batch |
|
RoadLineResult
|
run |
|
std::vector<
RoadLineResult
> |
run |
|