For the OpenCV version, the problem is in allocating more memory for filenames.
In the libjpeg version, the problem is in freeing some memory for filenames.
These both imply malloc() isn't able to get enough memory, are you running on a resource-constrained system?
I'll freely admit I have no experience reading in directories and managing string memory for such a task. Perhaps I'm doing something horrible in the code.
----
My first concern, however, isn't that my code runs well, it's that the user (i.e. you) can perform the action you've set out to do. Since you're using a Linux system, I can reach for the easy solution, which is to let the OS and shell handle directory and filename recursion. Following is a bash script (and supporting files) to do so:
http://www.mattikariluoma.com/files/rot ... ipt.tar.gz
Inside that archive are three files (in a directory): rotateall.sh, jpeg_rotate.c, and opencv_rotate.cpp
Either jpeg_rotate.c or opencv_rotate.cpp file can be compiled to make the executable "rotate"
Code: Select all
gcc -lm -ljpeg jpeg_rotate.c -o rotate
# OR
g++ opencv_rotate.cpp -I /usr/include/opencv -lcv -lhighgui -o rotate
The usage:
Code: Select all
./rotate
Usage: ./rotate <input-filename> <degrees-clockwise> <output-filename>
Now then, when we run the "rotateall.sh" command, it will look for this "rotate" executable
(it looks in the same directory where "rotateall.sh" is located) and apply it in an equivalent way as my earlier "rotateall" executables.
As a bonus, the execution is even faster, down to .02 sec per image (43X faster!?), although I think my "time" utility might be lying to me.
If this still fails, I'll just re-write that damn imagemagick script.