CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
G-API: Refine Semantic Segmentation Demo #23766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
G-API: Refine Semantic Segmentation Demo #23766
Conversation
explicit GCaptureSource(int id) : cap(id) { prep(); } | ||
explicit GCaptureSource(const std::string &path) : cap(path) { prep(); } | ||
using Properties = std::unordered_map<int, double>; | ||
explicit GCaptureSource(int id, const Properties &properties = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I wish it was separate method set
but properties must be set before the first frame is read (prep()
)
} | ||
|
||
static void drawResults(cv::Mat &img, const cv::Mat &color_mask) { | ||
img = img / 2 + color_mask / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not so efficient due reallocations but it doesn't impact performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should thing how we can make stuff like this in graph -- where a desynchronized path meets the synchronized one, and results are accumulated inside as we do now manually..
Good idea for future versions
cv::Mat mask_img; | ||
classesToColors(classes, mask_img); | ||
cv::resize(mask_img, out, in.size()); | ||
cv::resize(mask_img, out, in.size(), 0, 0, cv::INTER_NEAREST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INTER_NEAREST
is better when it comes to resize color mask
source = std::make_shared<cv::gapi::wip::GCaptureSource>( | ||
std::stoi(input), | ||
cv::gapi::wip::GCaptureSource::Properties { | ||
{cv::CAP_PROP_FRAME_WIDTH, 1280}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded so far, not sure if it should be cmd
option
a19aa1c
to
cf2505c
Compare
@dmatveev Could you have a look, please? |
explicit GCaptureSource(int id) : cap(id) { prep(); } | ||
explicit GCaptureSource(const std::string &path) : cap(path) { prep(); } | ||
using Properties = std::unordered_map<int, double>; | ||
explicit GCaptureSource(int id, const Properties &properties = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exposed to python so far...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposed now
static std::vector<cv::Vec3b> colors = { | ||
{0, 0, 0}, {0, 0, 128}, {0, 128, 0}, {0, 128, 128}, {128, 0, 0}, {128, 0, 128}, {128, 128, 0}, | ||
{128, 128, 128}, {0, 0, 64}, {0, 0, 192}, {0, 128, 64}, {0, 128, 192}, {128, 0, 64}, {128, 0, 192}, | ||
{128, 128, 64}, {128, 128, 192}, {0, 64, 0}, {0, 64, 128}, {0, 192, 0}, {0, 192, 128}, {128, 64, 0} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for this change? Previously it was just one line per class, easy to edit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I'll keep old alignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
static void drawResults(cv::Mat &img, const cv::Mat &color_mask) { | ||
img = img / 2 + color_mask / 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should thing how we can make stuff like this in graph -- where a desynchronized path meets the synchronized one, and results are accumulated inside as we do now manually..
Good idea for future versions
@dmatveev @asmorkalov Hi folks, can we merge this? |
{cv::CAP_PROP_FRAME_HEIGHT, 720}, | ||
{cv::CAP_PROP_BUFFERSIZE, 1}, | ||
{cv::CAP_PROP_AUTOFOCUS, true}, | ||
{cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('M', 'J', 'P', 'G')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works not with all cameras. I propose to add note on required camera parameters to help message and the source file header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'd rather remove it then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…aTalamanov/opencv into at/segmentation-demo-desync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…emo-desync G-API: Refine Semantic Segmentation Demo opencv#23766 ### Overview * Supported demo working with camera id (e.g `--input=0`) * Supported 3d output segmentation models (e.g `deeplabv3`) * Supported `desync` execution * Supported higher camera resolution * Changed the color map to pascal voc (https://cloud.githubusercontent.com/assets/4503207/17803328/1006ca80-65f6-11e6-9ff6-36b7ef5b9ac6.png) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [ ] I agree to contribute to the project under Apache 2 License. - [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
…emo-desync G-API: Refine Semantic Segmentation Demo opencv#23766 ### Overview * Supported demo working with camera id (e.g `--input=0`) * Supported 3d output segmentation models (e.g `deeplabv3`) * Supported `desync` execution * Supported higher camera resolution * Changed the color map to pascal voc (https://cloud.githubusercontent.com/assets/4503207/17803328/1006ca80-65f6-11e6-9ff6-36b7ef5b9ac6.png) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [ ] I agree to contribute to the project under Apache 2 License. - [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
Overview
--input=0
)deeplabv3
)desync
executionPull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.