Home > Software engineering >  For help for loop only once, can't find where is the problem?
For help for loop only once, can't find where is the problem?

Time:10-05

The for loop in the process of implementation for the first time, getEyeCornerLbp256or59 () function performs, file - & gt; Num becomes a big negative, before this function performs the program file - & gt; The value of num is very normal, refers to the folder in the number of images, for help and couldn't find the problem in a day and little sister words in this grateful,,,
 
Void savePartFeature256or59 (char * img_folder_path, char * point_folder_path, char * lbp_folder_path, radius, int, int "orientation, int thread_value, int the pattern)
{
ApDirInfo * file;
Char suffix [5]={" JPG "};//image file suffix
Int num_feature;
Int fnum;
The FILE * LBPF;

The FILE * fp1;//11.18
Int k, t;//Zhang Li add
Int j;
Img IplImage *;
File_name file_name_total//char * and * and * point_name * point_name_total;
Char * file_name_total, * point_name_total;
Char * point_name;
Struct CvPoint2D32f * image_point;
Double * faceratio;//face proportion
Double * fhdata;//the forehead part feature
Double * fcdata;//cheek part feature
Double * ecdata;//corner part feature

Faceratio=(double *) calloc (6, sizeof (double));
If (the pattern==1) {num_feature=59; }
Else if (pattern==2) {num_feature=16; }//CSLBP mode
The else {num_feature=256; }
Fhdata=https://bbs.csdn.net/topics/(double *) calloc (num_feature, sizeof (double));
Fcdata=https://bbs.csdn.net/topics/(double *) calloc (num_feature, sizeof (double));
Ecdata=https://bbs.csdn.net/topics/(double *) calloc (num_feature, sizeof (double));
File_name_total=(char *) calloc (FILE_NAME_LENGTH, sizeof (char));
Point_name_total=(char *) calloc (FILE_NAME_LENGTH, sizeof (char));

Image_point=(struct CvPoint2D32f *) calloc (POINT_NO, sizeof (struct CvPoint2D32f));

The file=(ApDirInfo *) calloc (1, sizeof (ApDirInfo));//allocate space, pay attention to allocate enough memory
The file=apDirFiles (img_folder_path, suffix);//read the folder information, including the file name and file number

LBPF=fopen (lbp_folder_path, "w");
If (LBPF==NULL)
{
Printf (" fopen file not open! \n");
exit(1);
};
Fprintf (LBPF, "pictureNum=% d \ n", file - & gt; Num);//

For (fnum=1; Fnum{
Printf (" are extracted first \ n % d picture ", fnum);
//file_name=file - & gt; The name [fnum];
Sprintf (file_name_total, "% s % s", img_folder_path, file - & gt; The name [fnum]);
//here to calculate the full path that dot file out
Point_name=(char *) calloc (strlen (file - & gt; The name [fnum]), sizeof (char));
//apChangeSuffix (file - & gt; The name [fnum], point_name, "PTS");//according to the image file name, by changing the filename suffix get feature points
//point_name [3]='a';//picture of the fourth to uppercase, feature point in the file name to lower case, here with the
//sprintf (point_name_total, "% s % s", point_folder_path, point_name);//in the end get feature points file comspec point_name

//2013.11.18 morning Zhang Ligai
ApChangeSuffix (file - & gt; The name [fnum], point_name, ". TXT ");//according to the image file name, by changing the filename suffix get feature points
Point_name [3]='a';//picture of the fourth to uppercase, feature point in the file name to lower case, here with the
Sprintf (point_name_total, "% s % s", point_folder_path, point_name);//in the end get feature points file comspec point_name

Fp1=fopen (point_name_total, "r");
Fscanf (fp1, "\ n points: % d", & amp; T);
For (k=0; K<68; K++)
{
The fscanf (fp1, "% f", & amp; Image_point [k]. X);
The fscanf (fp1, "% f", & amp; Image_point [k]. Y);
}
The fclose (fp1);

Img=cvLoadImage (file_name_total, 0);

//ImgePoint68 (point_name_total image_point);//read 68 points
//computing feature
GetFaceRatio (image_point faceratio);
GetForheadLbp256or59 (fhdata, img, image_point, radius, orientation, thread_value, pattern).
//getEyeCornerLbp256or59 (ecdata, img, image_point, radius, orientation, thread_value, pattern).
GetFaceCheekLbp256or59 (fcdata, img, image_point, radius, orientation, thread_value, pattern).
GetEyeCornerLbp256or59 (ecdata, img, image_point, radius, orientation, thread_value, pattern).
For (j=0; j<6; J++) {fprintf (LBPF, "% 6.4 f \ t," faceratio [j]); } fprintf (LBPF, "\ n");
For (j=0; jFor (j=0; jFor (j=0; j
//free (point_name);

}
Printf (" over... ");
The fclose (LBPF);
//free (point_name);
Free (faceratio);
Free (fhdata);
Free (fcdata);
Free (ecdata);
Free (image_point);
Free (file_name_total);
Free (point_name_total);
//free (point_name);
CvReleaseImage (& amp; Img);//release image data
ApReleaseMatrix2Dc (file - & gt; The name of the file - & gt; Num);
Free (file); The file=NULL;
}

CodePudding user response:

GetEyeCornerLbp256or59 this function to deal with if there is a problem, or your arguments such as incorrect, causing it to modify or cross-border written into the garbage data

CodePudding user response:

Try variable initialization

CodePudding user response:

Down again, the code commented out part of the code, and see what the problem is in place, to pinpoint which code or draw out first on which a few words, it is good for you to solve the problem

CodePudding user response:

Point_name [3]='a'; "a"??????
  • Related