cv::Mat 测试
测试平台:
- ubuntu20.04
- gcc 9.3.0
- opencv 4.2.0
- c++ 14
Mat 现在和智能指针差不多了。进行下面测试
测试一
#include <iostream>
#include <string>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
int main()
{
cv::Mat data_out;
cv::Mat data_copy;
{
uchar data[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
// cv::Mat mat_data = cv::imread(image_path + image_files[0], cv::IMREAD_GRAYSCALE);
cv::Mat mat_data(3, 3, CV_8UC1, data); // 外部数据
data_out = mat_data;
mat_data.copyTo(data_copy);
std::cout << "作用域内:" << (int)mat_data.at<uchar>(1, 1) << std::endl;
// std::cout << "引用计数:" << mat_data.u->refcount <&