I'm new to libgphoto2 and had some questions about where the actual image memory is located. It seems that photos are accessed via an object called a CameraFile
. There's an example included in the source called sample-capture.c that has a function called capture_to_memory
.
In that function, a CameraFile object is created and initialized using gp_file_new
. The implementation of gp_file_new
creates a CameraFile
object whose accesstype member is set to GP_FILE_ACCESSTYPE_MEMORY
.
That CameraFile
object is then passed to gp_camera_file_get
, and I'm not really clear what happens in this function.
After the call to gp_camera_file_get
, the file is sent to gp_file_get_data_and_size
. Looking at the implementation of that function, and given that the files accesstype is GP_FILE_ACCESSTYPE_MEMORY
, the gp_file_get_data_and_size
function will not allocate any memory and instead merely assign the pointer to the CameraFile's data member (same with size).
So where is the memory this pointer points to? Is it on the actual camera? Or is it somewhere in my ram? I'm just trying to avoid as many memory operations as possible. I've found a nice blog post
http://sepharads.blogspot.com/2011/11/camera-tethered-capturing-using.html?m=1
where the CameraFile
object is created via gp_file_new_from_fd
. This sets the files accesstype to GP_FILE_ACCESSTYPE_FD
. When gp_file_get_data_and_size
is called on a file with this accesstype, new memory is allocated and the file's data is copied into it. However, this is read from disk, or at least I assume it is since FD means Unix File Descriptor, and it needs an actual filename string. Does that mean that gp_camera_file_get
reads the data into a file on disk if the CameraFile's accestype is GP_FILE_ACCESSTYPE_FD
?
There is a function called gp_file_free
. If it's an FD file it closes the file handle, but it doesn't call free(file->data)
anywhere, so I'm pretty confused...
What does gp_camera_file_get
do? The implementation is there, but it kind of threw me. Does it actually bring the file from my camera's memory to my computer's memory and allocate CameraFile->data
in ram? Or does it just give me a handle to something stored on my camera?
Sorry if this is the wrong place to ask, I did see some sort of mailing list for libgphoto2 but I couldn't tell how active it was.