#include <algorithm>
#include <iostream>
#include <sstream>
const std::string keys =
"{ h help | | 打印此帮助消息 }"
"{ detector | | 编译后的 .blob 人脸检测器模型的路径 }"
"{ duration | 100 | 从相机拉取并运行推理的帧数 }";
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: 没有为示例提供检测模型的路径。"
<< "请使用 --detector 选项指定它。"
<< std::endl;
return 1;
}
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 << "在帧 #" << frames << " 上获得 " << out_dets.size() << " 个检测。" << std::endl;
}
++frames;
if (frames == duration) {
pipeline.stop();
break;
}
}
std::cout << "管道已完成。处理了 " << frames << " 帧" << std::endl;
return 0;
}
如果数组没有元素,则返回 true。
int64_t int64
cv::GArray<T> 模板类表示图中 T 类对象的列表。
定义 garray.hpp:366
GComputation 类表示捕获的计算图。 GComputation 对象形成边界 ...
定义 gcomputation.hpp:121
GAPI_WRAP GStreamingCompiled compileStreaming(GMetaArgs &&in_metas, GCompileArgs &&args={})
编译流模式的计算。
GFrame 类表示图中的图像或媒体帧。
定义 gframe.hpp:61
GMat 类表示图中的图像或张量数据。
定义 gmat.hpp:68
cv::GOpaque<T> 模板类表示图中 T 类的对象。
定义 gopaque.hpp:326
void setSource(GRunArgs &&ins)
指定 GStreamingCompiled 用于处理的输入数据,这是一个通用版本。
2D 矩形的模板类。
定义 types.hpp:444
#define GAPI_OCV_KERNEL(Name, API)
定义 gcpukernel.hpp:488
#define G_API_OP
定义 gkernel.hpp:369
GKernelPackage kernels()
创建包含可变模板中指定的内核和转换的内核包对象 ...
定义 gkernel.hpp:678
GCompileArgs compile_args(Ts &&... args)
将参数列表(参数包)包装到编译参数向量中(cv::GCompileArg)...
定义 gcommon.hpp:214
GFrame renderFrame(const GFrame &m_frame, const GArray< Prim > &prims)
渲染媒体帧。
CV_EXPORTS_W bool imwrite(const String &filename, InputArray img, const std::vector< int > ¶ms=std::vector< int >())
将图像保存到指定文件。
#define CV_RGB(r, g, b)
定义 imgproc.hpp:4577
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3
#define G_API_NET(Class, API, Tag)
定义 infer.hpp:452
cv::GKernelPackage kernels()
GFrame copy(const GFrame &in)
cv::gapi::GKernelPackage kernels()
GOpaque< Size > size(const GMat &src)
从 Mat 获取维度。
cv::GMat BGR(const cv::GFrame &in)
从输入帧获取 bgr 平面。
IStreamSource::Ptr make_src(Args &&... args)
定义 source.hpp:55
std::tuple< GArray< Rect >, GArray< int > > parseSSD(const GMat &in, const GOpaque< Size > &inSz, const float confidenceThreshold=0.5f, const int filterLabel=-1)
解析 SSD 网络的输出。
Net::Result infer(cv::GOpaque< cv::Rect > roi, T in)
计算指定网络(模板参数)在 so ... 中的指定区域的响应
定义 infer.hpp:474
cv::GKernelPackage combine(const cv::GKernelPackage &lhs, const cv::GKernelPackage &rhs)
cv::gapi::GNetPackage networks(Args &&... args)
定义 infer.hpp:703
GProtoInputArgs GIn(Ts &&... ts)
定义 gproto.hpp:96
GRunArgsP gout(Ts &... args)
定义 garg.hpp:280
GProtoOutputArgs GOut(Ts &&... ts)
定义 gproto.hpp:101
此结构体表示要绘制的矩形。
定义 render_types.hpp:128