001    /*----------------------------------------------------------------------------*/
002    /* Copyright (c) FIRST 2008-2012. All Rights Reserved.                        */
003    /* Open Source Software - may be modified and shared by FRC teams. The code   */
004    /* must be accompanied by the FIRST BSD license file in the root directory of */
005    /* the project.                                                               */
006    /*----------------------------------------------------------------------------*/
007    
008    package edu.wpi.first.wpilibj.image;
009    
010    import com.sun.cldc.jna.Structure;
011    
012    /**
013     *
014     * @author dtjones
015     */
016    public class ShapeDetectionOptions extends Structure{
017    
018        int mode; //unsigned int  Specifies the method used when looking for the shape in the image. Combine values from the GeometricMatchingMode enumeration to specify the value of this element.
019        int angleRanges; //RangeFloat*  An array of angle ranges, in degrees, where each range specifies how much you expect the shape to be rotated in the image. To decrease the search time, limit the degrees of rotation in which you expect to find the shape in the image. Set this element to NULL to allow all angles. This function ignores this range if mode does not include IMAQ_GEOMETRIC_MATCH_ROTATION_INVARIANT.
020        int numAngleRanges;  //int  The size of the orientationRanges array.
021        float scaleRangeMin; // RangeFloat  A range that specifies the sizes of the shapes you expect to be in the image, expressed as a ratio percentage representing the size of the pattern in the image divided by size of the original pattern multiplied by 100. This function ignores this range if mode does not include IMAQ_GEOMETRIC_MATCH_SCALE_INVARIANT
022        float scaleRangeMax;
023        double minMatchScore; // double  The minimum score a match can have for the function to consider the match valid. Acceptable values range from 0 to 1,000.
024    
025        public static final int IMAQ_GEOMETRIC_MATCH_SHIFT_INVARIANT = 0; // Searches for occurrences of the pattern in the image, assuming that the pattern is not rotated more than plus or minus 5 degrees.
026        public static final int IMAQ_GEOMETRIC_MATCH_ROTATION_INVARIANT = 1; // Searches for occurrences of the pattern in the image with reduced restriction on the rotation of the pattern.
027        public static final int IMAQ_GEOMETRIC_MATCH_SCALE_INVARIANT = 2; // Searches for occurrences of the pattern in the image with reduced restriction on the size of the pattern.
028        public static final int IMAQ_GEOMETRIC_MATCH_OCCLUSION_INVARIANT = 4; // Searches for occurrences of the pattern in the image, allowing for a specified percentage of the pattern to be occluded.
029    
030    
031        public ShapeDetectionOptions(int mode, int angleRanges, int numAngleRanges, float scaleRangeMin, float scaleRangeMax, double minMatchScore) {
032            this.mode = mode;
033            this.angleRanges = angleRanges;
034            this.numAngleRanges = numAngleRanges;
035            this.scaleRangeMin = scaleRangeMin;
036            this.scaleRangeMax = scaleRangeMax;
037            this.minMatchScore = minMatchScore;
038            allocateMemory();
039            write();
040        }
041        
042    
043        public void read() {
044            mode = backingNativeMemory.getInt(0);
045            angleRanges = backingNativeMemory.getInt(4);
046            numAngleRanges = backingNativeMemory.getInt(8);
047            scaleRangeMin = backingNativeMemory.getFloat(12);
048            scaleRangeMax = backingNativeMemory.getFloat(16);
049            minMatchScore = backingNativeMemory.getDouble(20);
050        }
051    
052        public void write() {
053            backingNativeMemory.setInt(0, mode);
054            backingNativeMemory.setInt(4, angleRanges);
055            backingNativeMemory.setInt(8, numAngleRanges);
056            backingNativeMemory.setFloat(12, scaleRangeMin);
057            backingNativeMemory.setFloat(16, scaleRangeMax);
058            backingNativeMemory.setDouble(20, minMatchScore);
059    
060    
061        }
062    
063        public int size() {
064            return 28;
065        }
066    
067        public void free() {
068            release();
069        }
070    
071    }