NX二次开发-基于OpenCV图像处理的开发(将彩色图片变为灰色)
随着发展趋势的变换,按照传统只是光会NX界面小工具开发,已经满足不了各种复杂的需求了。
需要各种其他领域的开发与NX开发进行对接。利用openCV进行图像处理,计算机视觉开发。
例如:图纸识别......
NX9+VS2012+Opencv2.4.9
1.添加环境变量
将路径D:\opencv\build\x64\vc11\bin复制到path环境变量里面
2.新建一个C++控制台项目
3.配置环境
Debug版
opencv_core249d.lib opencv_imgproc249d.lib opencv_highgui249d.lib opencv_ml249d.lib opencv_video249d.lib opencv_features2d249d.lib opencv_calib3d249d.lib opencv_objdetect249d.lib opencv_contrib249d.lib opencv_legacy249d.lib opencv_flann249d.lib
Release版
opencv_core249.lib opencv_imgproc249.lib opencv_highgui249.lib opencv_ml249.lib opencv_video249.lib opencv_features2d249.lib opencv_calib3d249.lib opencv_objdetect249.lib opencv_contrib249.lib opencv_legacy249.lib opencv_flann249.lib
4.添加代码
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; int main(int argc, char** argv) { Mat src = imread("D:/123/1.png"); if (src.empty()) { printf("could not load image...\n"); return -1; } //显示一张彩色图片 namedWindow("test opencv setup", CV_WINDOW_AUTOSIZE); imshow("test opencv setup", src); //将彩色图片转换成灰色,显示出来 namedWindow("output windows", CV_WINDOW_AUTOSIZE); Mat output_image; cvtColor(src, output_image, CV_BGR2GRAY); imshow("output windows", output_image); //保存图片 imwrite("D:/123/2.png", output_image); waitKey(0); return 0; } Caesar卢尚宇 2020年7月4日
5.新建一个NX dll项目,在项目中调用图像处理的exe
system("D:\\123.exe");
参考资料 https://blog.csdn.net/shiyimin1/article/details/26163993?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2
相关推荐
learningCV 2020-08-25
pythonxuexi 2020-06-16
kkpiece 2020-06-14
wangdaren 2020-06-14
pythonxuexi 2020-06-13
liangzuojiayi 2020-06-09
BeanJoy 2020-06-06
zyazky 2020-05-29
xixixi 2020-05-12
pythonxuexi 2020-05-10
JAVA入门中 2020-05-09
wanff0 2020-05-04
BeanJoy 2020-05-03
xirongxudlut 2020-04-26
晓杰0 2020-02-23
wangdaren 2020-02-19
yogoma 2020-01-28
ezhchai 2020-01-23
faiculty 2020-01-17