91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 55KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-06-16
  • 語言: C/C++
  • 標(biāo)簽: 橢圓??擬合??

資源簡介

以C語言開發(fā)的最小二乘法橢圓擬合程序,精度非常高,歡迎使用

資源截圖

代碼片段和文件信息

#include?“cv.h“
#include?“highgui.h“

int?slider_pos?=?70;

IplImage?*image02?=?0?*image03?=?0?*image04?=?0;
void?process_image(int?h);

int?main(?int?argc?char**?argv?)
{
????const?char*?filename?=?argc?==?2???argv[1]?:?(char*)“stuff.jpg“;
????
????//?讀入圖像,強制為灰度圖像
????if(?(image03?=?cvLoadImage(filename?0))?==?0?)
????????return?-1;

????//?Create?the?destination?images
????image02?=?cvCloneImage(?image03?);
????image04?=?cvCloneImage(?image03?);

????//?Create?windows.
????cvNamedWindow(“Source“?1);
????cvNamedWindow(“Result“?1);

????//?Show?the?image.
????cvShowImage(“Source“?image03);

????//?Create?toolbars.?HighGUI?use.
????cvCreateTrackbar(?“Threshold“?“Result“?&slider_pos?255?process_image?);

????process_image(0);

????//?Wait?for?a?key?stroke;?the?same?function?arranges?events?processing????????????????
????cvWaitKey(0);
????cvReleaseImage(&image02);
????cvReleaseImage(&image03);

????cvDestroyWindow(“Source“);
????cvDestroyWindow(“Result“);

????return?0;
}

//?Define?trackbar?callback?functon.?This?function?find?contours
//?draw?it?and?approximate?it?by?ellipses.
void?process_image(int?h)
{
????CvMemStorage*?stor;
????CvSeq*?cont;
????CvBox2D32f*?box;
????CvPoint*?PointArray;
????CvPoint2D32f*?PointArray2D32f;
????
????//?創(chuàng)建動態(tài)結(jié)構(gòu)序列
????stor?=?cvCreateMemStorage(0);
????cont?=?cvCreateSeq(CV_SEQ_ELTYPE_POINT?sizeof(CvSeq)?sizeof(CvPoint)??stor);
????
????//?二值話圖像.
????cvThreshold(?image03?image02?slider_pos?255?CV_THRESH_BINARY?);
????
????//?尋找所有輪廓.
????cvFindContours(?image02?stor?&cont?sizeof(CvContour)?
????????????????????CV_RETR_LIST?CV_CHAIN_APPROX_NONE?cvPoint(00));
????
????//?Clear?images.?IPL?use.
????cvZero(image02);
????cvZero(image04);
????
????//?本循環(huán)繪制所有輪廓并用橢圓擬合.
????for(;cont;cont?=?cont->h_next)
????{???
????????int?i;?//?Indicator?of?cycle.
????????int?count?=?cont->total;?//?This?is?number?point?in?contour
????????CvPoint?center;
????????CvSize?size;
????????
????????//?Number?point?must?be?more?than?or?equal?to?6?(for?cvFitEllipse_32f).????????
????????if(?count?????????????continue;
????????
????????//?Alloc?memory?for?contour?point?set.????
????????PointArray?=?(CvPoint*)malloc(?count*sizeof(CvPoint)?);
????????PointArray2D32f=?(CvPoint2D32f*)malloc(?count*sizeof(CvPoint2D32f)?);
????????
????????//?Alloc?memory?for?ellipse?data.
????????box?=?(CvBox2D32f*)malloc(sizeof(CvBox2D32f));
????????
????????//?Get?contour?point?set.
????????cvCvtSeqToArray(cont?PointArray?CV_WHOLE_SEQ);
????????
????????//?Convert?CvPoint?set?to?CvBox2D32f?set.
????????for(i=0;?i????????{
????????????PointArray2D32f[i].x?=?(float)PointArray[i].x;
????????????PointArray2D32f[i].y?=?(float)PointArray[i].y;
????????}
????????
????????//擬合當(dāng)前輪廓.
????????cvFitEllipse(PointArray2D32f?count?box);
????????
????????//?繪制當(dāng)前輪廓.
????????cvDrawContours(image04contCV_RGB(255255255)
CV_RGB(255255255)018cvPoint(00));
????????
????????//?Convert?ellipse?data?from?float?to?integer?representation.

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????8238??2007-02-24?14:57??例5-17\circles.png

?????文件???????3647??2007-02-24?14:56??例5-17\fitellipse.c

?????文件???????4196??2007-03-07?20:41??例5-17\fitellipse.dsp

?????文件????????545??2007-03-07?20:41??例5-17\fitellipse.dsw

?????文件????????138??2007-02-24?15:10??例5-17\Makefile

?????文件??????44521??2007-03-07?22:17??例5-17\rice.png

?????目錄??????????0??2008-10-21?09:23??例5-17

?????文件????????440??2011-07-24?18:56??快捷方式?到?EPSnap.exe.lnk

-----------?---------??----------?-----??----

????????????????61943????????????????????9


評論

共有 條評論