opencv/opencv_test.cpp
lls b8f5bb14fb opencv学习内容
Signed-off-by: lls <staying_liu_1@163.com>
2025-03-07 11:39:01 +08:00

43 lines
703 B
C++

#include"opencv_test.h"
opencv_t::opencv_t()
{
}
opencv_t::~opencv_t()
{
}
opencv_t* opencv_t::create_new()
{
opencv_t* temp = nullptr;
temp = new opencv_t();
return temp;
}
void opencv_t::visit_xiangsu(Mat& temp)
{
int w = temp.cols;
int h = temp.rows;
int dims = temp.channels();
for (int row = 0; row < h; row++)
{
for (int col = 0; col < w; col++)
{
if (dims == 1)
{
int pv = temp.at<uchar>(row, col);
temp.at<uchar>(row, col) = 255 - pv;
}
else if (dims == 3)
{
Vec3b pv = temp.at<Vec3b>(row, col);
temp.at<Vec3b>(row, col)[0] = 255 - pv[0];
temp.at<Vec3b>(row, col)[1] = 255 - pv[1];
temp.at<Vec3b>(row, col)[2] = 255 - pv[2];
}
}
}
}