Skip to content
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 Smart Framing Demo #3421

Open
wants to merge 46 commits into
base: master
Choose a base branch
from

Conversation

dbudniko
Copy link

@TolyaTalamanov @mpashchenkov @OrestChura please review this draft implementation


namespace custom {

const std::vector<std::string> coco_classes = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can load this from omz/data/dataset_calsses/coco_80cl.txt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpashchenkov are aware about any examples of doing so for classes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI omz/demos/instance_segmentation_demo (cases.py example for labels flag)

I think you can just add --labels flag for path to file with labels.

@mpashchenkov
Copy link
Contributor

@dbudniko, need to add tests for demo to omz/demos/tests/cases.py

Copy link
Contributor

@mpashchenkov mpashchenkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete or move to NOTE / TODO all commented code.

demos/README.md Outdated
@@ -38,6 +38,7 @@
omz_demos_image_retrieval_demo_python
omz_demos_segmentation_demo_cpp
omz_demos_segmentation_demo_python
omz_demos_smart_framing_demo_cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omz_demos_smart_framing_demo_cpp -->
omz_demos_smart_framing_demo_cpp_gapi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

demos/README.md Outdated
@@ -139,7 +140,8 @@ The Open Model Zoo includes the following demos:
- [Pedestrian Tracker C++ Demo](./pedestrian_tracker_demo/cpp/README.md) - Demo application for pedestrian tracking scenario.
- [Place Recognition Python\* Demo](./place_recognition_demo/python/README.md) - This demo demonstrates how to run Place Recognition models using OpenVINO™.
- [Security Barrier Camera C++ Demo](./security_barrier_camera_demo/cpp/README.md) - Vehicle Detection followed by the Vehicle Attributes and License-Plate Recognition, supports images/video and camera inputs.
- [Speech Recognition DeepSpeech Python\* Demo](./speech_recognition_deepspeech_demo/python/README.md) - Speech recognition demo: accepts an audio file with an English phrase on input and converts it into text. This demo does streaming audio data processing and can optionally provide current transcription of the processed part.
- [Smart Framing C++ Demo](./smart_framing_demo/cpp_gapi/README.md) - Person Detection followed by the Smart Framing/Croping and optionally Super Resolution, supports images/video and camera inputs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart Framing C++ G-API Demo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cv::GArray<custom::DetectedObject> yolo_detections;

// Now build the graph
cv::GMat in;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put graph 140 - 166 + GComputation to the beginning of main().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put graph after 221 line if it is possible

if (!FLAGS_no_show) {
//Draw detections on original image
for (const auto& el : objects) {
std::cout << el << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slog::debug << ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cv::Rect init_rect;
for (const auto& el : objects) {
if (el.labelID == 0) {//person ID
init_rect = init_rect | (cv::Rect)el;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_cast < cv::Rect > (el)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 84 to 85
}
else if (FLAGS_at_sr == "3ch") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else if (FLAGS_at_sr == "3ch") {
} else if (FLAGS_at_sr == "3ch") {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 87 to 88
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else {
} else {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 131 to 132
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else {
} else {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 135 to 136
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else {
} else {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 201 to 202
}
else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
else {
} else {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +212 to +213
cv::rectangle(image, el, cv::Scalar{ 0,255,0 }, 2, cv::LINE_8, 0);
cv::putText(image, el.label, el.tl(), cv::FONT_HERSHEY_SIMPLEX, 1.0, { 0,255,0 }, 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to draw these with render primitives in graph?
Up to you.

auto entriesNum = sideW * sideH;
const float* output_blob = (float*)blob.data;

auto postprocessRawData = /*(yoloVersion == YOLO_V4 || yoloVersion == YOLO_V4_TINY) ?*/ sigmoid;// : linear;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does demo have unsupported scenarios?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for (int i = 0; i < entriesNum; ++i) {
int row = i / sideW;
int col = i % sideW;
//for (int n = 0; n < region.num; ++n) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like legacy

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 95 to 96
int obj_index = calculateEntryIndex(entriesNum, /*region.coords*/ region_coords, /*region.classes*/ region_classes, n * entriesNum + i, /*region.coords*/ region_coords);
int box_index = calculateEntryIndex(entriesNum, /*region.coords*/ region_coords, /*region.classes*/ region_classes, n * entriesNum + i, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 105 to 106
//double height = std::exp(output_blob[box_index + 3 * entriesNum]) * region.anchors[2 * n + 1] * original_im_h / scaleH;
//double width = std::exp(output_blob[box_index + 2 * entriesNum]) * region.anchors[2 * n] * original_im_w / scaleW;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

cv::BORDER_CONSTANT, cv::Scalar::all(127));
}
else {
image.copyTo(out);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this copy necessary? You can get image for next operations from previous graph stage.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. we need this copy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use frame from cv::gapi::copy() instead?

Comment on lines 269 to 272
static void run(const cv::Mat & in,
cv::Mat & out) {
int h = in.size[2];
int w = in.size[3];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static void run(const cv::Mat & in,
cv::Mat & out) {
int h = in.size[2];
int w = in.size[3];
static void run(const cv::Mat& in,
cv::Mat& out) {
int h = in.size[2];
int w = in.size[3];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 277 to 279
std::transform(in_p, in_p + h * w, out_p,
[](float v) { return static_cast<uint8_t>(v * 255); });
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be:
out = in * 255;
Are in and out 1-channel cv::Mat?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check with Tolik. This is his kernel.

test_cases=combine_cases(
TestCase(options={'--no_show': None, '-at_sr': '3ch',
**MONITORS,
'-i': DataPatternArg('smart-classroom-demo'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I will add comment about it bit later.


GAPI_OCV_KERNEL(OCVSuperResolutionPostProcessingKernel, custom::GSuperResolutionPostProcessingKernel) {
static void run(const cv::Mat & image, cv::Mat & out) {
float* outputData = (float*)image.data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c-style cast

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still C-style cast

@mpashchenkov mpashchenkov self-requested a review March 31, 2022 17:56
@dbudniko
Copy link
Author

dbudniko commented Apr 4, 2022

@Wovchena please review.

@Wovchena
Copy link
Collaborator

Wovchena commented Apr 4, 2022

I'm not sure when I get to it

@Wovchena Wovchena requested a review from ivikhrev April 4, 2022 13:09
-t_conf_yolo Optional. YOLO v4 Tiny confidence threshold.
-t_box_iou_yolo Optional. YOLO v4 Tiny box IOU threshold.
-advanced_pp Optional. Use advanced post-processing for the YOLO v4 Tiny.
-apply_sr Optional. Use Super Resolution post processing model.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we decide whether to apply super resolution postprocessing based on was model provided or not?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

-limit "<num>" Optional. Number of frames to store in output. If 0 is set, all frames are stored.
-res "<WxH>" Optional. Set camera resolution in format WxH.
-m_yolo "<path>" Required. Path to an .xml file with a trained YOLO v4 Tiny model.
-at_sr "<type>" Required if Super Resolution is not disabled by apply_sr=false flag. Architecture type: Super Resolution - 3 channels input (3ch) or 1 channel input (1ch).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both single-image-super-resolution (1032 and 1033) models accept 3 channel images. What for 1 channel input support?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some use cases and SR models requires 1ch input. 3ch OMZ models are currently default. But we want to have optional 1ch scenario support in place.

* \brief This function shows a help message
*/

static void showUsage() {
Copy link

@ivikhrev ivikhrev Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've redesigned a usage message for demos, see example here:

void parse(int argc, char* argv[]) {

Please, update in accordance with it:

  • move to main.cpp
  • wrap into anonymous namespace
  • define flag and it's message nearby like this:
constexpr char h_msg[] = "show the help message and exit";
DEFINE_bool(h, false, h_msg);
  • Mark optional parameters with [ ]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


#include <gflags/gflags.h>
#include <utils/default_flags.hpp>
#include <models/detection_model.h>
Copy link

@ivikhrev ivikhrev Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transitive includes is a bad thing, please include models/detection_model.h in file where you actually use it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


#include <utils/slog.hpp>

namespace IE = InferenceEngine;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done




//#include "smart_framing_demo_gapi.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??? And demo works without this include. It is weird

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Need to remove.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done



namespace util {
//bool ParseAndCheckCommandLine(int argc, char *argv[]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Understood. New behavior is the same as in IFD.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MB need remove this code + include

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}


/** ---------------- Main graph of demo ---------------- **/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment without graph :)

cv::GArray<custom::DetectedObject> yolo_detections;

// Now build the graph
cv::GMat in;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put graph after 221 line if it is possible

DEFINE_INPUT_FLAGS
DEFINE_OUTPUT_FLAGS

static const char help_message[] = "Print a usage message.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unused file now, isn't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed after cleanup

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graph code rearranged. Don't completely understand "put graph after 221 line "

}
};

using GPostProc = cv::GOpaque<YOLOv4TinyPostProcessing>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

cv::BORDER_CONSTANT, cv::Scalar::all(127));
}
else {
image.copyTo(out);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use frame from cv::gapi::copy() instead?

@dbudniko
Copy link
Author

dbudniko commented Apr 6, 2022

Will we continue and merge?

@dbudniko
Copy link
Author

dbudniko commented Apr 7, 2022

@dmatveev FYI

using GDetections = cv::GArray<DetectedObject>;
using GLabels = cv::GArray<std::string>;

G_API_OP(GYOLOv4TinyPostProcessingKernel, < GDetections(cv::GMat, cv::GMat, cv::GMat, GLabels, float, float, bool) >, "custom.yolov4_tiny_post_processing") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operation shouldn't be called Kernel, as a Kernel is an implementation to the Operation.

Comment on lines +16 to +21
struct DetectedObject : public cv::Rect2f
{
unsigned int labelID;
std::string label;
float confidence;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt is subclassing from Rect2f is a good idea.. Not sure if it is bad, too.

The reason we usually don't use structures like this in pipeline and instead produce multiple arrays of different types is that it is easier to process those arrays with other functions like infer-list without any extra custom code.

}
};

G_API_OP(GSmartFramingKernel, <cv::GMat(cv::GMat, GDetections)>, "custom.smart_framing") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it should be SmartCrop isn't it?

cv::GMatDesc out_desc(CV_8U /* depth */, in.dims[1] /* channels */, cv::Size(in.dims[3], in.dims[2]), false /* planar */);
return out_desc;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop Kernel suffix from all the operations

// NB: Input is ND mat.
return cv::GMatDesc{ CV_8U, in.dims[1], cv::Size(in.dims[3], in.dims[2]) };
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have this in our base framework? Should we plan extending the existing function instead?

Comment on lines +37 to +48
static cv::gapi::GKernelPackage getKernelPackage(const std::string& type) {
if (type == "opencv") {
return cv::gapi::combine(cv::gapi::core::cpu::kernels(),
cv::gapi::imgproc::cpu::kernels());
} else if (type == "fluid") {
return cv::gapi::combine(cv::gapi::core::fluid::kernels(),
cv::gapi::imgproc::fluid::kernels());
} else {
throw std::logic_error("Unsupported kernel package type: " + type);
}
GAPI_Assert(false && "Unreachable code!");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably doesn't make sense as so far there is no image processing kernels in the pipeline?

Comment on lines +241 to +244
auto out_b = custom::GCvt32Fto8U::on(cv::gapi::infer<SRNet>(b));
auto out_g = custom::GCvt32Fto8U::on(cv::gapi::infer<SRNet>(g));
auto out_r = custom::GCvt32Fto8U::on(cv::gapi::infer<SRNet>(r));
out_sr_pp = cv::gapi::merge3(out_b, out_g, out_r);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so this in theory could leverage Fluid but in this face "Cvf32Fto8U" should be implemented as a Fluid kernel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..yes they can be custom


cv::merge(imgPlanes, out);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we unroll this kernel into a graph is possible? I see its treshold/convertTo/merge path can run on Fluid as well.

}
};

GAPI_OCV_KERNEL(OCVSmartFramingMakeBorderKernel, custom::GSmartFramingMakeBorderKernel) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is harder than I thought...

As it has a lot of temporary Mats created inside, those can be moved to State (as we turn this kernel into Stateful) to avoid run-time memory allocations.

Copy link
Collaborator

@Wovchena Wovchena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are debug prints. Please remove them

@@ -0,0 +1,110 @@
# G-API Smart Framing Demo

This demo shows how to perform smart framing using G-API.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a gif to show how demo looks.

--t_box_iou_yolo Optional. YOLO v4 Tiny box IOU threshold.
--advanced_pp Optional. Use advanced post-processing for the YOLO v4 Tiny.
--show Optional. (Don't) show output.
-u Optional. List of monitors to show initially.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misaligned with what the demo actually prints.

<< "\n\t[--loop] " << loop_msg
<< "\n\t[ -o <OUTPUT>] " << o_msg
<< "\n\t[--labels] " << labels_msg
<< "\n\t[--crop_with_borders] " << crop_with_borders_msg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort flags:

  1. -h
  2. --help
  3. required flags
  4. -i
  5. optional flags sorted alphabetically

cv::GArray<std::string> labels;

std::tie(blob26x26, blob13x13) = cv::gapi::infer<YOLOv4TinyNet>(in);
yolo_detections = custom::GYOLOv4TinyPostProcessingKernel::on(in, blob26x26, blob13x13, labels, FLAGS_t_conf_yolo, FLAGS_t_box_iou_yolo, FLAGS_advanced_pp);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's warning on windows warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data. Please put explicit cast

cv::Mat SF_resized_ROI;
cv::Size target_size;
target_size.height = image.size().height;
target_size.width = even_rect.width * (static_cast<float>(image.size().height) / static_cast<float>(even_rect.height));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's warning on Windows: '=': conversion from 'float' to '_Tp', possible loss of data. Please resolve it

auto* in_p = in.ptr<const float>();

std::transform(in_p, in_p + h * w, out_p,
[](float v) { return static_cast<uint8_t>(v * 255); });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not in.convertTo()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's even comment about it on top of this kernel

To run the demo, please provide paths to the model in the IR format, and to an input video, image, or folder with images:

```bash
./smart_framing_demo_gapi/ -m <path_to_model> -i <path_to_file>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
./smart_framing_demo_gapi/ -m <path_to_model> -i <path_to_file>
./smart_framing_demo_gapi -m <path_to_model> -i <path_to_file>

Comment on lines +63 to +64
constexpr char yolo_m_msg[] = "path to an .xml file with a trained YOLO v4 Tiny model.";
DEFINE_string(m_yolo, "", yolo_m_msg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr char yolo_m_msg[] = "path to an .xml file with a trained YOLO v4 Tiny model.";
DEFINE_string(m_yolo, "", yolo_m_msg);
constexpr char m_msg[] = "path to an .xml file with a trained YOLO v4 Tiny model.";
DEFINE_string(m, "", m_msg);

Could you make it just m: --m_yolo->-m because it's the primal model of the demo


GAPI_OCV_KERNEL(OCVSuperResolutionPostProcessingKernel, custom::GSuperResolutionPostProcessingKernel) {
static void run(const cv::Mat & image, cv::Mat & out) {
float* outputData = (float*)image.data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still C-style cast


} // anonymous namespace


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Two blank lines are usually prohibited for C++. It's not Python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants