First of all, I am new to C++. I am using Visual Studio 2010. I worked on a project that includes an camera. Camera send an image(bitmap) to a specific folder location in my computer. I want to monitor the directory consistenly. When a new bitmap image is obtained in the directory, I want to process this image. The code that I want to use is always monitoring the directory and read the last bitmap image in this directory. What can I use to achieve it? What is your suggestions? Could you write the source code? Thanks for your interest.
Asked
Active
Viewed 155 times
0
-
3Can you show us what you have tried? – newbie Apr 22 '15 at 21:10
-
I am processing the image by using the code as follow: frame = cvLoadImage("test17.bmp",CV_LOAD_IMAGE_GRAYSCALE); However; I do not want to read image by typing its name. I want to monitor a directory and when an image is added to the directory, I want to read this image. Does it help you to understand what I tried to do? – erhertan Apr 22 '15 at 21:47
-
I think it is probably duplicated with this question: http://stackoverflow.com/questions/61253/how-to-be-notified-of-file-directory-change-in-c-c-ideally-using-posix and this question: http://stackoverflow.com/questions/931093/how-do-i-make-my-program-watch-for-file-modification-in-c – newbie Apr 22 '15 at 21:54
2 Answers
1
The Windows ReadDirectoryChangesW API can be used to monitor a directory for added files. However, it is very advanced and if you are new to C++ and Windows programming it is probably beyond what you can achieve. You will need some experienced help.

ScottMcP-MVP
- 10,337
- 2
- 15
- 15
0
I dont agree with the other guy who answered the question, it can be done eaisly with some co-existing libraries that I used below, This code does what you are looking for,
string processName()
{
FILETIME bestDate = { 0, 0 };
FILETIME curDate;
string name;
CFileFind finder;
BOOL bWorking = finder.FindFile("*.png");
while (bWorking)
{
bWorking = finder.FindNextFile();
// date = (((ULONGLONG) finder.GetCreationTime(ft).dwHighDateTime) << 32) + finder.GetCreationTime(ft).dwLowDateTime;
finder.GetCreationTime(&curDate);
if (CompareFileTime(&curDate, &bestDate) > 0 )
{
bestDate = curDate;
name = finder.GetFileName().GetString();
// name = (LPCTSTR) finder.GetFileName();
}
}
return name;
}
Here I wrote it for the code you, it takes the name of the last entered /.png extension you can check libray for it.
Please tell me for further question

Elektrik Adam
- 58
- 1
- 6