I am trying to do an "obstacle detection program using laser" i am unable to obtain the output image

#include “highgui.h”
#include “cv.h”
#include
#include
#include
#include
IplImage frame=0,frame1=0,outp=0;
int count1 =0;
int output_mod(int u,int v,int wid,int hei) //function for editing
the output image
{
int i,j;
if(count1=0)
{
outp=cvCreateImage(cvGetSize(frame1),frame1->depth,frame1->nChannels);
for(i=0;i<=wid-35;i++)
{
for(j=0;j<=hei+30;j++)
{
((uchar )(outp->imageData + ioutp->widthStep))[j
outp->nChannels +0]=0;
((uchar )(outp->imageData + ioutp->widthStep))[j
outp->nChannels +1]=0;
((uchar )(outp->imageData + ioutp->widthStep))[j
outp->nChannels
+2]=0;
}
}
}
count1++;
for(i=0;i<=wid-35;i++)
{
for(j=0;j<=hei+30;j++)
{
if((i==u)&&(j==v)) //the deviation shown in stage 1(with
obatacle) gets detected
{
((uchar )(outp->imageData + ioutp->widthStep))[joutp->nChannels +0]=255;
((uchar )(outp->imageData + ioutp->widthStep))[j
outp->nChannels +1]=255;
((uchar )(outp->imageData + ioutp->widthStep))[j*outp->nChannels
+2]=255; }

}
}
return 0;
}
int ref_creator(void) //function for detection of obstacle
{
int i,j,wid,hei,ref_wid,ref_hei;
wid=frame1->width;
hei=frame1->height;
int Bl[hei+30],Gr[hei+30],Re[hei+30];
for(i=0;i<=wid-35;i++) //wid-35 for practical purposes
{
for(j=0;j<=hei+30;j++) //hei+30 for practical purposes
{
Bl[j]=((uchar )(frame1->imageData +
i
frame1->widthStep))[jframe1->nChannels +0];
Gr[j]=((uchar )(frame1->imageData +
i
frame1->widthStep))[j
frame1->nChannels +1];
Re[j]=((uchar )(frame1->imageData +
i
frame1->widthStep))[j*frame1->nChannels +2];

}
if((Bl[1]==255)&&(Re[1]==255)&&(Gr[1]==255))
{
if((Bl[hei]==255)&&(Re[hei]==255)&&(Gr[hei]==255))
{ //detect_ovr[i]=1;
for(j=0;j<=hei+30;j++)
{
if((Bl[j]==0)&&(Re[j]==0)&&(Gr[j]==0))
{
output_mod(i,j,wid,hei); //coordinates corresponding to the detection send
}
}

}
}

}
return 0;
}
int main(int argc,char** argv)
{
int i,j,hei,wid,Bl,Re,Gr,count;
count=0;
cvNamedWindow(“INPUT”,CV_WINDOW_AUTOSIZE);
cvNamedWindow(“MODIFIED INPUT”,CV_WINDOW_AUTOSIZE);
cvNamedWindow(“OUTPUT”,CV_WINDOW_AUTOSIZE); //window showing outp
CvCapture* capture=cvCreateCameraCapture(-1);
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 200 );
cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 200 );
cvSetCaptureProperty( capture, CV_CAP_PROP_FPS, 15.0 );
while(1)
{
frame=cvQueryFrame(capture);
if(!frame) break;
cvShowImage(“INPUT”,frame);
wid=frame->width;
hei=frame->height;
for(i=0;i<=wid-35;i++)
{
for(j=0;j<=hei+30;j++)
{

Bl=((uchar )(frame->imageData +
i
frame->widthStep))[jframe->nChannels +0]; // B
Gr=((uchar )(frame->imageData +
i
frame->widthStep))[j
frame->nChannels +1]; // G
Re=((uchar )(frame->imageData +
i
frame->widthStep))[jframe->nChannels +2]; // R
if((Re>200) && (Bl>200)&&(Gr>200)&&(Re>Bl)&&(Re>Gr))
//LASER LINE DETECTION
{ //for high red intensity white
((uchar )(frame->imageData +
i
frame->widthStep))[j
frame->nChannels +0]=255;
((uchar )(frame->imageData +
i
frame->widthStep))[jframe->nChannels +1]=255;
((uchar )(frame->imageData +
i
frame->widthStep))[j
frame->nChannels +2]=255;
//break;
}
else
{ //for others black
((uchar )(frame->imageData + iframe->widthStep))[jframe->nChannels +0]=0;
((uchar )(frame->imageData + iframe->widthStep))[j
frame->nChannels +1]=0;
((uchar )(frame->imageData + iframe->widthStep))[j*frame->nChannels +2]=0;
//break;
}

}
}
frame1 = cvCreateImage(cvGetSize(frame),frame->depth,frame->nChannels);
cvCopy(frame, frame1, NULL);
ref_creator();
count++;
cvShowImage(“MODIFIED INPUT”,frame1);
cvShowImage(“OUTPUT”,outp);
char c=cvWaitKey(20);
if(c==27) break;
}
//cvReleaseImage(&gray);
//cvReleaseImage(&edge);
//cvDestroyWindow(wndname);
cvReleaseCapture(&capture);
cvDestroyWindow(“INPUT”);
cvDestroyWindow(“MODIFIED INPUT”);
cvDestroyWindow(“OUTPUT”);
}

/* I am unable to obtain the final image as output instead im getting
a blank black image */

no obstacle.jpeg

with obstacle.jpeg

output.jpeg