一次顯示圖片

#include "StdAfx.h"
#include <stdio.h>
#include <iostream>
#include <cv.h>
#include <ml.h>
#include <cxcore.h>
#include <highgui.h> 
#include <afx.h>
#include <string>


int ShowImage(const char *imagename)
{
	IplImage * image = cvLoadImage(imagename,1);
	if(!image)
		return 0;
	cvNamedWindow(imagename,1);
	cvShowImage(imagename,image);
	cvWaitKey(0);
	cvReleaseImage(&image);
	cvDestroyWindow(imagename);
	return 1;
}
void FindJpgFile(const char *dripath,int &num)
{
	CFileFind findjpg;
	CString jpgpath,s;
	const char * here;
	jpgpath.Format(_T("%s\\*.jpg"),dripath);
	 
	bool done = findjpg.FindFile(jpgpath);
	while(done)
	{
		done = findjpg.FindNextFile();
		if(findjpg.IsDirectory() || findjpg.IsDots())
			continue;
		s = findjpg.GetFilePath();
		here = (LPSTR)(LPCTSTR) s;
		num+=ShowImage(here);
	}
}


void FindDir(const char *picture,int &num)
{
	CFileFind find;
	CString path;
	CString s;
	const char * dirpath;
	path.Format(_T("%s\\*.*"),(LPSTR)(LPCTSTR)picture);
	bool done = find.FindFile(path);
	while(done)
	{
		done = find.FindNextFile();
		if(!find.IsDirectory()|| find.IsDots())
			continue;
		s = find.GetFilePath();
		dirpath = (LPSTR)(LPCTSTR) s;
		FindJpgFile(dirpath,num);
	}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章