Just thought one of you might be able to give me some advise on coding a good real-time camera logger (i.e. save images with timestamps). FYI I'm using OpenCV to grab frames and save images.
I've coded up a few versions:
1) uses a fork, where the child process does a cvSaveImage() and then _exit(). NOTE I'm doing signal(SIGCLD, SIG_IGN) so the parent doesn't have to wait for the child.
2) uses a pthread, where the thread does the cvSaveImage() and then pthread_exit()
3) saves the images in an array and after getting X images, goes though each and does a cvSaveImage().
4) one which does the cvGrabFrame() and the cvSaveImage() all in one loop.
With these methods I get the following fps:
1) Since the main loop parent process takes up most of the CPU, the child process doing cvSaveImage() takes a while, so the fps drop over time (starts at 20fps and drops to 5fps over time). I tried slowing up the main loop with a usleep(10000) but that didn't help.
2) Same as (1)
3) As you can guess, this just ramps up the memory over time, so the fps drops over time too. However its the fastest method, getting 20fps for a long period of time (well for 2min's or so - depending on how much memory the machine I'm using at the time has).
4) I only get 2fps doing that, as one would expect.