BeanJoy 2020-07-04
随着发展趋势的变换,按照传统只是光会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