mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-19 11:21:39 +08:00

Migrate G-API module from main repo to opencv_contrib #3827 Related to https://github.com/opencv/opencv/pull/26469 Required https://github.com/opencv/opencv/pull/26527 CI: https://github.com/opencv/ci-gha-workflow/pull/201 TODO: - [x] Python types generator fix - [x] CI update ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
29 lines
686 B
C++
29 lines
686 B
C++
#include <opencv2/videoio.hpp>
|
|
#include <opencv2/highgui.hpp>
|
|
#include <opencv2/gapi.hpp>
|
|
#include <opencv2/gapi/core.hpp>
|
|
#include <opencv2/gapi/imgproc.hpp>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
(void) argc;
|
|
(void) argv;
|
|
|
|
using namespace cv;
|
|
Mat in_mat = imread("lena.png");
|
|
Mat out_mat;
|
|
|
|
GMat in;
|
|
GMat gx = gapi::Sobel(in, CV_32F, 1, 0);
|
|
GMat gy = gapi::Sobel(in, CV_32F, 0, 1);
|
|
GMat mag = gapi::sqrt( gapi::mul(gx, gx)
|
|
+ gapi::mul(gy, gy));
|
|
GMat out = gapi::convertTo(mag, CV_8U);
|
|
|
|
GComputation sobel(GIn(in), GOut(out));
|
|
sobel.apply(in_mat, out_mat);
|
|
|
|
imwrite("lena-out.png", out_mat);
|
|
return 0;
|
|
}
|