Go to Post oh, the prom! I thought you were missing a PROM (Programable Read Only Memory) ...you had me worried for a minute, I dont know if IFI has any spare PROMs. - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 09-02-2012, 10:44
derekwhite's Avatar
derekwhite derekwhite is offline
Java Virtual Machine Hacker
no team (FIRST@Oracle)
Team Role: Programmer
 
Join Date: May 2009
Rookie Year: 2009
Location: Burlington, MA
Posts: 127
derekwhite is on a distinguished road
Re: MemPartAlloc Error When Trying to Access the NIVision Library

I found a memory leak in NIVision.particleFilter(). I believe WPI is working on it...

If you feel daring, you could modify WPILibJ's NIVision class (sunspotfrcsdk/lib/WPILibJ/src/edu/wpi/first/wpilibj/image/NIVision.java) with this UNTESTED FIX:


Code:
    /* THIS IS AN UNTESTED FIX */
    public static int particleFilter(Pointer dest, Pointer source, CriteriaCollection collection) throws NIVisionException {
        Pointer particleFilterOptions = new Pointer(16);
        particleFilterOptions.setInt(0, 0);
        particleFilterOptions.setInt(4, 0);
        particleFilterOptions.setInt(8, 0);
        particleFilterOptions.setInt(12, 1);
        IntByReference i = new IntByReference(0);
        Pointer criteriaArray = collection.getCriteriaArray();
        assertCleanStatus(imaqParticleFilter4Fn.call7(dest.address().toUWord().toPrimitive(),   // dest image
                                                    source.address().toUWord().toPrimitive(),   // source image
                                                    criteriaArray.address().toUWord().toPrimitive(),  // array of criteria
                                                    collection.getNumberOfCriteria(),           // number of criteria in the array
                                                    particleFilterOptions.address().toUWord().toPrimitive(),  // particle filter options
                                                    0,                                          // Region of interest
                                                    i.getPointer().address().toUWord().toPrimitive()));  // returned number of particles
        int numberOfParticles = i.getValue();
        i.free();
        criteriaArray.free();
        particleFilterOptions.free();
        return numberOfParticles;
    }
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi