1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #23766 from TolyaTalamanov:at/segmentation-demo-desync

G-API: Refine Semantic Segmentation Demo #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
This commit is contained in:
Anatoliy Talamanov
2023-06-13 16:06:19 +01:00
committed by GitHub
parent 134d0b74d3
commit a371bdac9d
5 changed files with 187 additions and 62 deletions
@@ -22,6 +22,7 @@
* because of this file.
*/
#include <chrono>
#include <map>
#include <opencv2/videoio.hpp>
#include <opencv2/gapi/garg.hpp>
@@ -47,8 +48,16 @@ namespace wip {
class GCaptureSource: public IStreamSource
{
public:
explicit GCaptureSource(int id) : cap(id) { prep(); }
explicit GCaptureSource(const std::string &path) : cap(path) { prep(); }
explicit GCaptureSource(int id, const std::map<int, double> &properties = {})
: cap(id) { prep(properties); }
explicit GCaptureSource(const std::string &path,
const std::map<int, double> &properties = {})
: cap(path) { prep(properties); }
void set(int propid, double value) {
cap.set(propid, value);
}
// TODO: Add more constructor overloads to make it
// fully compatible with VideoCapture's interface.
@@ -59,8 +68,12 @@ protected:
bool first_pulled = false;
int64_t counter = 0;
void prep()
void prep(const std::map<int, double> &properties)
{
for (const auto &it : properties) {
cap.set(it.first, it.second);
}
// Prepare first frame to report its meta to engine
// when needed
GAPI_Assert(first.empty());
@@ -114,15 +127,19 @@ protected:
};
// NB: Overload for using from python
GAPI_EXPORTS_W cv::Ptr<IStreamSource> inline make_capture_src(const std::string& path)
GAPI_EXPORTS_W cv::Ptr<IStreamSource>
inline make_capture_src(const std::string& path,
const std::map<int, double>& properties = {})
{
return make_src<GCaptureSource>(path);
return make_src<GCaptureSource>(path, properties);
}
// NB: Overload for using from python
GAPI_EXPORTS_W cv::Ptr<IStreamSource> inline make_capture_src(const int id)
GAPI_EXPORTS_W cv::Ptr<IStreamSource>
inline make_capture_src(const int id,
const std::map<int, double>& properties = {})
{
return make_src<GCaptureSource>(id);
return make_src<GCaptureSource>(id, properties);
}
} // namespace wip