<> Function one
#include <opencv2/opencv.hpp> cv::Mat func(cv::Mat input) { input.setTo(0);
//input = cv::Mat::ones(4, 4, CV_32F); return input; } int main(int argc, char
const *argv[]) { cv::Mat imga = cv::imread("/home/ly/Pictures/11111111.jpg");
cv::Mat imgb = imga; cv::Mat imgc = imga.clone(); cv::Mat imgd = func(imga);
return 0; }
* imga ,imgb,imgd Shared matrix header , When one changes, the other two change .
* imgc Deep copy , complete independence ,
<> Function two
#include <opencv2/opencv.hpp> cv::Mat func(cv::Mat input) { input =
cv::Mat::ones(4, 4, CV_32F); return input; } int main(int argc, char const
*argv[]) { cv::Mat imga = cv::imread("/home/ly/Pictures/11111111.jpg"); cv::Mat
imgb = imga; cv::Mat imgc = imga.clone(); cv::Mat imgd = func(imga); return 0; }
* imga,imgb Shared office pillow , The two interact , Because in func Constructor called in , therefore input Memory space will be restored , that imgd Also independent
* imgc Deep copy , complete independence
Technology
Daily Recommendation