If you are having problems with xiGetImage() sometimes failing and returning an error value of XI_INVALID_ARG (11) then it may be due to the state of the XI_IMG structure that you are passing into the call (the image pointer argument).
The image object’s .size parameter must be set to sizeof(XI_IMG) and must not be 0. This is not really discussed in the XIMEA API documentation, but if it is left at 0 then the call will fail (however it doesn’t see to have to be sizeof(XI_IMG) for the call to work).
So xiGetImage() should be called like this:
XI_IMG image; image.size = sizeof(XI_IMG); // Must initialise the .size field auto res = xiGetImage(handle, timeout, &image);
If you don’t initialize the .size field then you may get occasional fails depending on how the image struct is declared, for example if it is declared as a local variable on the stack then an un-initialised image struct will have random-ish values, the .size field is unlikely to be zero, but it may occasionally be zero and when it is the acquisition will fail.
If however, the image struct is declared as a file static variable then it will always be initialised to 0, .size will always be 0 and the acquisition will always fail!
So remember to always initialise it and you will save yourself lots of head-scratching!