Help using the advanced OpenCV feature

In the following code, I want to use the dilate function, but I do not know how to distinguish the Mat class from InputArray and OutputArray . Can you help me?

Using this prototype function:

 void dilate(InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() ) 

Here is my code:

 #include "opencv2/opencv.hpp" using namespace cv; int main(int, char**) { Mat edges; VideoCapture cap(0); // open the default camera if(!cap.isOpened()) // check if we succeeded return -1; for(;;) { Mat frame; cap >> frame; // get a new frame from camera cvtColor(frame, edges, CV_BGR2GRAY); GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); //dilate(edges,edges,NULL); Canny(edges, edges, 0, 30, 3); imshow("edges", frame); if(waitKey(30) >= 0) break; } // the camera will be deinitialized automatically in VideoCapture destructor return 0; } 
+6
source share
2 answers

There are examples around Stack Overflow like this :

 int erosion_size = 6; cv::Mat element = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(2 * erosion_size + 1, 2 * erosion_size + 1), cv::Point(erosion_size, erosion_size) ); cv::dilate(edges, edges, element); 

Or is it :

 cv::dilate(edges, edges, cv::Mat(), cv::Point(-1,-1)); 
+19
source

in the following code I want to use an advanced function, but I can’t throw the Mat class into InputArray and OutputArray. Can you help me?

Well, you can use Mat as an Inputarray / Outputarray parameter without casting. See white papers .

And also here is an out-of-competition tutorial on opening OpenGL / delate. Or you can use samples from the karlphillip post .

+2
source

Source: https://habr.com/ru/post/918898/


All Articles