机器视觉图像处理软件包
美国 Opencv------------------由美国Intel公司建立,如今由Willow Garage提供支持
加拿大 MIL---------------------加拿大的Matrox Imaging Library(缩写为MIL)
MIL2OpenCV
#include "stdafx.h"
#include <Mil.h>
#include<iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
#define byte unsigned char
// Opencv Mat--->MilImage buf
int _tmain(int argc, _TCHAR* argv[])
{
MIL_ID MilApplication,
MilSystem,
MilDisplay,
MilImage;
MappAllocDefault(M_DEFAULT, &MilApplication, &MilSystem, &MilDisplay, M_NULL, M_NULL);
Mat src_gray;
Mat src = imread("D://s2.bmp");
if(!src.data)
{
return -1;
}
int n = src.channels();// 获取图像通道数
if(n>1)
{
cvtColor(src, src_gray, CV_RGB2GRAY);//转化为灰度图
}
MbufAlloc2d(MilSystem,src_gray.cols,src_gray.rows,8+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP,& MilImage);//给MIL图像分配空间
MbufPut(MilImage,src_gray.data);//从Opencv的Mat中拷贝数据
MdispSelect(MilDisplay, MilImage); //显示MIL图像
imshow("Opencv图像",src_gray);//显示Opencv图像
waitKey(6000); //等待6000ms后窗口自动关闭
MappFreeDefault(MilApplication,MilSystem, MilDisplay,NULL,MilImage);
return 0;
}
OpenCV2MIL
#include "stdafx.h"
#include <Mil.h>
#include<iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
#define byte unsigned char
// Opencv Mat--->MilImage buf
int _tmain(int argc, _TCHAR* argv[])
{
MIL_ID MilApplication,
MilSystem,
MilDisplay,
MilImage;
MappAllocDefault(M_DEFAULT, &MilApplication, &MilSystem, &MilDisplay, M_NULL, M_NULL);
Mat src_gray;
Mat src = imread("D://s2.bmp");
if(!src.data)
{
return -1;
}
int n = src.channels();// 获取图像通道数
if(n>1)
{
cvtColor(src, src_gray, CV_RGB2GRAY);//转化为灰度图
}
MbufAlloc2d(MilSystem,src_gray.cols,src_gray.rows,8+M_UNSIGNED, M_IMAGE+M_PROC+M_DISP,& MilImage);//给MIL图像分配空间
MbufPut(MilImage,src_gray.data);//从Opencv的Mat中拷贝数据
MdispSelect(MilDisplay, MilImage); //显示MIL图像
imshow("Opencv图像",src_gray);//显示Opencv图像
waitKey(6000); //等待6000ms后窗口自动关闭
MappFreeDefault(MilApplication,MilSystem, MilDisplay,NULL,MilImage);
return 0;
}