Base class for
Segmentation
. Declaration Segmentation
Network number of segmentation classes label 0 name: "unlabeled" label 1 name: "ego vehicle" label 2 name: "rectification border" label 3 name: "out of roi" label 4 name: "static" label 5 name: "dynamic" label 6 name: "ground" label 7 name: "road" label 8 name: "sidewalk" label 9 name: "parking" label 10 name: "rail track" label 11 name: "building" label 12 name: "wall" label 13 name: "fence" label 14 name: "guard rail" label 15 name: "bridge" label 16 name: "tunnel" label 17 name: "pole"
Input is an image (cv:Mat).
Output is result of running the Segmentation
network.
Sample code :
auto det =vitis::ai::Segmentation::create
("fpn", true);
auto img= cv::imread("sample_segmentation.jpg");
int width = det->getInputWidth();
int height = det->getInputHeight();
cv::Mat image;
cv::resize(img, image, cv::Size(width, height), 0, 0,
cv::INTER_LINEAR);
auto result = det->run_8UC1(image);
for (auto y = 0; y < result.segmentation.rows; y++) {
for (auto x = 0; x < result.segmentation.cols; x++) {
result.segmentation.at<uchar>(y,x) *= 10;
}
}
cv::imwrite("segres.jpg",result.segmentation);
auto resultshow = det->run_8UC3(image);
resize(resultshow.segmentation, resultshow.segmentation,
cv::Size(resultshow.cols * 2, resultshow.rows * 2));
cv::imwrite("sample_segmentation_result.jpg",resultshow.segmentation);
Figure 1. segmentation Visualization Result Image
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::Segmentation
class:
Type | Name | Arguments |
---|---|---|
std::unique_ptr< Segmentation > |
create |
|
int | getInputWidth |
|
int | getInputHeight |
|
size_t | get_input_batch |
|
SegmentationResult
|
run_8UC1 |
|
std::vector< SegmentationResult > |
run_8UC1 |
|
SegmentationResult
|
run_8UC3 |
|
std::vector< SegmentationResult > |
run_8UC3 |
|