XIMEA xiGetImage() fails and returns 11 (XI_INVALID_ARG) on xiQ USB3 Camera

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!

2 replies
  1. Chris
    Chris says:


    This just fixed a problem I’ve been struggling with for an hour.

  2. Guest
    Guest says:

    Do you accidentally have an idea why there could be error 10(timeout) with the same function? The rest of the API seems to work fine…

Comments are closed.