Array2DFloat *.

I'm trying to access a function in a DLL that needs a float * input.

cvCreateHist( int dims, int* sizes, int type, float** ranges CV_DEFAULT(NULL),  int uniform CV_DEFAULT(1));

In labviews´s call library feature at the entrance of a 2D Array like this can only choose table handle.

This puts an Array2DFloat in turn * struct in the input parameters.

uint32_t cvCreateHist(int32_t dims, int32_t *sizes, int32_t type, Array2DFloat **ranges, int32_t uniform);

How or where exactly is Array2DFloat * defined?

You don't want to use the table handle (and, at least in LabVIEW 2012, I don't see the limited options to manage table).

You can see how this setting should be set, if you were to use it as such, call library function node right-click and selecting "Create C files." The type of parameter will be named differently, but will be set correctly in the file created. Note that it will not be a standard C array, so this isn't what you want.

The best thing to do here would be to write a new DLL, containing a wrapper function, which expects an array 1 d of LabVIEW and converts it into 2D table provided by the DLL, and then calls the DLL function. If you want to do purely in LabVIEW, see this thread: https://lavag.org/topic/14642-passing-array-of-string-to-c-dll/

Tags: NI Software

Similar Questions

  • When to call DSDisposeHandle when you have a DLL function acting as a dynamic data DS source extensible?

    Hello

    I have a dynamic function DLL acting as a data source within a LabVIEW application (see attachment) - I use DSNewHandle to dynamically allocate an array 2D handle storage via the Manager memory LV for arrays of arbitrary in application size data. I had assumed that these blocks of memory would be willing (Magic) when appropriate by the LabVIEW built in blocks that are sitting downstream, however, is not the case for treatment and the system LabVIEW memory usage continues to increase until you quit LabVIEW environment (not just if the offending application is stopped or closed).

    So my question is how and where to mop up the table used for buffers in the treatment of the application of the chain and how do I know when the buffers are really exhausted and not be re-used downstream (for instance two 2D paintings are first grouped into a 2D complex table by the re + im at the operator complex labview - is data memory out of this totally different stage of entries or is - a) modified version of the entry tables - if they are totally different and 2D to entry tables are not wired in all other blocks why the operator not have input data banks?)

    Maybe Im going to this topic in the wrong direction have the DLL data source dynamically allocates space data tables? Any advice would be welcome

    Concerning

    Steve

    So instead of doing:

    DLLEXPORT int32_t DataGetFloatDll(... , Array2DFloat ***p_samples_2d_i, ...)
    {
        ...
    
        if ( p_samples_2d_i )
        {        // *p_samples_2d_i can be non NULL, because of performance optimization where LabVIEW will pass in the same handle        // that you returned in a previous call from this function, unless some other LabVIEW diagram took ownership of the handle.        // Your C code can't really take ownership of the handle, it owns the handle for the duration of the function call and either        // has to pass it back or deallocate it (and if you deallocate it you better NULL out the handle before returning from the        // function or return a different newly allocated handle. A NULL handle for an array is valid and treated as empty array.
            *p_samples_2d_i = (Array2DFloat **) DSNewHandle( ( sizeof(int32_t) * 2 ) + ( sizeof(float) * channel_count * sample_count ) );
    
            // Generally you should first try to insert the data into the array before adjusting the size        // the most safe would be to adjust the size after filling in the data if the array gets bigger in respect to the passed in array        // and do the opposite if the adjusted handle happened to get smaller. This is only really important though if your C code can        // bail out of the code path because of error conditions between adjusting the handle size and adjusting the array sizes.        // You should definitely avoid to return from this function with the array dimensions indicating a bigger size than what the        // handle really is allocated for, which can happen if the array was resized to a smaller size and you then return because of errors        // before adjusting the dimension sizes in the array.         ........        (**p_samples_2d_i)->Rows = channel_count;
            (**p_samples_2d_i)->Columns = sample_count;
        }
    
        ...}
    

    You should do:

    DLLEXPORT int32_t DataGetFloatDll(... , Array2DFloat ***p_samples_2d_i, ...)
    {
        ...
        MgErr err = NumericArrayResize(fS /* array of singles */, 2 /* number of dims */, (UHandle*)p_samples_2d_i, channel_count * sample_count);
        if (!err)
        {        // Fill in the data somehow
           .....       
    
            // Adjust the dimension sizes        (**p_samples_2d_i)->Rows = channel_count;
            (**p_samples_2d_i)->Columns = sample_count;
        }
    
        ...}
    

Maybe you are looking for