Hey thanks for the feedback.
Im working in windows 7 using visual studio 2010.
Originally Posted by
MWAAAHAAA
Use the right tool for the right job; use a shell script in this case.
Originally Posted by
ssharish2005
Have a read the
FAQ for files and directory handling.
ssharish
Im using windows from what I read about Shell scripts and from what I read in the faq Im not sure if they apply, unistd wouldn’t work in my #include for example.
I could be wrong though if I am let me know .
Originally Posted by
grumpy
In C++, the approach to do this is specific to the operating system.
If doing this under windows, look up the functions FindFirstFile() and FindNextFile() in the win32 API.
Under most (I'd hesitate to say all) flavours of unix, look up the functions findfirst() and findnext().
You might also try the boost filesystem library (look up the directory_iterator class). There are trade-offs with using that library, but it does aim for portability - and is/was the basis for a proposal to include such functionality in a future C++ standard (I'm not sure of the status of that, offhand - I seem to recall some concerns with an "illusion of portability" in discussion).
This is where most of my attention has been the last 2 days trying to use these functions with opencv.
Now I can pull all the files in my folder but they are not feeding into my cvLoadImage function.
Can anyone see what I may be doing wrong?
Code:
void findf()
{
//directory varibles
LPCTSTR lpFileName;
HANDLE hfind1;
TCHAR hj;
//opencv image
IplImage* Image;
//string and char array
string name;
char name1[100];
//counters
int i=0;
int q=0;
//not my real directory but my path name is correct, and pulling the bmp files
lpFileName=TEXT("c:/mydir");
WIN32_FIND_DATA FileData;
hfind1=FindFirstFile(lpFileName,&FileData);
do{
q++;
//print out file name
_tprintf(FileData.cFileName);
cout<<" "<<q<<"\n ";
//this puts the cFileName into a char array name1
do {
name1[i]=(1,FileData.cFileName[i]);
//up i
i++;
}
while(FileData.cFileName[i]!=0);
//once we have out name1, bring i to 0 once more
cout<<name1<<" \n";
//here images are inputted ,but not been displayed
Image=cvLoadImage(name1);
cvShowImage("new",Image);
// release the image
cvReleaseImage(&Image);
//return i to 0 and clear the name1 array
for(i;i!=-1;i--)
{
//clear name1 array
name1[i]=0;
}
}
//find the next file
while(FindNextFile(hfind1,&FileData)!=0);
//close the hfind
FindClose(hfind1);
}
Also on another note I noticed 2 files called
. and ..
are these just back tracks to the folder before hand, i managed to discard them using the wild card operator *?