From: Alexander Alekhin Date: Sun, 20 Dec 2020 02:27:46 +0000 (+0000) Subject: docs(core): fix process_video_frame() code snippet X-Git-Tag: accepted/tizen/unified/20220125.121719~1^2~1^2~222^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3359bdc464a6c8f38f36498992bd1dbba3fc0aaa;p=platform%2Fupstream%2Fopencv.git docs(core): fix process_video_frame() code snippet --- diff --git a/modules/core/include/opencv2/core/mat.hpp b/modules/core/include/opencv2/core/mat.hpp index 0922db9..98f451c 100644 --- a/modules/core/include/opencv2/core/mat.hpp +++ b/modules/core/include/opencv2/core/mat.hpp @@ -702,11 +702,16 @@ sub-matrices. -# Process "foreign" data using OpenCV (for example, when you implement a DirectShow\* filter or a processing module for gstreamer, and so on). For example: @code - void process_video_frame(const unsigned char* pixels, - int width, int height, int step) + Mat process_video_frame(const unsigned char* pixels, + int width, int height, int step) { - Mat img(height, width, CV_8UC3, pixels, step); - GaussianBlur(img, img, Size(7,7), 1.5, 1.5); + // wrap input buffer + Mat img(height, width, CV_8UC3, (unsigned char*)pixels, step); + + Mat result; + GaussianBlur(img, result, Size(7, 7), 1.5, 1.5); + + return result; } @endcode -# Quickly initialize small matrices and/or get a super-fast element access.