gpt4 book ai didi

c++ - 在ubuntu中使用Opencv编译警告

转载 作者:行者123 更新时间:2023-11-27 23:20:41 26 4
gpt4 key购买 nike

亲爱的社区,最近我一直在学习一些 Opencv,我发现眼动追踪的东西很有趣,所以我找到了一个入门源代码,但是当我尝试编译它时,我收到了这个警告:

ojos2.cpp:15:5: 警告:“int main(int*, char**)”的第一个参数应该是“int”[-Wmain]

更清楚地说,我是从 Ubuntu 终端编译的,这是代码

#include "cv.h"

#include"highgui.h"

IplImage* GetThresholdedImage(IplImage* img)
{

IplImage *imgHSV=cvCreateImage(cvGetSize(img),8,3);
cvCvtColor(img,imgHSV,CV_BGR2HSV);
IplImage *imgThresh=cvCreateImage(cvGetSize(img),8,1);
cvInRangeS(imgHSV,cvScalar(0, 84, 0, 0),cvScalar(179, 256, 11, 0),imgThresh);
cvReleaseImage(&imgHSV);
return imgThresh;
}

int main(int *argv,char **argc)
{

IplImage *imgScribble= NULL;
char c=0;
CvCapture *capture;
capture=cvCreateFileCapture("main.avi");

if(!capture)
{
printf("Camera could not be initialized");
exit(0);
}
cvNamedWindow("Simple");
cvNamedWindow("Thresholded");

while(c!=32)
{
IplImage *img=0;
img=cvQueryFrame(capture);
if(!img)
break;
if(imgScribble==NULL)
imgScribble=cvCreateImage(cvGetSize(img),8,3);

IplImage *timg=GetThresholdedImage(img);
CvMoments *moments=(CvMoments*)malloc(sizeof(CvMoments));
cvMoments(timg,moments,1);

double moment10 = cvGetSpatialMoment(moments, 1, 0);
double moment01 = cvGetSpatialMoment(moments, 0, 1);
double area = cvGetCentralMoment(moments, 0, 0);

static int posX = 0;
static int posY = 0;

int lastX = posX;
int lastY = posY;

posX = moment10/area;
posY = moment01/area;
// Print it out for debugging purposes
printf("position (%d,%d)\n", posX, posY);
// We want to draw a line only if its a valid position
if(lastX>0 && lastY>0 && posX>0 && posY>0)
{
// Draw a yellow line from the previous point to the current point
cvLine(imgScribble, cvPoint(posX, posY), cvPoint(lastX, lastY), cvScalar(0,255,255), 5);
}
// Add the scribbling image and the frame...

cvAdd(img, imgScribble, img);

cvShowImage("Simple",img);
cvShowImage("Thresholded",timg);
c=cvWaitKey(3);
cvReleaseImage(&timg);
delete moments;

}
//cvReleaseImage(&img);
cvDestroyWindow("Simple");
cvDestroyWindow("Thresholded");
}

任何帮助都是有用的

提前致谢

最佳答案

原型(prototype)应该是int main (int argv, char *argc[]),主要是指向argv的指针是错误的——char **argcchar *argc[] 是同一件事的两种说法,但是写成字符数组的指针比写成字符数组的指针更清楚一个指针。

关于c++ - 在ubuntu中使用Opencv编译警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13224789/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com