1 | initial version |
there is a sample here, which shows changing the backend to "fluid", and to use the opencl backend, you'd do similar:
add a few headers:
//! [opencl_includes]
#include "opencv2/gapi/ocl/core.hpp" // ocl Core kernel library
#include "opencv2/gapi/ocl/imgproc.hpp" // ocl ImgProc kernel library
//! [opencl_includes]
#include "opencv2/gapi/ocl/goclkernel.hpp" // ocl user kernel API
change the backend and run the graph:
// Prepare the kernel package and run the graph
cv::gapi::GKernelPackage ocl_kernels = cv::gapi::combine // Define a custom kernel package:
(cv::gapi::core::ocl::kernels(), // ...with Fluid Core kernels
cv::gapi::imgproc::ocl::kernels(), // ...and Fluid ImgProc kernels
cv::unite_policy::KEEP);
//! [kernel_pkg]
//! [kernel_hotfix]
// probably not nessecary for ocl !
//ocl_kernels.remove<cv::gapi::imgproc::GBoxFilter>(); // Remove Fluid Box filter as unsuitable,
// G-API will fall-back to OpenCV there.
//! [kernel_hotfix]
//! [kernel_pkg_use]
segm.apply(cv::gin(imgIn), // Input data vector
cv::gout(imgOut, imgOutCoherency, imgOutOrientation), // Output data vector
cv::compile_args(ocl_kernels)); // Kernel package to use
2 | No.2 Revision |
there is a sample here, which shows changing the backend to "fluid", and to use the opencl backend, you'd do similar:
add a few headers:
//! [opencl_includes]
#include "opencv2/gapi/ocl/core.hpp" // ocl Core kernel library
#include "opencv2/gapi/ocl/imgproc.hpp" // ocl ImgProc kernel library
//! [opencl_includes]
#include "opencv2/gapi/ocl/goclkernel.hpp" // ocl user kernel API
change the backend and run the graph:
// Prepare the kernel package and run the graph
cv::gapi::GKernelPackage ocl_kernels = cv::gapi::combine // Define a custom kernel package:
(cv::gapi::core::ocl::kernels(), // ...with Fluid ocl Core kernels
cv::gapi::imgproc::ocl::kernels(), // ...and Fluid ocl ImgProc kernels
cv::unite_policy::KEEP);
//! [kernel_pkg]
//! [kernel_hotfix]
// probably not nessecary for ocl !
//ocl_kernels.remove<cv::gapi::imgproc::GBoxFilter>(); // Remove Fluid ocl Box filter as unsuitable,
// G-API will fall-back to OpenCV there.
//! [kernel_hotfix]
//! [kernel_pkg_use]
segm.apply(cv::gin(imgIn), // Input data vector
cv::gout(imgOut, imgOutCoherency, imgOutOrientation), // Output data vector
cv::compile_args(ocl_kernels)); // Kernel package to use