2,599
edits
mNo edit summary |
Efernandez (talk | contribs) |
||
Line 130: | Line 130: | ||
<syntaxhighlight lang=cpp> | <syntaxhighlight lang=cpp> | ||
#include | #include <rd/redaction.hpp> | ||
#include <unistd.h> | #include <unistd.h> | ||
Line 158: | Line 142: | ||
#define INPUT_HEIGHT 720 | #define INPUT_HEIGHT 720 | ||
#define INPUT_BPP 2 | #define INPUT_BPP 2 | ||
static void save_buffer(std::shared_ptr<rd::io::IBuffer> buffer, | static void save_buffer(std::shared_ptr<rd::io::IBuffer> buffer, | ||
Line 202: | Line 184: | ||
/* Buffers */ | /* Buffers */ | ||
rd::Resolution input_resolution = rd::Resolution(INPUT_WIDTH, INPUT_HEIGHT); | rd::Resolution input_resolution = rd::Resolution(INPUT_WIDTH, INPUT_HEIGHT); | ||
rd::Format input_format = rd::Format::YUY2; | rd::Format input_format = rd::Format::YUY2; | ||
Line 212: | Line 191: | ||
std::shared_ptr<rd::io::IBuffer> output_final = | std::shared_ptr<rd::io::IBuffer> output_final = | ||
backend_cpu->getBuffer(input_resolution, input_format); | backend_cpu->getBuffer(input_resolution, input_format); | ||
std::shared_ptr<rd::io::IBuffer> output = | std::shared_ptr<rd::io::IBuffer> output = | ||
backend->getBuffer(input_resolution, input_format); | backend->getBuffer(input_resolution, input_format); | ||
Line 219: | Line 196: | ||
backend->getBuffer(input_resolution, input_format); | backend->getBuffer(input_resolution, input_format); | ||
/*Copy input buffer to GPU*/ | |||
input_gpu->copyFromHost(input); | input_gpu->copyFromHost(input); | ||
/* Detect Faces */ | /* Detect Faces */ | ||
std::vector<rd::Rectangle> faces; | std::vector<rd::Rectangle> faces; | ||
algorithm->detect(model, | algorithm->detect(model, input_gpu, &faces); | ||
/* Print out detected faces */ | /* Print out detected faces */ | ||
std::cout << faces.size() << std::endl; | std::cout << faces.size() << std::endl; | ||
Line 233: | Line 211: | ||
/* Redact detected faces */ | /* Redact detected faces */ | ||
algorithm->redact(input_gpu, output, faces, rd::RedactionAlgorithm::BLURRING); | algorithm->redact(input_gpu, output, faces, rd::RedactionAlgorithm::BLURRING); | ||
/* Download buffer to CPU memory */ | |||
/* Download buffer back to CPU memory */ | |||
output->copyToHost(output_final); | output->copyToHost(output_final); | ||
/* Save redacted image */ | /* Save redacted image */ | ||
save_buffer(output_final, "output_final"); | save_buffer(output_final, "output_final"); |