-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabel_to_bgr.cpp
More file actions
26 lines (20 loc) · 789 Bytes
/
Copy pathlabel_to_bgr.cpp
File metadata and controls
26 lines (20 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "imgviz.hpp"
int main(int argc, char **argv) {
assert(argc == 2);
std::string data_dir = std::string(argv[1]);
cv::Mat bgr = cv::imread(data_dir + "/rgb.png");
cv::Mat class_label = cv::imread(data_dir + "/class_label.png", -1);
assert(class_label.type() == CV_16UC1);
class_label.convertTo(class_label, CV_32SC1);
cv::Mat gray;
cv::cvtColor(bgr, gray, cv::COLOR_BGR2GRAY);
cv::Mat class_label_bgr = imgviz::labelToBgr(class_label, gray);
bgr = imgviz::textInRectangle(bgr, "bgr");
class_label_bgr = imgviz::textInRectangle(class_label_bgr, "class_label");
cv::Mat viz = imgviz::tile({bgr, class_label_bgr}, cv::Vec2i(1, 2));
cv::imwrite("label_to_bgr.png", viz);
if (!std::getenv("CI")) {
cv::imshow(argv[0], viz);
cv::waitKey(0);
}
}