此基本类对应
Segmentation
。声明
Segmentation
网络;分割类的数量,标签 0 名称:"unlabeled";标签 1 名称:"ego vehicle";标签 2 名称:"rectification border";标签 3 名称:"out of roi";标签 4 名称:"static";标签 5 名称:"dynamic";标签 6 名称:"ground";标签 7 名称:"road";标签 8 名称:"sidewalk" 标签 9 名称:"parking";标签 10 名称:"rail track";标签 11 名称:"building";标签 12 名称:"wall";标签 13 名称:"fence";标签 14 名称:"guard rail";标签 15 名称:"bridge";标签 16 名称:"tunnel";标签 17 名称:"pole"
输入为图像 (cv:Mat)。
输出是运行
Segmentation
网络的结果。
代码样本:
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);
图 1. 分割可视化结果图像
函数快速参考
下表列出了 vitis::ai::Segmentation
类中定义的所有函数:
类型 | 成员 | 实参 |
---|---|---|
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 |
|