C# OPenCV(Emgu) (转载加编辑)
来源:互联网 发布:java判断字符集 编辑:程序博客网 时间:2024/05/12 15:03
1.pathstring
IntPtr img=CvInvoke.cvLoadImage(path, Emgu.CV.CvEnum.LOAD_IMAGE_TYPE.CV_LOAD_IMAGE_ANYCOLOR);
//这种方法创建并不太好,在c#中可以直接创建成 CvImage<Gray,Byte>
Rectangle cr = CvInvoke.cvGetImageROI(img1);
int width = cr.Width;
int height = cr.Height;
IntPtr GrayImg1 = CvInvoke.cvCreateImage(cr.Size, Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_8U, 1);
cvCvtColor
CvInvoke.cvCvtColor(img1, GrayImg1, Emgu.CV.CvEnum.COLOR_CONVERSION.CV_BGR2GRAY);
3.
int[] hist_size = new int[1] { 256 };//
IntPtr HistImg=CvInvoke.cvCreateHist(1, hist_size, Emgu.CV.CvEnum.HIST_TYPE.CV_HIST_ARRAY, null, 1);//
CvInvoke.cvCalcHist(inPtr1, HistImg,false,System.IntPtr.Zero);//inPtr1HistimgIntPtr[] inPtr1 = new IntPtr[1] { SubImg}
Histimg
for (int i = 0; i < 256; i++)
{
temphist[i] = CvInvoke.cvQueryHistValue_1D(histImg, i);
}
temphist
4.cvLoadImageimg IntPtrIntPtrMIplImage
Emgu.CV.Structure.MIplImage MIpImg =
(Emgu.CV.Structure.MIplImage)System.Runtime.InteropServices.Marshal.PtrToStructure(img, typeof(Emgu.CV.Structure.MIplImage));
C#unsafenpixel = (int)((byte*)img.imageData + img.widthStep * i)[j];
5.
IntPtr Dyncontour = new IntPtr();//
IntPtr Dynstorage = CvInvoke.cvCreateMemStorage(0);
int n= CvInvoke.cvFindContours(tempimg, Dynstorage, ref Dyncontour, StructSize.MCvContour, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_CCOMP,Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE, new Point(0, 0));
n
6.
for(;DyncontourTemp!=null&&DyncontourTemp.Ptr.ToInt32()!=0;DyncontourTemp=DyncontourTemp.HNext)
{
CvInvoke.cvDrawContours(tempContImg, DyncontourTemp,new MCvScalar(255, 255, 255),new MCvScalar(255, 255, 255), 0, 1, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));
}
DyncontourTemp
Seq<Point> DyncontourTemp1= new Seq<Point>(Dyncontour, null)//IntPtr
Seq<Point> DyncontourTemp=DyncontourTemp1;
7cvFindContours Dyncontour
seq<Point> DyncontourTemp1= new Seq<Point>(Dyncontour, null); //IntPtr
int total=contourImg.Total;//contourImg
int TempX = 0; int TempY = 0;int[,] contourArray = new int[2,total];
//
for (int i = 0; i < total;i++ )
{
contourArray[0,i]=contourImg[i].X;
contourArray[1,i]=contourImg[i].Y;
}
摘自:http://www.cnblogs.com/maiye/archive/2010/06/19/1761075.html
- C# OPenCV(Emgu) (转载加编辑)
- c# OpenCV Emgu学习
- VS2010、C#、Emgu CV配置 ; 在C#下使用OpenCV ; C#中使用OpenCV(Emgu CV); 配置全程截图
- VS2010、C#、Emgu CV配置 ; 在C#下使用OpenCV ; C#中使用OpenCV(Emgu CV); 配置全程截图
- VS2010、C#、Emgu CV配置 ; 在C#下使用OpenCV ; C#中使用OpenCV(Emgu CV)
- C# 中使用OPenCV(Emgu)心得
- C#下的openCV(Emgu CV)
- C#下的openCV(Emgu CV)
- 【C# -- OpenCV】Emgu CV 第一个实例
- C# 中使用OPenCV(Emgu)心得
- C# 中使用OPenCV(Emgu)心得
- C# 中使用OPenCV(Emgu)心得
- C#下使用openCV(Emgu CV)
- C#下的openCV(Emgu CV)
- C# 中使用OPenCV(Emgu)心得
- C# 中使用OPenCV(Emgu)心得
- VS2010、C#、Emgu CV配置 ; 在C#下使用OpenCV ; C#中使用OpenCV(Emgu CV); 配置全程截图,不能请留言!
- Emgu CV(OpenCV for C#)学习笔记(1)
- 在csdn 上安个家,记录编程的点滴
- codeforces 306D Polygon
- LeetCode(50) N-Queens II
- ros3.3静态IP上网配置
- 基于XMPP协议的手机多方多端即时通讯方案
- C# OPenCV(Emgu) (转载加编辑)
- java工程编译成exe文件的方法。
- 彻底让我弄懂this,call,apply的文章
- 图解WildFly 8.X配置HTTPS
- 修改dbwr后台进程数量
- 不要在WM_ACTIVATE里调用可以触发活动转移的函数
- WebService框架整理(二) Axis1+Spring
- Cordova – file-transfer, unzip and present adventures
- Android性能优化典范