File size: 1,751 Bytes
be94e5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Copyright (C) 2021 Intel Corporation
#include <opencv2/gapi/oak/oak.hpp>
#include <opencv2/gapi/cpu/gcpukernel.hpp>
#include "oak_memory_adapters.hpp"
#include <thread>
#include <chrono>
namespace cv {
namespace gapi {
namespace oak {
GArray<uint8_t> encode(const GFrame& in, const EncoderConfig& cfg) {
return GEncFrame::on(in, cfg);
}
GFrame sobelXY(const GFrame& in, const cv::Mat& hk, const cv::Mat& vk) {
return GSobelXY::on(in, hk, vk);
}
GFrame copy(const GFrame& in) {
return GCopy::on(in);
}
// This is a dummy oak::ColorCamera class that just makes our pipelining
// machinery work. The real data comes from the physical camera which
// is handled by DepthAI library.
ColorCamera::ColorCamera()
: m_dummy(cv::MediaFrame::Create<cv::gapi::oak::OAKMediaAdapter>()) {
}
ColorCamera::ColorCamera(const ColorCameraParams& params)
: m_dummy(cv::MediaFrame::Create<cv::gapi::oak::OAKMediaAdapter>()),
m_params(params) {
}
bool ColorCamera::pull(cv::gapi::wip::Data &data) {
// FIXME: Avoid passing this formal frame to the pipeline
std::this_thread::sleep_for(std::chrono::milliseconds(10));
data = m_dummy;
return true;
}
cv::GMetaArg ColorCamera::descr_of() const {
// FIXME: support other resolutions
GAPI_Assert(m_params.resolution == ColorCameraParams::Resolution::THE_1080_P);
return cv::GMetaArg{cv::GFrameDesc{cv::MediaFormat::NV12, cv::Size{1920, 1080}}};
}
} // namespace oak
} // namespace gapi
} // namespace cv
|