Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -6,6 +6,8 @@
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.image;

import com.ni.vision.NIVision;

/**
* A color image represented in HSL color space at 3 bytes per pixel.
* @author dtjones
@@ -16,7 +18,7 @@ public class HSLImage extends ColorImage {
* Create a new 0x0 image.
*/
public HSLImage() throws NIVisionException {
super(NIVision.ImageType.imaqImageHSL);
super(NIVision.ImageType.IMAGE_HSL);
}

HSLImage(HSLImage sourceImage) {
@@ -28,7 +30,7 @@ public HSLImage() throws NIVisionException {
* @param fileName The path of the file to load.
*/
public HSLImage(String fileName) throws NIVisionException {
super(NIVision.ImageType.imaqImageHSL);
NIVision.readFile(image, fileName);
super(NIVision.ImageType.IMAGE_HSL);
NIVision.imaqReadFile(image, fileName);
}
}
@@ -6,21 +6,22 @@
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.image;

import com.sun.jna.Pointer;
import com.ni.vision.NIVision;
import com.ni.vision.NIVision.Image;

/**
* Class representing a generic image.
* @author dtjones
*/
public abstract class Image {
public abstract class ImageBase {

/**
* Pointer to the image memory
*/
public final Pointer image;
public final Image image;
static final int DEFAULT_BORDER_SIZE = 3;

Image(NIVision.ImageType type) throws NIVisionException {
ImageBase(NIVision.ImageType type) throws NIVisionException {
image = NIVision.imaqCreateImage(type, DEFAULT_BORDER_SIZE);
}

@@ -30,7 +31,7 @@ public abstract class Image {
* one will free both.
* @param sourceImage The image to reference
*/
Image(Image sourceImage) {
ImageBase(ImageBase sourceImage) {
image = sourceImage.image;
}

@@ -48,29 +49,31 @@ public abstract class Image {
* @param fileName The path to write the image to.
*/
public void write(String fileName) throws NIVisionException {
NIVision.writeFile(image, fileName);
NIVision.RGBValue value = new NIVision.RGBValue();
NIVision.imaqWriteFile(image, fileName, value);
value.free();
}

/**
* Release the memory associated with an image.
*/
public void free() throws NIVisionException {
NIVision.dispose(image);
image.free();
}

/**
* Get the height of the image in pixels.
* @return The height of the image.
*/
public int getHeight() throws NIVisionException {
return NIVision.getHeight(image);
return NIVision.imaqGetImageSize(image).height;
}

/**
* Get the width of the image in pixels.
* @return The width of the image.
*/
public int getWidth() throws NIVisionException {
return NIVision.getWidth(image);
return NIVision.imaqGetImageSize(image).width;
}
}

This file was deleted.

@@ -6,31 +6,38 @@
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.image;

import com.ni.vision.NIVision;
import com.ni.vision.NIVision.EllipseDescriptor;
import com.ni.vision.NIVision.CurveOptions;
import com.ni.vision.NIVision.ShapeDetectionOptions;
import com.ni.vision.NIVision.ROI;
import com.ni.vision.NIVision.DetectEllipsesResult;

/**
* A grey scale image represented at a byte per pixel.
* @author dtjones
*/
public class MonoImage extends Image {
public class MonoImage extends ImageBase {

/**
* Create a new 0x0 image.
*/
public MonoImage() throws NIVisionException {
super(NIVision.ImageType.imaqImageU8);
super(NIVision.ImageType.IMAGE_U8);
}

MonoImage(MonoImage sourceImage) {
super(sourceImage);
}

public EllipseMatch[] detectEllipses(EllipseDescriptor ellipseDescriptor,
public DetectEllipsesResult detectEllipses(EllipseDescriptor ellipseDescriptor,
CurveOptions curveOptions, ShapeDetectionOptions shapeDetectionOptions,
RegionOfInterest roi) throws NIVisionException {
return NIVision.detectEllipses(this, ellipseDescriptor, curveOptions, shapeDetectionOptions, roi);
ROI roi) throws NIVisionException {
return NIVision.imaqDetectEllipses(image, ellipseDescriptor, curveOptions, shapeDetectionOptions, roi);
}

public EllipseMatch[] detectEllipses(EllipseDescriptor ellipseDescriptor)
public DetectEllipsesResult detectEllipses(EllipseDescriptor ellipseDescriptor)
throws NIVisionException {
return NIVision.detectEllipses(this, ellipseDescriptor, null, null, null);
return NIVision.imaqDetectEllipses(image, ellipseDescriptor, null, null, null);
}
}

This file was deleted.

@@ -422,7 +422,7 @@ private static String lookUpCode(int errorCode) {
case -1074395879:
return "Invalid measure number.";
case -1074395878:
return "The Image Display control does not support writing this property node.";
return "The ImageBase Display control does not support writing this property node.";
case -1074395877:
return "The specified color mode requires the use of imaqChangeColorSpace2.";
case -1074395876:
@@ -6,6 +6,8 @@
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.image;

import com.ni.vision.NIVision;

/**
* Class to store commonly used information about a particle.
* @author dtjones
@@ -52,21 +54,21 @@ public class ParticleAnalysisReport {
ParticleAnalysisReport(BinaryImage image, int index) throws NIVisionException {
imageHeight = image.getHeight();
imageWidth = image.getWidth();
center_mass_x = (int) NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_CENTER_OF_MASS_X);
center_mass_y = (int) NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_CENTER_OF_MASS_Y);
center_mass_x = (int) NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_CENTER_OF_MASS_X);
center_mass_y = (int) NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_CENTER_OF_MASS_Y);
center_mass_x_normalized = (2.0 * center_mass_x / imageWidth) - 1.0;
center_mass_y_normalized = (2.0 * center_mass_y / imageHeight) - 1.0;
particleArea = NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_AREA);
boundingRectLeft = (int) NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_BOUNDING_RECT_LEFT);
boundingRectTop = (int) NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_BOUNDING_RECT_TOP);
boundingRectWidth = (int) NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_BOUNDING_RECT_WIDTH);
boundingRectHeight = (int) NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_BOUNDING_RECT_HEIGHT);
particleToImagePercent = NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_AREA_BY_IMAGE_AREA);
particleQuality = NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA);
particleArea = NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_AREA);
boundingRectLeft = (int) NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_BOUNDING_RECT_LEFT);
boundingRectTop = (int) NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_BOUNDING_RECT_TOP);
boundingRectWidth = (int) NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_BOUNDING_RECT_WIDTH);
boundingRectHeight = (int) NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_BOUNDING_RECT_HEIGHT);
particleToImagePercent = NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_AREA_BY_IMAGE_AREA);
particleQuality = NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_AREA_BY_PARTICLE_AND_HOLES_AREA);
}

static double getParticleToImagePercent(BinaryImage image, int index) throws NIVisionException {
return NIVision.MeasureParticle(image.image, index, false, NIVision.MeasurementType.IMAQ_MT_AREA_BY_IMAGE_AREA);
return NIVision.imaqMeasureParticle(image.image, index, 0, NIVision.MeasurementType.MT_AREA_BY_IMAGE_AREA);
}

/**
@@ -7,6 +7,8 @@

package edu.wpi.first.wpilibj.image;

import com.ni.vision.NIVision;

/**
* A color image represented in RGB color space at 3 bytes per pixel.
* @author dtjones
@@ -17,7 +19,7 @@ public class RGBImage extends ColorImage {
* Create a new 0x0 image.
*/
public RGBImage() throws NIVisionException {
super(NIVision.ImageType.imaqImageRGB);
super(NIVision.ImageType.IMAGE_RGB);
}

RGBImage(RGBImage sourceImage) {
@@ -29,7 +31,7 @@ public RGBImage() throws NIVisionException {
* @param fileName The path of the file to load.
*/
public RGBImage(String fileName) throws NIVisionException {
super(NIVision.ImageType.imaqImageRGB);
NIVision.readFile(image, fileName);
super(NIVision.ImageType.IMAGE_RGB);
NIVision.imaqReadFile(image, fileName);
}
}

This file was deleted.

This file was deleted.