给窗帘做网站百度竞价推广开户价格

当前位置: 首页 > news >正文

给窗帘做网站,百度竞价推广开户价格,购买网域名的网站好,wordpress改商城// 加载必要的头文件 #include iostream // 用于标准输入输出流 #include fstream // 用于文件的输入输出 #include sstream // 用于字符串的输入输出流操作#include opencv2/core.hpp // OpenCV核心功能的头文件 #include o… // 加载必要的头文件 #include iostream // 用于标准输入输出流 #include fstream // 用于文件的输入输出 #include sstream // 用于字符串的输入输出流操作#include opencv2/core.hpp // OpenCV核心功能的头文件 #include opencv2/imgcodecs.hpp // OpenCV图像编解码功能的头文件 #include opencv2/highgui.hpp // OpenCV的高级GUI图形用户界面// 使用标准命名空间和OpenCV命名空间避免重复声明 using namespace cv; using namespace std;/// // 函数声明部分// read_imgList函数用于从文本文件中读取图像路径并加载这些图像 static void read_imgList(const string filename, vectorMat images) {std::ifstream file(filename.c_str(), ifstream::in); // 打开文件if (!file) {string error_message No valid input file was given, please check the given filename.; // 错误消息CV_Error(Error::StsBadArg, error_message); // 如果文件打开失败给出错误信息并退出程序}string line; // 存储读取的每行文字while (getline(file, line)) {images.push_back(imread(line, IMREAD_GRAYSCALE)); // 将每行读取到的图像路径用于加载图像并转换为灰度图像} }// formatImagesForPCA函数用于将图像数据格式化为一个适合PCA处理的矩阵 static Mat formatImagesForPCA(const vectorMat data) {// 创建一个用于PCA处理的矩阵将所有图像行向量垂直堆叠Mat dst(static_castint(data.size()), data[0].rowsdata[0].cols, CV_32F);for(unsigned int i 0; i data.size(); i) // 遍历所有图像{Mat image_row data[i].clone().reshape(1,1); // 将每张图像转换为行向量Mat row_i dst.row(i); // 获取目标矩阵的当前行image_row.convertTo(row_i,CV_32F); // 将图像数据转换为浮点型并填入目标矩阵的相应行}return dst; // 返回格式化后的矩阵 }// toGrayscale函数用于将输入图像转换为灰度图像并进行归一化处理 static Mat toGrayscale(InputArray _src) {Mat src _src.getMat(); // 获取输入数据的Mat对象// 检查是否是单通道图像if(src.channels() ! 1) {CV_Error(Error::StsBadArg, Only Matrices with one channel are supported); // 如果不是抛出异常}// 创建一个目标Mat对象并对输入图像进行归一化处理Mat dst;cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);return dst; // 返回处理后的图像 }// 定义一个结构体用于传递给滑动条回调函数的参数 struct params {Mat data; // 存放数据的Mat矩阵int ch; // 图像的通道数int rows; // 图像行数PCA pca; // PCA对象string winName; // 窗口名称 };// onTrackbar滑动条回调函数用于根据Retained Variance(保留方差)的变化更新PCA结果并显示 static void onTrackbar(int pos, void ptr) {cout Retained Variance pos % ;cout re-calculating PCA… std::flush; // 提示正在重新计算PCAdouble var pos / 100.0; // 将滑动条的整型位置值转换为[0,1]之间的百分比表示的保留方差struct params *p (struct params )ptr; // 从回调函数的指针参数中提取出params结构体// 使用新的保留方差重新计算PCAp-pca PCA(p-data, cv::Mat(), PCA::DATA_AS_ROW, var); // 将原始数据的第一行第一幅图像投影到PCA空间并获取其点representationMat point p-pca.project(p-data.row(0));// 然后利用该点representation重构图像Mat reconstruction p-pca.backProject(point);reconstruction reconstruction.reshape(p-ch, p-rows); // 重构的图像需要重新改变其形状reconstruction toGrayscale(reconstruction); // 转换为灰度图便于显示// 在窗口中显示重构的图像imshow(p-winName, reconstruction);// 打印PCA使用的主成分数量cout done! # of principal components: p-pca.eigenvectors.rows endl; }/// // 主程序 int main(int argc, char** argv) {// 解析命令行参数cv::CommandLineParser parser(argc, argv, {input||image list}{help h||show help message});// 如果存在help参数则打印帮助消息if (parser.has(help)){parser.printMessage();exit(0);}// 获取CSV文件的路径string imgList parser.getstring(input);// 如果未传入图片列表则打印消息并退出程序if (imgList.empty()){parser.printMessage();exit(1);}// 创建一个向量来存储图像vectorMat images;// 读取数据如果失败则会抛出异常try {read_imgList(imgList, images);} catch (const cv::Exception e) {cerr Error opening file \ imgList . Reason: e.msg endl;exit(1);}// 如果图片不足以进行此演示则退出程序if(images.size() 1) {string error_message This demo needs at least 2 images to work. Please add more images to your data set!;CV_Error(Error::StsError, error_message);}// 将图像重排并堆叠成一个行矩阵Mat data formatImagesForPCA(images);// 执行PCA// 这里trackbar初始设置为95%这也是一个常见的保留方差值PCA pca(data, cv::Mat(), PCA::DATA_AS_ROW, 0.95); // 展示保留方差对第一张图片效果的演示Mat point pca.project(data.row(0)); // 将图像投影到特征空间图像变成了一个“点”Mat reconstruction pca.backProject(point); // 从“点”中重建图像reconstruction reconstruction.reshape(images[0].channels(), images[0].rows); // 重新将行向量变形为图像形状reconstruction toGrayscale(reconstruction); // 重新缩放以便于显示// 初始化高层GUI窗口string winName Reconstruction | press q to quit;namedWindow(winName, WINDOW_NORMAL);// 创建一个结构体以传递给trackbar处理函数params p;p.data data;p.ch images[0].channels();p.rows images[0].rows;p.pca pca;p.winName winName;// 创建trackbarint pos 95;createTrackbar(Retained Variance (%), winName, pos, 100, onTrackbar, (void)p);// 显示直到用户按下q键imshow(winName, reconstruction);char key 0;while(key ! q)key (char)waitKey();return 0; } 代码的主要功能是通过用户输入一个包含图像全路径的文本文件该文件的每一行都代表一张图片的路径。程序将会使用主成分分析(PCA)技术对这些图像进行处理并通过OpenCV库完成。这一处理过程可以通过一个trackbar滑动条来动态调整保留方差的百分比从而展现不同保留方差下图像重建的效果。程序界面会持续显示直到用户按下q键退出。这个代码示例建议使用ATT人脸数据库的前15个人脸图片来演示。 // Reshape and stack images into a rowMatrixMat data formatImagesForPCA(images);// perform PCAPCA pca(data, cv::Mat(), PCA::DATA_AS_ROW, 0.95); // trackbar is initially set here, also this is a common value for retainedVariance// Demonstration of the effect of retainedVariance on the first imageMat point pca.project(data.row(0)); // project into the eigenspace, thus the image becomes a pointMat reconstruction pca.backProject(point); // re-create the image from the pointreconstruction reconstruction.reshape(images[0].channels(), images[0].rows); // reshape from a row vector into image shapereconstruction toGrayscale(reconstruction); // re-scale for displaying purposes imageslist.txt https://www.kaggle.com/datasets/kasikrit/att-database-of-faces?resourcedownload  数据下载地址