最終更新: mikk_ni3_92 2007年11月27日(火) 14:24:36履歴
現在地 >> メニュー >> サンプルコード::OpenCV >> OpenCV::シーケンス >> OpenCV::シーケンス2
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
#define NUM 3
int point_data[NUM][2]=
{
{150,200},
{50,100},
{250,100}
};
int main( int argc, char **argv)
{
static CvSize window_size={300,300};
IplImage *imgA = cvCreateImage(window_size,IPL_DEPTH_8U,3);
cvSet (imgA, cvScalarAll (255), 0);
CvMemStorage *storage1 = cvCreateMemStorage (0);
CvSeq *points;
points = cvCreateSeq (CV_SEQ_ELTYPE_POINT, sizeof (CvSeq), sizeof (CvPoint), storage1);
CvPoint *tmp;
tmp = new CvPoint;
int k;
for(k = 0; k < NUM;k++)
{
tmp->x = point_data[k][0];
tmp->y = point_data[k][1];
cvSeqPush (points, tmp);
}
for(k = 0; k<NUM;k++)
{
tmp = (CvPoint *)cvGetSeqElem( points, k );
cout << "tmp2.x " << tmp->x << endl;
cout << "tmp2.y " << tmp->y << endl;
}
cvNamedWindow("window",CV_WINDOW_AUTOSIZE);
cvShowImage("window",imgA);
cvWaitKey(0);
cvReleaseMemStorage( &storage1 );
delete tmp;
cvReleaseImage(& imgA);
cvDestroyWindow("window");
return 0;
}
#include <iostream>
#include <cv.h>
#include <highgui.h>
using namespace std;
#define NUM 3
int point_data[NUM][2]=
{
{150,200},
{50,100},
{250,100}
};
int main( int argc, char **argv)
{
static CvSize window_size={300,300};
IplImage *imgA = cvCreateImage(window_size,IPL_DEPTH_8U,3);
cvSet (imgA, cvScalarAll (255), 0);
CvMemStorage *storage1 = cvCreateMemStorage (0);
CvSeq *points;
points = cvCreateSeq (CV_SEQ_ELTYPE_POINT, sizeof (CvSeq), sizeof (CvPoint), storage1);
CvPoint *tmp;
tmp = new CvPoint;
int k;
for(k = 0; k < NUM;k++)
{
tmp->x = point_data[k][0];
tmp->y = point_data[k][1];
cvSeqPush (points, tmp);
}
for(k = 0; k<NUM;k++)
{
tmp = (CvPoint *)cvGetSeqElem( points, k );
cout << "tmp2.x " << tmp->x << endl;
cout << "tmp2.y " << tmp->y << endl;
}
cvNamedWindow("window",CV_WINDOW_AUTOSIZE);
cvShowImage("window",imgA);
cvWaitKey(0);
cvReleaseMemStorage( &storage1 );
delete tmp;
cvReleaseImage(& imgA);
cvDestroyWindow("window");
return 0;
}