Some small problems about OpenCV4Android haze removal
I am a new of OpenCV4Android.I have a piece of code about OpenCV which written by C.I want to rewrite it in Android and use my cellphone to make it come ture.But some function I don't know why can't call ,for example cvSetImageROI();cvCopy();cvMinMaxLoc();cvSetImageROI();cvSet() etc.Who can teach me how to deal with it.
The whole code is blow
int block=5;
int w1=80;
double w;
IplImage *src=NULL;
IplImage *dst=NULL;
IplImage *quw(IplImage *src,int block,double w)
{
IplImage *dst1=NULL;
IplImage *dst2=NULL;
IplImage *dst3=NULL;
IplImage *imgroi1;
IplImage *imgroi2;
IplImage *imgroi3;
IplImage *roidark;
IplImage *dark_channel=NULL;
IplImage *toushelv=NULL;
IplImage *j1=NULL;
IplImage *j2=NULL;
IplImage *j3=NULL;
IplImage *dst=NULL;
CvRect ROI_rect;
dst1=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
dst2=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
dst3=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
imgroi1=cvCreateImage(cvSize(block,block),IPL_DEPTH_8U,1);
imgroi2=cvCreateImage(cvSize(block,block),IPL_DEPTH_8U,1);
imgroi3=cvCreateImage(cvSize(block,block),IPL_DEPTH_8U,1);
roidark=cvCreateImage(cvSize(block,block),IPL_DEPTH_8U,1);
j1=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
j2=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
j3=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
dark_channel=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
toushelv=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,1);
dst=cvCreateImage(cvSize(src->width,src->height),IPL_DEPTH_8U,3);
cvSplit(src,dst1,dst2,dst3,NULL);
ROI_rect.width=block;
ROI_rect.height=block;
ROI_rect.x=0;
ROI_rect.y=0;
int i;
int j;
double min1=0;
double max1=0;
double min2=0;
double max2=0;
double min3=0;
double max3=0;
double min=0;
CvScalar value;
for(i=0;i<src->width/block;i++)
{ for(j=0;j<src->height/block;j++)
{
cvSetImageROI(dst1,ROI_rect);
cvCopy(dst1,imgroi1,NULL);
cvMinMaxLoc(imgroi1,&min1,&max1,NULL,NULL);
cvSetImageROI(dst2,ROI_rect);
cvCopy(dst2,imgroi2,NULL);
cvMinMaxLoc(imgroi2,&min2,&max2,NULL,NULL);
cvSetImageROI(dst3,ROI_rect);
cvCopy(dst3,imgroi3,NULL);
cvMinMaxLoc(imgroi3,&min3,&max3,NULL,NULL);
if(min1<min2)
min=min1;
else
min=min2;
if(min>min3)
min=min3;
alar(min,min,min,min);
cvSetImageROI(dark_channel,ROI_rect);
cvSet(roidark,value,NULL);
cvCopy(roidark,dark_channel,NULL);
cvResetImageROI(dst1);
cvResetImageROI(dst2);
cvResetImageROI(dst3);
cvResetImageROI(dark_channel);
ROI_rect.x=block*i;
ROI_rect.y=block*j;
}
}
cvSaveImage("f:/dark_channel_prior.jpg",dark_channel);
double min_dark;
double max_dark;
CvPoint min_loc;
CvPoint max_loc;
cvMinMaxLoc(dark_channel,&min_dark,&max_dark,&min_loc,&max_loc,NULL);
cout<<max_loc.x<<" "<<max_loc.y<<endl;
ROI_rect.x=max_loc.x;
ROI_rect.y=max_loc.y;
double A_dst1;
double dst1_min;
double A_dst2;
double dst2_min;
double A_dst3;
double dst3_min;
cvSetImageROI(dst1,ROI_rect);
cvCopy(dst1,imgroi1,NULL);
cvMinMaxLoc(imgroi1,&dst1_min,&A_dst1,NULL,NULL);
cvSetImageROI(dst2,ROI_rect);
cvCopy(dst2,imgroi2,NULL);
cvMinMaxLoc(imgroi2,&dst2_min,&A_dst2,NULL,NULL);
cvSetImageROI(dst3,ROI_rect);
cvCopy(dst3,imgroi3,NULL);
cvMinMaxLoc(imgroi3,&dst3_min,&A_dst3,NULL,NULL);
cout<<A_dst1<<" "<<A_dst2<<" "<<A_dst3<<endl;
int k;
int l;
CvScalar m;
CvScalar n;
for(k=0;k<src->height;k++)
{for(l=0;l<src->width;l++)
{
m=cvGet2D(dark_channel,k,l);
n=cvScalar(255-w ...
Please sir ...
Thank you for your comments. My main question I don't know how to switch the code to C++ API,because my English is not good enough to read the official documents.
Let me give you a hand! Just a sec please.
"The whole code is blow" - well, indeed ;(