博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7、C++版本图像畸变校正
阅读量:2090 次
发布时间:2019-04-29

本文共 1836 字,大约阅读时间需要 6 分钟。

当使用python验证了原理,同时获取了校正的角点参数,则可以直接使用C++代码对图像处理,

 

int process_image(unsigned char *imgBuffer, int width, int height, int channels, char* file_name){	int type = 0;	if (channels == 3) {		type = CV_8UC3;	}	else  if (channels == 1) {		type = CV_8UC1;	}	Mat image_src = Mat(height, width, type);	memcpy(image_src.data, imgBuffer, width* height*channels);		//vector
src_corner; //src_corner.push_back(Point2f(0, 190)); //Point2f src_corner[4] = { Point2f(0, 190), Point2f(800, 200), Point2f(590, 460), Point2f(205, 460) }; if (src_corner[2].y < 100) { if (read_config() != 0) { return -2; } } // TL BL BR BL Point2f dst_corner[4] = { Point2f(0, 0), Point2f(static_cast
(m_camera_width), 0), Point2f(static_cast
(m_camera_width), static_cast
(m_camera_height)), Point2f(0, static_cast
(m_camera_height)) }; Mat result_image; Mat warp_mat = getPerspectiveTransform(src_corner, dst_corner); warpPerspective(image_src, result_image, warp_mat, Size(m_camera_width, m_camera_height)); //string save_file_name = get_date_time_string()+".bmp"; //strcpy_s(file_name, sizeof(save_file_name), save_file_name.c_str()); string save_file_name = file_name; //Mat normalize_image; //normalize(result_image, normalize_image, 255, 0, NORM_MINMAX); //Mat equal_image; //Mat blur_image; //Mat Median_image; //Mat bilate_image; //vector
splitRGB(result_image.channels()); //cv::split(normalize_image, splitRGB); //for (auto i = 0; i < result_image.channels(); i++) { // equalizeHist(splitRGB[i], splitRGB[i]); //} //Mat mergeImage; //merge(splitRGB, mergeImage); //mergeImage.copyTo(equal_image); //equal_image.convertTo(blur_image, -1, 1.5, 150); //Mat dstImage; //normalize_image.convertTo(dstImage, -1, 1.15,50); //draw_for_test(result_image); imwrite(save_file_name, result_image); return 0;}

 

转载地址:http://dtqqf.baihongyu.com/

你可能感兴趣的文章
Fiddler 抓包工具总结
查看>>
【雅思】雅思需要购买和准备的学习资料
查看>>
【雅思】雅思写作作业(1)
查看>>
【雅思】【大作文】【审题作业】关于同不同意的审题作业(重点)
查看>>
【Loadrunner】通过loadrunner录制时候有事件但是白页无法出来登录页怎么办?
查看>>
【English】【托业】【四六级】写译高频词汇
查看>>
【托业】【新东方全真模拟】01~02-----P5~6
查看>>
【托业】【新东方全真模拟】03~04-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST05~06-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST09~10-----P5~6
查看>>
【托业】【新东方托业全真模拟】TEST07~08-----P5~6
查看>>
solver及其配置
查看>>
JAVA多线程之volatile 与 synchronized 的比较
查看>>
Java集合框架知识梳理
查看>>
笔试题(一)—— java基础
查看>>
Redis学习笔记(三)—— 使用redis客户端连接windows和linux下的redis并解决无法连接redis的问题
查看>>
Intellij IDEA使用(一)—— 安装Intellij IDEA(ideaIU-2017.2.3)并完成Intellij IDEA的简单配置
查看>>
Intellij IDEA使用(二)—— 在Intellij IDEA中配置JDK(SDK)
查看>>
Intellij IDEA使用(三)——在Intellij IDEA中配置Tomcat服务器
查看>>
Intellij IDEA使用(四)—— 使用Intellij IDEA创建静态的web(HTML)项目
查看>>