我有兴趣从文件中读取 CvPoint* 类型的点,但我尝试了标准符号 (x,y)。当我尝试验证输出时,它给出了不正确的值。在文件中读取 CvPoint 的格式是什么。
点.txt
(1,1)
主文件
points = (CvPoint*)malloc(length*sizeof(CvPoint*));
points1 = (CvPoint*)malloc(length*sizeof(CvPoint*));
points2 = (CvPoint*)malloc(length*sizeof(CvPoint*));
fp = fopen(points.txt, "r");
fscanf(fp, "%d", &(length));
printf("%d \n", length);
i = 1;
while(i <= length)
{
fscanf(fp, "%d", &(points[i].x));
fscanf(fp, "%d", &(points[i].y));
printf("%d %d \n",points[i].x, points[i].y);
i++;
}
它打印:
1
12 0