本文整理汇总了C#中IplImage类的典型用法代码示例。如果您正苦于以下问题:C# IplImage类的具体用法?C# IplImage怎么用?C# IplImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IplImage类属于命名空间,在下文中一共展示了IplImage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Absolute
public void Absolute(IplImage imgNow)
{
imgDiff = cvlib.cvCreateImage(cvlib.cvGetSize( imgNow), imgNow.depth, imgNow.nChannels);
if (!sudah_ambil)
{
imgLast = cvlib.cvCreateImage(cvlib.cvGetSize( imgNow), imgNow.depth, imgNow.nChannels);
imgLast = cvlib.cvCloneImage( imgNow);
sudah_ambil = true;
}
else
sudah_ambil = false;
cvlib.cvAbsDiff( imgNow, imgLast, imgDiff);
cvlib.cvSmooth( imgDiff, imgDiff);
cvlib.cvSmooth( imgDiff, imgDiff);
if (form.showAbs)
cvlib.cvShowImage("Motion", imgDiff);
countWhitePix(imgDiff);
if (!sudah_ambil)
cvlib.cvReleaseImage( imgLast);
cvlib.cvReleaseImage( imgNow);
cvlib.cvReleaseImage( imgDiff);
}
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:29,代码来源:AbsDiff.cs
示例2: cariX
public void cariX(IplImage imgSrc, ref int min, ref int max)
{
bool minTemu = false;
data = new CvMat();
CvScalar maxVal = cvlib.cvRealScalar(imgSrc.width * 255);
CvScalar val = cvlib.cvRealScalar(0);
//For each column sum, if sum <width * 255 then we find min
//then proceed to the end of me to find max, if sum <width * 255 then found a new max
for (int i = 0; i < imgSrc.width; i++)
{
cvlib.cvGetCol( imgSrc, data, i); //col
val = cvlib.cvSum( data);
if (val.Val < maxVal.Val)
{
max = i;
if (!minTemu)
{
min = i;
minTemu = true;
}
}
}
}
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:26,代码来源:preprocessing.cs
示例3: cariY
public void cariY(IplImage imgSrc, ref int min, ref int max)
{
bool minFound = false;
data = new CvMat();
CvScalar maxVal = cvlib.cvRealScalar(imgSrc.width * 255);
CvScalar val = cvlib.cvRealScalar(0);
//For each row sum, if sum <width * 255 then we find min
//then proceed to the end of me to find max, if sum <width * 255 then found a new max
for (int i = 0; i < imgSrc.height; i++)
{
cvlib.cvGetRow( imgSrc, data, i); //row
val = cvlib.cvSum( data);
if (val.val1 < maxVal.val1)
{
max = i;
if (!minFound)
{
min = i;
minFound = true;
}
}
}
}
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:26,代码来源:preprocessing.cs
示例4: cariY
public void cariY(IplImage imgSrc, ref int min, ref int max)
{
bool minFound = false;
data = new CvMat();
CvScalar maxVal = cxtypes.cvRealScalar(imgSrc.width * 255);
CvScalar val = cxtypes.cvRealScalar(0);
//utk setiap baris sum, jika sum < width*255 maka kita temukan min
//kemudian lanjutkan hingga akhir utk menemukan max, jika sum < width*255 maka ditemukan max baru
for (int i = 0; i < imgSrc.height; i++)
{
cxcore.CvGetRow(ref imgSrc, ref data, i); //row
val = cxcore.CvSum(ref data);
if (val.val1 < maxVal.val1)
{
max = i;
if (!minFound)
{
min = i;
minFound = true;
}
}
}
}
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:26,代码来源:preprocessing.cs
示例5: Absolute
public void Absolute(IplImage imgNow)
{
imgDiff = cxcore.CvCreateImage(cxcore.CvGetSize(ref imgNow), imgNow.depth, imgNow.nChannels);
if (!sudah_ambil)
{
imgLast = cxcore.CvCreateImage(cxcore.CvGetSize(ref imgNow), imgNow.depth, imgNow.nChannels);
imgLast = cxcore.CvCloneImage(ref imgNow);
sudah_ambil = true;
}
else
sudah_ambil = false;
cxcore.CvAbsDiff(ref imgNow, ref imgLast, ref imgDiff);
cv.CvSmooth(ref imgDiff, ref imgDiff);
cv.CvSmooth(ref imgDiff, ref imgDiff);
if(form.showAbs)
highgui.CvShowImage("Motion", ref imgDiff);
countWhitePix(imgDiff);
if (!sudah_ambil)
cxcore.CvReleaseImage(ref imgLast);
cxcore.CvReleaseImage(ref imgNow);
cxcore.CvReleaseImage(ref imgDiff);
}
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:29,代码来源:AbsDiff.cs
示例6: adaBlackPix
public bool adaBlackPix(IplImage image)
{
int p, black = 0;
byte pix;
byte[] data = image.ImageData;
for (int x = 0; x < image.widthStep; x++)
{
for (int y = 0; y < image.height; y++)
{
p = y * image.widthStep + x;
pix = data[p];
if (pix == 0)
black++;
}
}
if (black < 1000)
return false;
else
return true;
}
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:26,代码来源:MainForm.cs
示例7: skin_hsv
public IplImage skin_hsv(IplImage image)
{
int xi, x, y, p;
IplImage img_hsv;
img_hsv = cvlib.cvCreateImage(cvlib.cvGetSize( image), 8, 3);
cvlib.cvCvtColor( image, img_hsv, cvlib.CV_BGR2HSV);
num[,] bmpdata;
bmpdata = new num[image.height, image.width];
byte[] dataIn = img_hsv.ImageData;
for (y = 0; y < image.height; y++)
{
for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
{
//column position
p = y * image.widthStep + xi;
//grab the pixel data
bmpdata[y, x].H = dataIn[p];
bmpdata[y, x].S = dataIn[p + 1];
bmpdata[y, x].V = dataIn[p + 2];
}
}
for (y = 0; y < image.height; y++)
{
for (x = 0; x < image.width; x++)
{
if (bmpdata[y, x].H <= 19 && bmpdata[y, x].S >= 48) //jika kondisi cocok maka jgn d hitamkan
bmpdata[y, x].H += 0;
else
bmpdata[y, x].H = bmpdata[y, x].S = bmpdata[y, x].V = 0;
}
}
for (y = 0; y < image.height; y++)
{
for (xi = 0, x = 0; xi < image.widthStep; xi += 3, x++)
{
//column position
p = y * image.widthStep + xi;
//grab the pixel data
dataIn[p] = bmpdata[y, x].H;
dataIn[p + 1] = bmpdata[y, x].S;
dataIn[p + 2] = bmpdata[y, x].V;
}
}
img_hsv.ImageData = dataIn;
IplImage res = cvlib.cvCreateImage(cvlib.cvGetSize( image), 8, 3);
cvlib.cvCvtColor( img_hsv, res, cvlib.CV_HSV2BGR);
cvlib.cvReleaseImage( img_hsv);
return res;
}
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:59,代码来源:SkinDetect.cs
示例8: NewEqualsOld3
public void NewEqualsOld3()
{
using (var img = new IplImage(@"Image\Blob\shapes3.png", LoadMode.GrayScale))
{
CompareBlob(img);
CompareRendering(img);
CompareLabelImage(img);
}
}
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:9,代码来源:BlobTest.cs
示例9: CentralMoments
/// <summary>
/// Calculates central moment for a blob.
/// Central moments will be stored in blob structure. (cvCentralMoments)
/// </summary>
/// <param name="blob">Blob.</param>
/// <param name="img">Label image (depth=IPL_DEPTH_LABEL and num. channels=1).</param>
public static void CentralMoments(CvBlob blob, IplImage img)
{
if (blob == null)
throw new ArgumentNullException("blob");
if (img == null)
throw new ArgumentNullException("img");
CvBlobInvoke.cvb_cvCentralMoments(blob.CvPtr, img.CvPtr);
}
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:15,代码来源:CvBlobLib.cs
示例10: Process
/// <summary>
///
/// </summary>
/// <param name="inputBgrImage"></param>
/// <param name="outputHueMask"></param>
public virtual void Process(IplImage inputBgrImage, IplImage outputHueMask)
{
if (disposed)
throw new ObjectDisposedException("CvAdaptiveSkinDetector");
if (inputBgrImage == null)
throw new ArgumentNullException("inputBgrImage");
if (outputHueMask == null)
throw new ArgumentNullException("outputHueMask");
inputBgrImage.ThrowIfDisposed();
outputHueMask.ThrowIfDisposed();
NativeMethods.contrib_CvAdaptiveSkinDetector_process(ptr, inputBgrImage.CvPtr, outputHueMask.CvPtr);
}
开发者ID:0sv,项目名称:opencvsharp,代码行数:17,代码来源:CvAdaptiveSkinDetector.cs
示例11: ConvexityDefect
public ConvexityDefect()
{
using (IplImage imgSrc = new IplImage(@"img\hand_p.jpg", LoadMode.Color))
using (IplImage imgHSV = new IplImage(imgSrc.Size, BitDepth.U8, 3))
using (IplImage imgH = new IplImage(imgSrc.Size, BitDepth.U8, 1))
using (IplImage imgS = new IplImage(imgSrc.Size, BitDepth.U8, 1))
using (IplImage imgV = new IplImage(imgSrc.Size, BitDepth.U8, 1))
using (IplImage imgBackProjection = new IplImage(imgSrc.Size, BitDepth.U8, 1))
using (IplImage imgFlesh = new IplImage(imgSrc.Size, BitDepth.U8, 1))
using (IplImage imgHull = new IplImage(imgSrc.Size, BitDepth.U8, 1))
using (IplImage imgDefect = new IplImage(imgSrc.Size, BitDepth.U8, 3))
using (IplImage imgContour = new IplImage(imgSrc.Size, BitDepth.U8, 3))
using (CvMemStorage storage = new CvMemStorage())
{
// RGB -> HSV
Cv.CvtColor(imgSrc, imgHSV, ColorConversion.BgrToHsv);
Cv.CvtPixToPlane(imgHSV, imgH, imgS, imgV, null);
IplImage[] hsvPlanes = {imgH, imgS, imgV};
// 肌色領域を求める
RetrieveFleshRegion(imgSrc, hsvPlanes, imgBackProjection);
// 最大の面積の領域を残す
FilterByMaximalBlob(imgBackProjection, imgFlesh);
Interpolate(imgFlesh);
// 輪郭を求める
CvSeq<CvPoint> contours = FindContours(imgFlesh, storage);
if (contours != null)
{
Cv.DrawContours(imgContour, contours, CvColor.Red, CvColor.Green, 0, 3, LineType.AntiAlias);
// 凸包を求める
int[] hull;
Cv.ConvexHull2(contours, out hull, ConvexHullOrientation.Clockwise);
Cv.Copy(imgFlesh, imgHull);
DrawConvexHull(contours, hull, imgHull);
// 凹状欠損を求める
Cv.Copy(imgContour, imgDefect);
CvSeq<CvConvexityDefect> defect = Cv.ConvexityDefects(contours, hull);
DrawDefects(imgDefect, defect);
}
using (new CvWindow("src", imgSrc))
using (new CvWindow("back projection", imgBackProjection))
using (new CvWindow("hull", imgHull))
using (new CvWindow("defect", imgDefect))
{
Cv.WaitKey();
}
}
}
开发者ID:qxp1011,项目名称:opencvsharp,代码行数:52,代码来源:Program.cs
示例12: countWhitePix
public void countWhitePix(IplImage image)
{
int p, white = 0 ;
byte pix;
byte[] data = image.ImageDataUChar;
for (int x = 0; x < image.widthStep; x++)
{
for (int y = 0; y < image.height; y++)
{
p = y * image.widthStep + x;
pix = data[p];
if (pix == 255)
white++;
}
}
if (white < 50 && white < 5)
diam++;
else
diam = 0;
if (white > 100)
{
gerak++;
if (white > 500)
wave++;
}
if (diam > 10)
{
gerak = 0;
wave = 0;
diam = 0;
form.match = true;
}
if (wave > 10)
{
form.reset = true;
wave = 0;
gerak = 0;
diam = 0;
}
cxcore.CvReleaseImage(ref image);
}
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:51,代码来源:AbsDiff.cs
示例13: Niblack
/// <summary>
/// Niblackの手法による二値化処理を行う。
/// </summary>
/// <param name="imgSrc">入力画像</param>
/// <param name="imgDst">出力画像</param>
/// <param name="kernelSize">局所領域のサイズ</param>
/// <param name="k">係数</param>
#else
/// <summary>
/// Binarizes by Niblack's method
/// </summary>
/// <param name="src">Input image</param>
/// <param name="dst">Output image</param>
/// <param name="kernelSize">Window size</param>
/// <param name="k">Adequate coefficient</param>
#endif
public static void Niblack(IplImage src, IplImage dst, int kernelSize, double k)
{
if (src == null)
throw new ArgumentNullException("src");
if (dst == null)
throw new ArgumentNullException("dst");
// グレースケールのみ
if (src.NChannels != 1)
throw new ArgumentException("src must be gray scale image");
if (dst.NChannels != 1)
throw new ArgumentException("dst must be gray scale image");
// サイズのチェック
if (kernelSize < 3)
throw new ArgumentOutOfRangeException("kernelSize", "size must be 3 and above");
if (kernelSize % 2 == 0)
throw new ArgumentOutOfRangeException("kernelSize", "size must be odd number");
CvRect roi = src.ROI;
int width = roi.Width;
int height = roi.Height;
if (width != dst.Width || height != dst.Height)
throw new ArgumentException("src.Size == dst.Size");
unsafe
{
byte* pSrc = src.ImageDataPtr;
byte* pDst = dst.ImageDataPtr;
int stepSrc = src.WidthStep;
int stepDst = dst.WidthStep;
//for (int y = 0; y < gray.Height; y++)
MyParallel.For(0, height, delegate(int y)
{
for (int x = 0; x < width; x++)
{
double m, s;
MeanStddev(src, x + roi.X, y + roi.Y, kernelSize, out m, out s);
double threshold = m + k * s;
int offsetSrc = stepSrc * (y + roi.Y) + (x + roi.X);
int offsetDst = stepDst * y + x;
if (pSrc[offsetSrc] < threshold)
pDst[offsetDst] = 0;
else
pDst[offsetDst] = 255;
}
}
);
}
}
开发者ID:0sv,项目名称:opencvsharp,代码行数:66,代码来源:Binarizer.cs
示例14: SimpleTest
public void SimpleTest()
{
using (var src = new IplImage(@"Image\Blob\shapes2.png", LoadMode.GrayScale))
using (var binary = new IplImage(src.Size, BitDepth.U8, 1))
using (var render = new IplImage(src.Size, BitDepth.U8, 3))
{
Cv.Threshold(src, binary, 0, 255, ThresholdType.Otsu);
var blobs = new CvBlobs(binary);
blobs.RenderBlobs(src, render);
using (new CvWindow(render))
{
Cv.WaitKey();
}
}
}
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:16,代码来源:BlobTest.cs
示例15: RetrieveFleshRegion
/// <summary>
/// バックプロジェクションにより肌色領域を求める
/// </summary>
/// <param name="imgSrc"></param>
/// <param name="hsvPlanes"></param>
/// <param name="imgRender"></param>
private void RetrieveFleshRegion(IplImage imgSrc, IplImage[] hsvPlanes, IplImage imgDst)
{
int[] histSize = new int[] {30, 32};
float[] hRanges = {0.0f, 20f};
float[] sRanges = {50f, 255f};
float[][] ranges = {hRanges, sRanges};
imgDst.Zero();
using (CvHistogram hist = new CvHistogram(histSize, HistogramFormat.Array, ranges, true))
{
hist.Calc(hsvPlanes, false, null);
float minValue, maxValue;
hist.GetMinMaxValue(out minValue, out maxValue);
hist.Normalize(imgSrc.Width * imgSrc.Height * 255 / maxValue);
hist.CalcBackProject(hsvPlanes, imgDst);
}
}
开发者ID:qxp1011,项目名称:opencvsharp,代码行数:23,代码来源:Program.cs
示例16: Surf
private static void Surf(IplImage img1, IplImage img2)
{
Mat src = new Mat(img1, true);
Mat src2 = new Mat(img2, true);
//Detect the keypoints and generate their descriptors using SURF
SURF surf = new SURF(500, 4, 2, true);
KeyPoint[] keypoints1, keypoints2;
MatOfFloat descriptors1 = new MatOfFloat();
MatOfFloat descriptors2 = new MatOfFloat();
surf.Run(src, null, out keypoints1, descriptors1);
surf.Run(src2, null, out keypoints2, descriptors2);
// Matching descriptor vectors with a brute force matcher
BFMatcher matcher = new BFMatcher(NormType.L2, false);
DMatch[] matches = matcher.Match(descriptors1, descriptors2);//例外が発生する箇所
Mat view = new Mat();
Cv2.DrawMatches(src, keypoints1, src2, keypoints2, matches, view);
Window.ShowImages(view);
}
开发者ID:0sv,项目名称:opencvsharp,代码行数:19,代码来源:Program.cs
示例17: classify
//img For classifying method which is based on the nearest class
public float classify(ref IplImage img, bool showResult)
{
CvMat data = new CvMat();
CvMat results = new CvMat(); //<<<< check
CvMat dist = new CvMat(); //<<<< check
CvMat nearest = cvlib.cvCreateMat(1, K, cvlib.CV_32FC1); //<<<< check
float result;
//process file
prs_image = p.preprocess(img, size, size);
//set data
img32 = cvlib.cvCreateImage(cvlib.cvSize(size, size), (int)cvlib.IPL_DEPTH_32F, 1);
cvlib.cvConvertScale( prs_image, img32, 0.0039215, 0);
cvlib.cvGetSubRect( img32, data, cvlib.cvRect(0, 0, size, size)); //possible memory leak??
CvMat row_header = new CvMat();
CvMat row1 = new CvMat(); //<<< check
//convert data matrix size x size to vector
row1 = cvlib.cvReshape( data, row_header, 0, 1); //<<< check
result = knn.find_nearest(row1, K, results, IntPtr.Zero, nearest, dist);
int accuracy = 0;
for (int i = 0; i < K; i++)
{
if (nearest.fl[i] == result)
accuracy++;
}
float pre = 100 * ((float)accuracy / (float)K);
if (showResult == true)
{
form.WriteLine("|\tClass\t\t|\tPrecision\t\t|\tAccuracy/K\t|\n", false, false);
form.WriteLine("|\t" + result.ToString() + "\t\t|\t" + pre.ToString("N2") + "% \t\t|\t" + accuracy.ToString() + "/" + K.ToString() + "\t\t|" + "\n", false, false);
form.WriteLine(" -------------------------------------------------------------------------------------------------------------------------------------------------\n", false, false);
}
cvlib.cvReleaseImage( img);
return result;
}
开发者ID:rahulgarg1994,项目名称:empower_talk2,代码行数:43,代码来源:KNearest.cs
示例18: DebugShowOldLabel
public void DebugShowOldLabel(IplImage oldLabels)
{
using (IplImage img = new IplImage(oldLabels.Size, BitDepth.U8, 1))
{
img.Zero();
for (int r = 0; r < img.Height; r++)
{
for (int c = 0; c < img.Width; c++)
{
try
{
if (oldLabels[r, c] != 0)
img[r, c] = 255;
}
catch
{
throw;
}
}
}
CvWindow.ShowImages("old", img);
}
}
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:23,代码来源:BlobTest.cs
示例19: cariBB
public CvRect cariBB(IplImage imgSrc)
{
CvRect aux;
int xmin, xmax, ymin, ymax, height, width;
xmin = xmax = ymin = ymax = height = width = 0;
cariX(imgSrc, ref xmin, ref xmax);
cariY(imgSrc, ref ymin, ref ymax);
width = xmax - xmin;
height = ymax - ymin;
double lebar = width * 1.5;
height = height >= (width * 1.5) ? (int)lebar : height;
//form.WriteLine("height = " + height.ToString(), true, true);
//form.WriteLine("width = " + width.ToString(), true, true);
aux = new CvRect(xmin, ymin, width, height);
return aux;
}
开发者ID:Juniar-Rakhman,项目名称:OpenCV_ASL_Recognition,代码行数:23,代码来源:preprocessing.cs
示例20: GrayCapture
private static void GrayCapture(Capture capture)
{
using (var window = new NamedWindow("test"))
{
while (CV.WaitKey(10) < 0) //laisse la main
{
using (var src = capture.QueryFrame())// recupere une image
{
if (src == null)
{
break;
}
using (var gray = new IplImage(src.Size, IplDepth.U8, 1)) //filtre
using (var dstCanny = new IplImage(src.Size, IplDepth.U8, 1))
{
CV.CvtColor(src, gray, ColorConversion.Bgr2Gray);
CV.Canny(gray, dstCanny, 50, 50);
window.ShowImage(dstCanny);
}
}
}
}
}
开发者ID:auriou,项目名称:SampleRA,代码行数:23,代码来源:Detourage.cs
注:本文中的IplImage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论