gpt4 book ai didi

c++ - 寻找 HSV 转换视频提要的均值

转载 作者:行者123 更新时间:2023-11-28 02:06:43 26 4
gpt4 key购买 nike

<分区>

这是我的代码的预期行为:

“我应该从我的主程序中获取 RGB2HSV 转换后的视频和原始视频,并设计一个函数来计算所有 H、S 和 V 值的平均值,并为每一帧生成 1*3 矩阵。”

这其实就是用PCA对物体着火和不着火进行分类。我在 MATLAB 中完成了特征提取,并在 visual studio 中用 C++ 代码贴标了 PCA 系数。显然代码没有错误,但是当我调试运行它时,它给出了可以在附加照片中看到的错误。

此外,其余代码已正确执行,没有错误。哪里有问题。附上我的代码

void pca_decide(Mat &Threshdimg , Mat &Original)
{
//declare master pca matrix

double pca_data[9] = { -0.5398, -0.4189, 0.7302, -0.0365, 0.8782, 0.4768, 0.8410, -0.2307, 0.4893 };
Mat pca = Mat(3, 3, CV_32F, pca_data);

//declaring mean fire hsv values multiplied with pca in matlab
double fire_pca_data[3] = { 0.7375, -0.0747,0.6608 };
Mat fire_pca = Mat(1, 3, CV_32F, fire_pca_data);

//declaring mean non-fire hsv values multiplied with pca in matlab
double nfire_pca_data[3] = { 0.4389,-0.0874, 0.6240 };
Mat nfire_pca = Mat(1, 3, CV_32F, nfire_pca_data);

//generating current image hsv values in euclidean space

Mat image_pca;
double rows = Threshdimg.rows;
double cols = Threshdimg.cols;

vector<Mat> hsv_planes;
split(Threshdimg, hsv_planes);
Mat h = hsv_planes[0]; // H channel h is a 2D matrix
Mat s = hsv_planes[1]; // S channel
Mat v = hsv_planes[2]; // V channel

Scalar h_mean_image = sum(h)/ (rows*cols); // here I need to sum all the rows and columns
Scalar s_mean_image = sum(s)(rows*cols);
Scalar v_mean_image = sum(v)(rows*cols);
Scalar HSV_mean_data[3] = { h_mean_image, s_mean_image, v_mean_image };
Mat HSV_mean = Mat(1, 3, CV_32F, HSV_mean_data);
multiply(pca, HSV_mean, image_pca);

//finding difference with fire_pca
float diff_fire;
diff_fire = norm(image_pca, fire_pca, NORM_L2);


//finding differene with non_fire_pca
float diff_non_fire;
diff_non_fire = norm(image_pca, nfire_pca, NORM_L2);

if (diff_fire > diff_non_fire)
putText(Original, "Fire Detected", Point(0, 50), 2, 1, Scalar(255, 0, 0), 2);
else
putText(Original, "Fire Not Detected", Point(0, 50), 2, 1, Scalar(0, 255, 0), 2);
}

the error that i get when I debug

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com