visual studio+opencv 读取位置 0x02904000 时发生访问冲突。在第一个for循环出错,求助~~
intmain(intargc,char**argv){intheight,nstep,width,sumterm=0;floatg,c;inti,j;float*hda...
int main( int argc, char** argv )
{
int height, nstep, width, sumterm=0;
float g,c;
int i,j;
float *hdata,*sdata, *vdata;
IplImage *frame =cvLoadImage("F://camera1.jpg",1);
IplImage *framrs=cvCreateImage(cvSize(640,480),frame->depth,frame->nChannels);
IplImage *framed=cvCreateImage(cvGetSize(framrs),frame->depth,frame->nChannels);
IplImage *frameh=cvCreateImage(cvGetSize(framrs),frame->depth,1);
IplImage *frames=cvCreateImage(cvGetSize(framrs),frame->depth,1);
IplImage *framev=cvCreateImage(cvGetSize(framrs),frame->depth,1);
cvResize(frame,framrs,CV_INTER_NN);
//cvConvertScale(frame,framrs,1/255.0,0.0);
cvCvtColor(framrs,framed,CV_RGB2HSV);
cvSplit(framed,frameh,frames,framev,NULL);
cv::TickMeter tm;
tm.start();
hdata = (float *)frameh->imageData;
sdata = (float *)frames->imageData;
vdata = (float *)framev->imageData;
height = frame->height;
width = frame->width;
nstep = width;
//char* vdata = (char *) frame->imageData;
g=15;c=0.3;
float max=0.1, min=100000;
for(i=0;i<=height;i++){for(j=0;j<=width;j++)
{ if (min> vdata[i*nstep+j]){
min= vdata[i*nstep+j];}
}}
for(i=0;i<=height;i++) {for(j=0;j<=width;j++)
{vdata[i*nstep+j]=vdata[i*nstep+j]-min;
}
}
for(i=0;i<=height;i++){for(j=0;j<=width;j++)
{ if (max> vdata[i*nstep+j]){
max= vdata[i*nstep+j];}
}}
for(i=0;i<=height;i++) {for(j=0;j<=width;j++)
{
vdata[i*nstep+j]=vdata[i*nstep+j]/max;
vdata[i*nstep+j]=1/(1+exp(g*(c-vdata[i*nstep+j])));}
}
。。。。 展开
{
int height, nstep, width, sumterm=0;
float g,c;
int i,j;
float *hdata,*sdata, *vdata;
IplImage *frame =cvLoadImage("F://camera1.jpg",1);
IplImage *framrs=cvCreateImage(cvSize(640,480),frame->depth,frame->nChannels);
IplImage *framed=cvCreateImage(cvGetSize(framrs),frame->depth,frame->nChannels);
IplImage *frameh=cvCreateImage(cvGetSize(framrs),frame->depth,1);
IplImage *frames=cvCreateImage(cvGetSize(framrs),frame->depth,1);
IplImage *framev=cvCreateImage(cvGetSize(framrs),frame->depth,1);
cvResize(frame,framrs,CV_INTER_NN);
//cvConvertScale(frame,framrs,1/255.0,0.0);
cvCvtColor(framrs,framed,CV_RGB2HSV);
cvSplit(framed,frameh,frames,framev,NULL);
cv::TickMeter tm;
tm.start();
hdata = (float *)frameh->imageData;
sdata = (float *)frames->imageData;
vdata = (float *)framev->imageData;
height = frame->height;
width = frame->width;
nstep = width;
//char* vdata = (char *) frame->imageData;
g=15;c=0.3;
float max=0.1, min=100000;
for(i=0;i<=height;i++){for(j=0;j<=width;j++)
{ if (min> vdata[i*nstep+j]){
min= vdata[i*nstep+j];}
}}
for(i=0;i<=height;i++) {for(j=0;j<=width;j++)
{vdata[i*nstep+j]=vdata[i*nstep+j]-min;
}
}
for(i=0;i<=height;i++){for(j=0;j<=width;j++)
{ if (max> vdata[i*nstep+j]){
max= vdata[i*nstep+j];}
}}
for(i=0;i<=height;i++) {for(j=0;j<=width;j++)
{
vdata[i*nstep+j]=vdata[i*nstep+j]/max;
vdata[i*nstep+j]=1/(1+exp(g*(c-vdata[i*nstep+j])));}
}
。。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询