#include <yolo_object_detection.h>
#include <iostream>
using namespace std;
using namespace cv;
float sigmoid(float x)
{
return (1 / (1 + exp(-x)));
}
int main(int argc, char** argv) {
//int a = 100;
//int b = 9;
//std::cout << (a + b) / 2 << std::endl;
//std::list<double> values(262114, 3.14159265);
//vector<float> a(262114, 1.0);
vector<float> a;
// 显示 vec 的原始大小
cout << "vector size = " << a.size() << endl;
// 推入 5 个值到向量中
for (int i = 0; i < 786432; i++) {
a.push_back((255.0/ 786432)*i);
}
Mat t1 = Mat(512, 512, CV_8UC1);
t1.data;
int width = t1.cols;
int height = t1.rows;
cout << width << " " << height << endl;
float zz = a[10];
std::cout << a[10] << endl;
int index_num;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
index_num = row * 512 + col;
t1.at<uchar>(row, col) = (int) (sigmoid(a[index_num])*255);
//cout << (int)a[index_num] << endl;
}
}
Mat ImgGrayC1;
t1.convertTo(ImgGrayC1, CV_8UC1);
int pp1 = t1.at<uchar>(500, 500);
int pp = ImgGrayC1.at<uchar>(500, 500);
cout <<"data"<< (int)a[256512] << " " << pp << " " << pp1 << endl;
Mat mask;
cv::threshold(t1, mask, 127.0, 255.0,1);
imshow("usm filter", mask);
waitKey(0);
destroyAllWindows();
imwrite("D://2.jpg", t1);
imwrite("D://1.jpg", ImgGrayC1);
double min_val = 1000, max_val = -1000;
for (int num_output = 0; num_output < 512 * 512 * 3; num_output++) {
if (min_val > a[num_output]) {
min_val = a[num_output];
}
}
for (int num_output = 0; num_output < 512 * 512 * 3; num_output++) {
a[num_output] = num_output - min_val;
}
for (int num_output = 0; num_output < 512 * 512 * 3; num_output++) {
if (max_val < a[num_output]) {
max_val = a[num_output];
}
}
for (int num_output = 0; num_output < 512 * 512 * 3; num_output++) {
a[num_output] = num_output/ max_val;
}
Mat image_bgr = Mat(512, 512, CV_8UC3);
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
index_num = row * 512 + col;
image_bgr.at<cv::Vec3b>(col, row)[0] = (int)((a[index_num]) * 255);
image_bgr.at<cv::Vec3b>(col, row)[1] = (int)((a[index_num + 512 * 512]) * 255);
image_bgr.at<cv::Vec3b>(col, row)[2] = (int)((a[index_num + 512 * 512 * 2]) * 255);
//cout << (int)a[index_num] << endl;
}
}
imwrite("D://3.jpg", image_bgr);
/*
double minv, maxv;
Point pt_min, pt_max;
minMaxLoc(image_bgr, &minv, &maxv, &pt_min, &pt_max);
cout << "minv = " << minv << endl;
cout << "idx_min = " << pt_min << endl;
cout << "maxv = " << maxv << endl;
cout << "idx_max = " << pt_max << endl;
image_bgr = image_bgr - minv;
minMaxLoc(image_bgr, &minv, &maxv, &pt_min, &pt_max);
cout << "minv = " << minv << endl;
cout << "idx_min = " << pt_min << endl;
cout << "maxv = " << maxv << endl;
cout << "idx_max = " << pt_max << endl;
image_bgr = image_bgr / maxv;
image_bgr = image_bgr * 255;
*/
/*
Mat image_bgr = Mat(512, 512, CV_8UC3);
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
index_num = row * 512 + col;
t1.at<cv::Vec3b>(col, row)[0] = (int)(sigmoid(a[index_num]) * 255);
t1.at<cv::Vec3b>(col, row)[1] = (int)(sigmoid(a[index_num]) * 255);
t1.at<cv::Vec3b>(col, row)[2] = (int)(sigmoid(a[index_num]) * 255);
//cout << (int)a[index_num] << endl;
}
}
*/
/*
std::string xml = "D:/openvino/code/person.xml";
std::string bin = "D:/openvino/code/person.bin";
std::string onnx_yolov5s = "D:/openvino/code/yolov5s.onnx";
std::string image_file = "D:/openvino/1.jpg";
std::string video_file = "rtsp://admin:By198801@192.168.104.21:554/h264/ch1/sub/av_stream";
//std::string video_file = "D:/openvino/climb_cideo001.mp4";
YOLOObjectDetection yolo_detector;
yolo_detector.detect(xml, bin, video_file, 1);
*/
return 0;
}
临时代码1111
最新推荐文章于 2025-05-09 11:29:32 发布