OPENCV converts an image to a specified format.
// TrainingFaceSegment. cpp: defines the entry point of the console application. // # Include "stdafx. h "# include <windows. h> # include <iostream> # include <string> # include "cv. h "# include" highgui. h "IplImage * img; IplImage * resizeImg; void find (char * lpPath) {char szFile [MAX_PATH] = {0}; char szFind [MAX_PATH]; char root [MAX_PATH]; WIN32_FIND_DATA FindFileData; strcpy (szFind, lpPath); strcat (szFind ,"*. * "); HANDLE hFind =: FindFirstFile (szFind, & FindFileData); if (INVALID_HANDLE_VALUE = hFind) retu Rn; while (TRUE) {if (FindFileData. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {if (FindFileData. cFileName [0]! = '. ') {Strcpy (szFile, lpPath); strcat (szFile, FindFileData. cFileName); strcat (szFile, "//"); find (szFile) ;}} else {strcpy (root, lpPath); strcat (root, FindFileData. cFileName); img = cvLoadImage (root); strcpy (root ,".. //.. // images2 // "); strcat (root, FindFileData. cFileName); cvSaveImage (root, img); cvReleaseImage (& img);} if (! FindNextFile (hFind, & FindFileData) break;} FindClose (hFind);} void main () {find (".. //.. // images // "); getchar ();}
strcat(root,FindFileData.cFileName);
Change the cfilenameof the sentence to the desired format, such as jpg.bmp.