本文整理汇总了C++中cvSeqPush函数的典型用法代码示例。如果您正苦于以下问题:C++ cvSeqPush函数的具体用法?C++ cvSeqPush怎么用?C++ cvSeqPush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cvSeqPush函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void FaceDetection::AddContours2Rect(CvSeq *seq, int color, int iLayer)
{
assert(m_mstgRects != NULL);
assert(m_seqRects != NULL);
CvContourRect cr;
for (CvSeq* external = seq; external; external = external->h_next)
{
cr.r = cvContourBoundingRect(external, 1 );
cr.pCenter.x = cr.r.x + cr.r.width / 2;
cr.pCenter.y = cr.r.y + cr.r.height / 2;
cr.iNumber = iLayer;
cr.iType = 6;
cr.iFlags = 0;
cr.seqContour = external;
cr.iContourLength = external->total;
cr.iColor = color;
cvSeqPush(m_seqRects, &cr);
for (CvSeq* internal = external->v_next; internal; internal = internal->h_next)
{
cr.r = cvContourBoundingRect(internal, 0);
cr.pCenter.x = cr.r.x + cr.r.width / 2;
cr.pCenter.y = cr.r.y + cr.r.height / 2;
cr.iNumber = iLayer;
cr.iType = 12;
cr.iFlags = 0;
cr.seqContour = internal;
cr.iContourLength = internal->total;
cr.iColor = color;
cvSeqPush(m_seqRects, &cr);
}
}
}// void FaceDetection::AddContours2Rect(CvSeq *seq, int color, int iLayer)
示例2: drawSquares
// the function draws all the squares in the image
void drawSquares(IplImage* imgSrc, CvSeq* squares)
{
CvSeqReader reader;
IplImage* imgCopy = cvCloneImage(imgSrc);
int i;
// initialize reader of the sequence
cvStartReadSeq(squares, &reader, 0);
// read 4 sequence elements at a time (all vertices of a square)
printf("Found %d rectangles in image\n", squares->total / 4);
for (i = 0; i < squares->total; i += 4)
{
CvPoint* pntRect = gPnt;
int pntCount = 4;
CvSeq* seqRect = cvCreateSeq(CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), gStorage);
// read 4 vertices
memcpy(gPnt, reader.ptr, squares->elem_size);
CV_NEXT_SEQ_ELEM(squares->elem_size, reader);
cvSeqPush(seqRect, &pntRect[0]);
memcpy(gPnt + 1, reader.ptr, squares->elem_size);
CV_NEXT_SEQ_ELEM(squares->elem_size, reader);
cvSeqPush(seqRect, &pntRect[1]);
memcpy(gPnt + 2, reader.ptr, squares->elem_size);
CV_NEXT_SEQ_ELEM(squares->elem_size, reader);
cvSeqPush(seqRect, &pntRect[2]);
memcpy(gPnt + 3, reader.ptr, squares->elem_size);
CV_NEXT_SEQ_ELEM(squares->elem_size, reader);
cvSeqPush(seqRect, &pntRect[3]);
// draw the square as a closed polyline
cvPolyLine(imgCopy, &pntRect, &pntCount, 1, 1, CV_RGB(0, 255, 0), 1, CV_AA, 0);
// draw the min outter rect
CvBox2D box = cvMinAreaRect2(seqRect, NULL);
CvPoint2D32f ptBox[4];
cvBoxPoints(box, ptBox);
for(int i = 0; i < 4; ++i) {
cvLine(imgCopy, cvPointFrom32f(ptBox[i]), cvPointFrom32f(ptBox[((i+1)%4)?(i+1):0]), CV_RGB(255,0,0));
}
}
// show the resultant image
cvShowImage(wndname, imgCopy);
cvReleaseImage(&imgCopy);
}
示例3: cvSeqPush
void FaceDetection::CreateResults(CvSeq * lpSeq)
{
Face * tmp;
double Max = 0;
double CurStat = 0;
FaceData tmpData;
if (m_bBoosting)
{
tmp = m_pFaceList->GetData();
tmp->CreateFace(&tmpData);
CvFace tmpFace;
tmpFace.MouthRect = tmpData.MouthRect;
tmpFace.LeftEyeRect = tmpData.LeftEyeRect;
tmpFace.RightEyeRect = tmpData.RightEyeRect;
cvSeqPush(lpSeq,&tmpFace);
}else
{
while ( (tmp = m_pFaceList->GetData()) != 0 )
{
CurStat = tmp->GetWeight();
if (CurStat > Max)
Max = CurStat;
}
while ( (tmp = m_pFaceList->GetData()) != 0 )
{
tmp->CreateFace(&tmpData);
CurStat = tmp->GetWeight();
if (CurStat == Max)
{
CvFace tmpFace;
tmpFace.MouthRect = tmpData.MouthRect;
tmpFace.LeftEyeRect = tmpData.LeftEyeRect;
tmpFace.RightEyeRect = tmpData.RightEyeRect;
cvSeqPush(lpSeq,&tmpFace);
}
}
}
}// void FaceDetection::DrawResult(IplImage* img)
示例4: CalcFourierDescriptorCoeff
void CalcFourierDescriptorCoeff(CvSeq* seq_pts, int n_fourier,CvSeq* seq_fourier)
{
int count = seq_pts->total;
double *coeff_cos, *coeff_sin;
coeff_cos = (double*)malloc(count*sizeof(double));
coeff_sin = (double*)malloc(count*sizeof(double));
int i;
for(i = 0; i < count; i++)
{
coeff_sin[i] = sin(2*i*CV_PI/count);
coeff_cos[i] = cos(2*i*CV_PI/count);
}
cvClearSeq(seq_fourier);
for(int u = 0; u < n_fourier; u++)
{
CvPoint2D32f point_coeff = cvPoint2D32f(0, 0);
for(i = 0; i < count; i+=4)
{
CvPoint* pt = (CvPoint*)cvGetSeqElem(seq_pts, i);
point_coeff.x += (float)(pt->x*coeff_cos[(i*u)%count] + pt->y*coeff_sin[(i*u)%count]);
point_coeff.y += (float)(pt->y*coeff_cos[(i*u)%count] - pt->x*coeff_sin[(i*u)%count]);
}
//point_coeff.x/=count;
//point_coeff.y/=count;
cvSeqPush(seq_fourier, &point_coeff);
}
free(coeff_cos);
free(coeff_sin);
}
示例5: CalcBoundary
void CalcBoundary(CvSeq* seq_fourier, int n_Pts, CvSeq* seq_pts)
{
int count = seq_fourier->total;
double *coeff_cos, *coeff_sin;
coeff_cos = (double*)malloc(n_Pts*sizeof(double));
coeff_sin = (double*)malloc(n_Pts*sizeof(double));
int i;
for(i = 0; i < n_Pts; i++)
{
coeff_sin[i] = sin(2*i*CV_PI/n_Pts);
coeff_cos[i] = cos(2*i*CV_PI/n_Pts);
}
cvClearSeq(seq_pts);
for(i = 0; i < n_Pts; i++)
{
CvPoint pt = cvPoint(0, 0);
double sumx = 0, sumy = 0;
for(int u = 0; u < count; u++)
{
CvPoint2D32f* point_coeff = (CvPoint2D32f*)cvGetSeqElem(seq_fourier, u);
sumx += point_coeff->x*coeff_cos[(i*u)%n_Pts] - point_coeff->y*coeff_sin[(i*u)%n_Pts];
sumy += point_coeff->y*coeff_cos[(i*u)%n_Pts] + point_coeff->x*coeff_sin[(i*u)%n_Pts];
}
pt.x = cvRound(sumx/count);
pt.y = cvRound(sumy/count);
cvSeqPush(seq_pts, &pt);
}
free(coeff_cos);
free(coeff_sin);
}
示例6: rb_seq_push
VALUE
rb_seq_push(VALUE self, VALUE args, int flag)
{
CvSeq *seq = CVSEQ(self);
VALUE klass = seqblock_class(seq), object;
void *buffer = NULL;
for (int i = 0; i < RARRAY_LEN(args); i++) {
object = RARRAY_PTR(args)[i];
if (CLASS_OF(object) == klass) {
if (flag == CV_FRONT)
cvSeqPushFront(seq, DATA_PTR(object));
else
cvSeqPush(seq, DATA_PTR(object));
}
else if (rb_obj_is_kind_of(object, rb_klass) && CLASS_OF(rb_first(object)) == klass) { // object is CvSeq
buffer = cvCvtSeqToArray(CVSEQ(object), cvAlloc(CVSEQ(object)->total * CVSEQ(object)->elem_size));
cvSeqPushMulti(seq, buffer, CVSEQ(object)->total, flag);
cvFree(&buffer);
}
else {
rb_raise(rb_eTypeError, "arguments should be %s or %s which includes %s.",
rb_class2name(klass), rb_class2name(rb_klass), rb_class2name(klass));
}
}
return self;
}
示例7: cvAvgSdv
CvSeq *reghand::filthull2(CvSeq *filted_elimhull)
{
//CvSeq *filtedhullseq=cvCloneSeq(filted_elimhull);
float maxdis=0;CvPoint **fingpt;CvScalar mean,std=cvScalarAll(0);
CvMat *dismat=cvCreateMat(1,filted_elimhull->total,CV_32FC1);
CvPoint2D32f center=minrect.center;
for (int i=0;i<filted_elimhull->total;i++)
{
CvPoint **data=CV_GET_SEQ_ELEM(CvPoint*,filted_elimhull,i);
CvPoint pt=**data;
float dis=sqrt(pow(pt.x-center.x,2)+pow(pt.y-center.y,2));
dismat->data.fl[i]=dis;
if(dis>maxdis){maxdis=dis;fingpt=data;}
}
cvAvgSdv(dismat,&mean,&std);
if(filted_elimhull->total==1&&maxdis>fingerTh*0.5) return filted_elimhull;
if(filted_elimhull->total==2&&maxdis>fingerTh*0.5&&std.val[0]<10)
{
CvPoint startpt=**CV_GET_SEQ_ELEM(CvPoint*,filted_elimhull,0);
CvPoint endpt=**CV_GET_SEQ_ELEM(CvPoint*,filted_elimhull,1);;
double bfang=atan(double(startpt.y-handcenter.y)/(startpt.x-handcenter.x))*180/PI;
if(bfang<0)bfang+=180;
double afang=atan(double(endpt.y-handcenter.y)/(endpt.x-handcenter.x))*180/PI;
if(afang<0)afang+=180;
if(fabs(bfang-afang)>60)
{cvClearSeq(filted_elimhull);cvSeqPush(filted_elimhull,fingpt);return filted_elimhull;}
else return filted_elimhull;
}
示例8: cvGetSize
bool CybCamCalibration::generateDataToCalibration(IplImage *rgb_image) {
IplImage *view_gray;
int found = 0, count = 0;
img_size = cvGetSize(rgb_image);
found = cvFindChessboardCorners( rgb_image, board_size,
image_points_buf, &count, CV_CALIB_CB_ADAPTIVE_THRESH );
// improve the found corners' coordinate accuracy
view_gray = cvCreateImage( cvGetSize(rgb_image), 8, 1 );
cvCvtColor( rgb_image, view_gray, CV_BGR2GRAY );
cvFindCornerSubPix( view_gray, image_points_buf, count, cvSize(11,11),
cvSize(-1,-1), cvTermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 30, 0.1 ));
cvReleaseImage( &view_gray );
if( found )
{
cvSeqPush( image_points_seq, image_points_buf );
sprintf( imagename, "image%03d.png", image_points_seq->total - 1 );
cvSaveImage( imagename, rgb_image );
}
cvDrawChessboardCorners( rgb_image, board_size, image_points_buf, count, found );
return ((unsigned)image_points_seq->total >= (unsigned)image_count);
}
示例9: cvSeqPush
void EdgeDetection::getEdge(CvSeq *seq)
{
int nWidth = pImage->width;
int nHeight = pImage->height;
int widthStep=pImage->widthStep;
//计算直方图
int histab[256];
for(int i=0;i<256;i++)
histab[i]=0;
for(int j=1;j<nHeight-1;j++)
{
for(int i=1;i<nWidth-1;i++)
{
double temp=(pImage->imageData+nWidth*j)[i];
if(temp<0)
temp+=256;
histab[(int)temp]++;
}
}
for(int i=0;i<256;i++)
probability[i]=(float)(histab[i]/((nHeight-2)*(nWidth-2)*1.0));
double edgethreadhold=moment_shresh_sel1(probability);//计算边缘二值化的分割阈值
for(int j=0;j<nHeight;j++)//将sobel检测出来的边缘进行二值化,滤去值过小的边缘点
{
for(int i=0;i<nWidth;i++)
{
if(i<1||j<1||j==nHeight-1||i==nWidth-1)
{
(pImage->imageData+nWidth*j)[i]=0;
}
else
{
double temp=(pImage->imageData+nWidth*j)[i];
if(temp<0)
temp+=256;
if(temp>edgethreadhold)
{
(pImage->imageData+nWidth*j)[i]=255;
CvPoint2D32f sample;
sample.x=j;
sample.y=i;
cvSeqPush(seq,&sample);
}
else
(pImage->imageData+nWidth*j)[i]=0;
}
}
}
cvNamedWindow( "Segment2_边缘图", 1 );//创建窗口
cvShowImage( "Segment2_边缘图", pImage );//显示图像
}
示例10: cvCreateMemStorage
void bContourFinder::findConvexHulls(){
CvMemStorage *stor = cvCreateMemStorage();
CvSeq * ptseq = cvCreateSeq( CV_SEQ_KIND_CURVE|CV_32SC2,
sizeof(CvContour),
sizeof(CvPoint),
stor );
CvSeq * hull;
CvPoint pt;
this->convexBlobs.clear();
for(int i = 0 ; i < this->blobs.size(); i++){
this->convexBlobs.push_back(ofxCvBlob());
this->convexBlobs[i] = this->blobs[i];
this->convexBlobs[i].pts.clear();
// get blob i
for(int j = 0; j < this->blobs[i].pts.size(); j++){
// fill in blob points
pt.x = this->blobs[i].pts[j].x;
pt.y = this->blobs[i].pts[j].y;
cvSeqPush( ptseq, &pt);
}
hull = cvConvexHull2(ptseq, 0, CV_CLOCKWISE, 0);
// get the points for the blob:
CvPoint pt = **CV_GET_SEQ_ELEM( CvPoint*, hull, hull->total - 1 );
for( int j=0; j < hull->total; j++ ) {
pt = **CV_GET_SEQ_ELEM( CvPoint*, hull, j );
convexBlobs[i].pts.push_back( ofPoint((float)pt.x, (float)pt.y) );
}
convexBlobs[i].nPts = convexBlobs[i].pts.size();
}
cvClearMemStorage( stor );
}
示例11: main
int
main (int argc, char **argv)
{
CvMemStorage *storage = cvCreateMemStorage( 0 );
CvSeq *points = cvCreateSeq( CV_SEQ_ELTYPE_POINT, sizeof( CvSeq ), sizeof( CvPoint ), storage );
cvSeqPush( points, &cvPoint( 100, 50 ) );
cvSeqPush( points, &cvPoint( 50, 100 ) );
cvSeqPush( points, &cvPoint( 50, 150 ) );
cvSeqPush( points, &cvPoint( 150, 50 ) );
CvRect rect = cvBoundingRect( points );
cvPrintRect( rect );
cvReleaseMemStorage( &storage );
return 0;
}
示例12: cvSegmentMotion
CV_IMPL CvSeq*
cvSegmentMotion( const CvArr* mhimg, CvArr* segmaskimg, CvMemStorage* storage,
double timestamp, double segThresh )
{
cv::Mat mhi = cv::cvarrToMat(mhimg);
const cv::Mat segmask = cv::cvarrToMat(segmaskimg);
std::vector<cv::Rect> brs;
cv::segmentMotion(mhi, segmask, brs, timestamp, segThresh);
CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvConnectedComp), storage);
CvConnectedComp comp;
memset(&comp, 0, sizeof(comp));
for( size_t i = 0; i < brs.size(); i++ )
{
cv::Rect roi = brs[i];
float compLabel = (float)(i+1);
int x, y, area = 0;
cv::Mat part = segmask(roi);
for( y = 0; y < roi.height; y++ )
{
const float* partptr = part.ptr<float>(y);
for( x = 0; x < roi.width; x++ )
area += partptr[x] == compLabel;
}
comp.value = cv::Scalar(compLabel);
comp.rect = roi;
comp.area = area;
cvSeqPush(seq, &comp);
}
return seq;
}
示例13: scale_space_extrema
/*
Detects features at extrema in DoG scale space. Bad features are discarded
based on contrast and ratio of principal curvatures.
@param dog_pyr DoG scale space pyramid
@param octvs octaves of scale space represented by dog_pyr
@param intvls intervals per octave
@param contr_thr low threshold on feature contrast
@param curv_thr high threshold on feature ratio of principal curvatures
@param storage memory storage in which to store detected features
@return Returns an array of detected features whose scales, orientations,
and descriptors are yet to be determined.
*/
CvSeq* scale_space_extrema( IplImage*** dog_pyr, int octvs, int intvls,
double contr_thr, int curv_thr, CvMemStorage* storage ) {
CvSeq* features;
double prelim_contr_thr = 0.5 * contr_thr / intvls;
struct feature* feat;
struct detection_data* ddata;
int o, i, r, c;
features = cvCreateSeq( 0, sizeof(CvSeq), sizeof(struct feature), storage );
for( o = 0; o < octvs; o++ )
for( i = 1; i <= intvls; i++ )
for(r = SIFT_IMG_BORDER; r < dog_pyr[o][0]->height-SIFT_IMG_BORDER; r++)
for(c = SIFT_IMG_BORDER; c < dog_pyr[o][0]->width-SIFT_IMG_BORDER; c++)
/* perform preliminary check on contrast */
if( ABS( pixval32f( dog_pyr[o][i], r, c ) ) > prelim_contr_thr )
if( is_extremum( dog_pyr, o, i, r, c ) ) {
feat = interp_extremum(dog_pyr, o, i, r, c, intvls, contr_thr);
if( feat ) {
ddata = feat_detection_data( feat );
if( ! is_too_edge_like( dog_pyr[ddata->octv][ddata->intvl],
ddata->r, ddata->c, curv_thr ) ) {
cvSeqPush( features, feat );
}
else
free( ddata );
free( feat );
}
}
return features;
}
示例14: read_num_class_data
// This function reads data and responses from the file <filename>
static int
read_num_class_data( const char* filename, int var_count,
CvMat** data, CvMat** responses )
{
const int M = 1024;
FILE* f = fopen( filename, "rt" );
CvMemStorage* storage;
CvSeq* seq;
char buf[M+2];
float* el_ptr;
CvSeqReader reader;
int i, j;
if( !f )
return 0;
el_ptr = new float[var_count+1];
storage = cvCreateMemStorage();
seq = cvCreateSeq( 0, sizeof(*seq), (var_count+1)*sizeof(float), storage );
for(;;)
{
char* ptr;
if( !fgets( buf, M, f ) || !strchr( buf, ',' ) )
break;
el_ptr[0] = buf[0];
ptr = buf+2;
for( i = 1; i <= var_count; i++ )
{
int n = 0;
sscanf( ptr, "%f%n", el_ptr + i, &n );
ptr += n + 1;
}
if( i <= var_count )
break;
cvSeqPush( seq, el_ptr );
}
fclose(f);
*data = cvCreateMat( seq->total, var_count, CV_32F );
*responses = cvCreateMat( seq->total, 1, CV_32F );
cvStartReadSeq( seq, &reader );
for( i = 0; i < seq->total; i++ )
{
const float* sdata = (float*)reader.ptr + 1;
float* ddata = data[0]->data.fl + var_count*i;
float* dr = responses[0]->data.fl + i;
for( j = 0; j < var_count; j++ )
ddata[j] = sdata[j];
*dr = sdata[-1];
CV_NEXT_SEQ_ELEM( seq->elem_size, reader );
}
cvReleaseMemStorage( &storage );
delete[] el_ptr;
return 1;
}
示例15: plot_scan_image
void plot_scan_image(IplImage* image, Two_dimensional_vector* scan_image)
{
CvSeq *points;
CvPoint pt;
CvMemStorage *storage = cvCreateMemStorage (0);
points = cvCreateSeq (CV_SEQ_ELTYPE_POINT, sizeof (CvSeq), sizeof (CvPoint), storage);
for (int i = 0; i < (int)scan_image->x.size(); i++) {
if(0 > scan_image->x[i] || scan_image->x[i] > 639) {
continue;
}
if(0 > scan_image->y[i] || scan_image->y[i] > 479) {
continue;
}
pt.x = scan_image->x[i];
pt.y = scan_image->y[i];
cvSeqPush (points, &pt);
cvCircle(image, pt, 2, CV_RGB (0, 255, 0), CV_FILLED, 8, 0);
}
cvClearSeq(points);
cvReleaseMemStorage(&storage);
}