#include <algorithm>
#include <iostream>
#include <sstream>
const std::string keys =
"{ h help | | Print this help message }"
"{ detector | | Path to compiled .blob face detector model }"
"{ duration | 100 | Number of frames to pull from camera and run inference on }";
namespace custom {
G_API_OP(BBoxes, <GPrims(GDetections)>,
"sample.custom.b-boxes") {
}
};
static void run(const std::vector<cv::Rect> &in_face_rcs,
std::vector<cv::gapi::wip::draw::Prim> &out_prims) {
out_prims.clear();
};
for (auto &&rc : in_face_rcs) {
out_prims.emplace_back(cvt(rc,
CV_RGB(0,255,0)));
}
}
};
}
int main(
int argc,
char *argv[]) {
if (cmd.has("help")) {
cmd.printMessage();
return 0;
}
const auto det_name = cmd.get<std::string>("detector");
const auto duration = cmd.get<int>("duration");
if (det_name.empty()) {
std::cerr << "FATAL: path to detection model is not provided for the sample."
<< "Please specify it with --detector options."
<< std::endl;
return 1;
}
cv::gapi::kernels<custom::OCVBBoxes>(),
cv::GMat blob = cv::gapi::infer<custom::FaceDetector>(copy);
pipeline.
setSource(cv::gapi::wip::make_src<cv::gapi::oak::ColorCamera>());
pipeline.start();
std::vector<cv::Rect> out_dets;
int frames = 0;
while (pipeline.pull(
cv::gout(out_mat, out_dets))) {
std::string name = "oak_infer_frame_" + std::to_string(frames) + ".png";
if (!out_dets.empty()) {
std::cout << "Got " << out_dets.size() << " detections on frame #" << frames << std::endl;
}
++frames;
if (frames == duration) {
pipeline.stop();
break;
}
}
std::cout << "Pipeline finished. Processed " << frames << " frames" << std::endl;
return 0;
}
Designed for command line parsing.
Definition utility.hpp:890
cv::GArray<T> template class represents a list of objects of class T in the graph.
Definition garray.hpp:366
GComputation class represents a captured computation graph. GComputation objects form boundaries for ...
Definition gcomputation.hpp:121
GAPI_WRAP GStreamingCompiled compileStreaming(GMetaArgs &&in_metas, GCompileArgs &&args={})
Compile the computation for streaming mode.
GFrame class represents an image or media frame in the graph.
Definition gframe.hpp:61
GMat class represents image or tensor data in the graph.
Definition gmat.hpp:68
cv::GOpaque<T> template class represents an object of class T in the graph.
Definition gopaque.hpp:326
void setSource(GRunArgs &&ins)
Specify the input data to GStreamingCompiled for processing, a generic version.
n-dimensional dense array class
Definition mat.hpp:828
Template class for 2D rectangles.
Definition types.hpp:444
#define GAPI_OCV_KERNEL(Name, API)
Definition gcpukernel.hpp:488
#define G_API_OP
Definition gkernel.hpp:369
GCompileArgs compile_args(Ts &&... args)
Wraps a list of arguments (a parameter pack) into a vector of compilation arguments (cv::GCompileArg)...
Definition gcommon.hpp:214
GFrame renderFrame(const GFrame &m_frame, const GArray< Prim > &prims)
Renders Media Frame.
CV_EXPORTS_W bool imwrite(const String &filename, InputArray img, const std::vector< int > ¶ms=std::vector< int >())
Saves an image to a specified file.
#define CV_RGB(r, g, b)
Definition imgproc.hpp:4524
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
#define G_API_NET(Class, API, Tag)
Definition infer.hpp:452
cv::GKernelPackage kernels()
GFrame copy(const GFrame &in)
cv::gapi::GKernelPackage kernels()
GOpaque< Size > size(const GMat &src)
Gets dimensions from Mat.
cv::GMat BGR(const cv::GFrame &in)
Gets bgr plane from input frame.
std::tuple< GArray< Rect >, GArray< int > > parseSSD(const GMat &in, const GOpaque< Size > &inSz, const float confidenceThreshold=0.5f, const int filterLabel=-1)
Parses output of SSD network.
cv::GKernelPackage combine(const cv::GKernelPackage &lhs, const cv::GKernelPackage &rhs)
cv::gapi::GNetPackage networks(Args &&... args)
Definition infer.hpp:703
GProtoInputArgs GIn(Ts &&... ts)
Definition gproto.hpp:96
GRunArgsP gout(Ts &... args)
Definition garg.hpp:280
GProtoOutputArgs GOut(Ts &&... ts)
Definition gproto.hpp:101
This structure represents a rectangle to draw.
Definition render_types.hpp:128