Coder Social home page Coder Social logo

Comments (5)

Kevin-OConnor avatar Kevin-OConnor commented on June 14, 2024

getImage does not describe a unique method in AxisCamera. Can you please post a minimal sample that you are seeing an issue with?

from allwpilib.

nimrod46 avatar nimrod46 commented on June 14, 2024

@Kevin-OConnor
public HSLImage getImage() throws NIVisionException { HSLImage image = new HSLImage(); this.getImage(image); return image; }
lines 138 - 142;

from allwpilib.

Kevin-OConnor avatar Kevin-OConnor commented on June 14, 2024

That tells me which getImage but still does not tell me what you are doing with it. Can you please post a minimal sample that you are seeing an issue with?

from allwpilib.

nimrod46 avatar nimrod46 commented on June 14, 2024

@Kevin-OConnor Ohh, sorry.
Here you go:

`public newParticleAnalysisReport imageProcessing() {

    try {
        HSLImage inputImage = camera.getImage();
        Image processImage = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_U8, 0);

        /* Ranges for the HSV variables in the Threshold operation */
        NIVision.Range hueRange = new NIVision.Range(HUE_LOW, HUE_HIGH);
        NIVision.Range saturationRange = new NIVision.Range(SATURATION_LOW, SATURATION_HIGH);
        NIVision.Range valueRange = new NIVision.Range(VALUE_LOW, VALUE_HIGH);

        try {
            NIVision.imaqColorThreshold(processImage, inputImage.image, 255, NIVision.ColorMode.HSV, hueRange,
                    saturationRange, valueRange);

        } catch (Exception e) {
            e.printStackTrace();
        }

        /*
         * First filter operation of the Threshold image - "Particle Filter"
         */
        NIVision.ParticleFilterCriteria2[] criteria = new ParticleFilterCriteria2[2];
        criteria[0] = new ParticleFilterCriteria2(NIVision.MeasurementType.MT_AREA, MIN_AREA, MAX_AREA, 0, 0);
        criteria[1] = new ParticleFilterCriteria2(NIVision.MeasurementType.MT_RATIO_OF_EQUIVALENT_RECT_SIDES, 9, 15, 0, 0);

        ROI roi = NIVision.imaqCreateROI();
        ParticleFilterOptions options = new ParticleFilterOptions(0, 0, 1); 
        NIVision.imaqParticleFilter3(processImage, processImage, criteria[0], 1, options, roi);
        NIVision.imaqParticleFilter3(processImage, processImage, criteria[1], 1, options, roi);

        newBinaryImage binaryImage = new newBinaryImage();
        binaryImage.image = processImage;


        if (binaryImage.getNumberParticles() > 0) {
            particleArray = binaryImage.getOrderedParticleAnalysisReports(binaryImage.getNumberParticles());
            maxArea = particleArray[0].particleArea;
            particleReport = particleArray[0];
            for (newParticleAnalysisReport par : particleArray) {
                if (maxArea < par.particleArea) {
                    maxArea = par.particleArea;
                    particleReport = par;
                }
            }
        }   
    } catch (Exception e) {
        e.printStackTrace();
    }

    return particleReport;
}`

from allwpilib.

Kevin-OConnor avatar Kevin-OConnor commented on June 14, 2024

You are definitely running out of memory. Even if the destructor called free(), by the time the GC got around to actually freeing this memory you would likely have an issue anyway.

Either call free() on all of the images you are allocating or create one of each type as a static or in a scope where they won't go out of scope every time and re-use them (what I would recommend).

For 2017 this code is being removed from WPILib (but will still be available as an external module). The code is moving to this repo: https://github.com/wpilibsuite/nivision

from allwpilib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.