本文整理汇总了Java中com.ni.vision.NIVision类的典型用法代码示例。如果您正苦于以下问题:Java NIVision类的具体用法?Java NIVision怎么用?Java NIVision使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NIVision类属于com.ni.vision包,在下文中一共展示了NIVision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image Source)
{
Image returnImage = null;
Image input = Source;
for (int i = 0; i < this.iterations; i++)
{
Image out = NIVision
.imaqCreateImage(ImageType.IMAGE_U8, 0);
NIVision.imaqGrayMorphology(out, input,
NIVision.MorphologyMethod.DILATE,
new NIVision.StructuringElement());
Source.free();
returnImage = out;
input = out;
}
return (returnImage);
}
示例2: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
public Image operate (Image Source)
{
// If we have criteria, then use the filter. If not, just return the
// original image.
if (allCriteria.length > 0)
{
Image out = NIVision
.imaqCreateImage(ImageType.IMAGE_U8, 0);
NIVision.imaqParticleFilter4(out, Source, allCriteria,
new ParticleFilterOptions2(0, 0, 0, 0), null);
Source.free();
return out;
}
return Source;
}
示例3: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image Source)
{
final Image hulledImage = NIVision
.imaqCreateImage(ImageType.IMAGE_U8, 0);
if (this.useConnectivity8 == true)
{
NIVision.imaqConvexHull(hulledImage, Source, 0);
}
else
{
NIVision.imaqConvexHull(hulledImage, Source, 1);
}
Source.free();
return hulledImage;
}
示例4: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image source)
{
Image alteredImage = null;
if (this.connectivity8 == true)
{
NIVision.imaqSizeFilter(alteredImage, source, 0, this.erosions,
NIVision.SizeType.KEEP_SMALL,
new NIVision.StructuringElement(
3, 3, 0));
}
else
{
NIVision.imaqSizeFilter(alteredImage, source, 1, this.erosions,
NIVision.SizeType.KEEP_SMALL,
new NIVision.StructuringElement(
3, 3, 0));
}
source.free();
return alteredImage;
}
示例5: setImageData
import com.ni.vision.NIVision; //导入依赖的package包/类
private synchronized void setImageData(RawData data, int start) {
//flip it here, since it is called by setImage anyways
if(flipped){
//make an image out of data
Image image = null;
NIVision.imaqUnflatten(image, data, data.getBuffer().array().length);
//flip it
Image flippedImage = null;
NIVision.imaqFlip(flippedImage, image, FlipAxis.HORIZONTAL_AXIS);
//change data to the data of the flipped image
data = NIVision.imaqFlatten(flippedImage, NIVision.FlattenType.FLATTEN_IMAGE,
NIVision.CompressionType.COMPRESSION_JPEG, 10 * m_quality);
}
if (m_imageData != null && m_imageData.data != null) {
m_imageData.data.free();
if (m_imageData.data.getBuffer() != null){
m_imageDataPool.addLast(m_imageData.data.getBuffer());
}
m_imageData = null;
}
m_imageData = new CameraData(data, start);
notifyAll();
}
示例6: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image Source)
{
if (this.connectivity8 == true)
{
NIVision.imaqSizeFilter(Source, Source, 0, this.erosions,
NIVision.SizeType.KEEP_SMALL, new NIVision.StructuringElement(
3, 3, 0));
}
else
{
NIVision.imaqSizeFilter(Source, Source, 1, this.erosions,
NIVision.SizeType.KEEP_SMALL, new NIVision.StructuringElement(
3, 3, 0));
}
return Source;
}
示例7: switchDirection
import com.ni.vision.NIVision; //导入依赖的package包/类
public static void switchDirection() {
switch (lastSelected) {
case "Front View":
NIVision.IMAQdxStopAcquisition(currSession);
currSession = sessionback;
NIVision.IMAQdxConfigureGrab(currSession);
Robot.drivetrain.ReverseDrive();
lastSelected = "Back View";
break;
default:
case "Back View":
NIVision.IMAQdxStopAcquisition(currSession);
currSession = sessionfront;
NIVision.IMAQdxConfigureGrab(currSession);
Robot.drivetrain.ForwardDrive();
lastSelected = "Front View";
break;
case "Manual Change":
break;
}
}
示例8: operatorControl
import com.ni.vision.NIVision; //导入依赖的package包/类
public void operatorControl() {
NIVision.IMAQdxStartAcquisition(session);
/**
* grab an image, draw the circle, and provide it for the camera server
* which will in turn send it to the dashboard.
*/
NIVision.Rect rect = new NIVision.Rect(10, 10, 100, 100);
while (isOperatorControl() && isEnabled()) {
NIVision.IMAQdxGrab(session, frame, 1);
NIVision.imaqDrawShapeOnImage(frame, frame, rect,
DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
CameraServer.getInstance().setImage(frame);
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
NIVision.IMAQdxStopAcquisition(session);
}
示例9: openCamera
import com.ni.vision.NIVision; //导入依赖的package包/类
public synchronized void openCamera() {
if (m_id != -1)
return; // Camera is already open
for (int i = 0; i < 3; i++) {
try {
m_id =
NIVision.IMAQdxOpenCamera(m_name,
NIVision.IMAQdxCameraControlMode.CameraControlModeController);
} catch (VisionException e) {
if (i == 2)
throw e;
delay(2.0);
continue;
}
break;
}
}
示例10: display
import com.ni.vision.NIVision; //导入依赖的package包/类
public void display() {
NIVision.IMAQdxStartAcquisition(session);
/**
* grab an image, draw the circle, and provide it for the camera server
* which will in turn send it to the dashboard.
*/
NIVision.Rect rect = new NIVision.Rect(10, 10, 100, 100);
//while (teleop && enabled) {
while(enabled) {
NIVision.IMAQdxGrab(session, frame, 1);
NIVision.imaqDrawShapeOnImage(frame, frame, rect,
DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
CameraServer.getInstance().setImage(frame);
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
NIVision.IMAQdxStopAcquisition(session);
}
示例11: toggle
import com.ni.vision.NIVision; //导入依赖的package包/类
public void toggle(){
if(currentSession == sessionBack){
NIVision.IMAQdxStopAcquisition(sessionBack);
NIVision.IMAQdxCloseCamera(sessionBack);
sessionFront = NIVision.IMAQdxOpenCamera(RobotMap.FRONT_CAMERA, IMAQdxCameraControlMode.CameraControlModeController);
NIVision.IMAQdxConfigureGrab(sessionFront);
NIVision.IMAQdxStartAcquisition(sessionFront);
currentSession = sessionFront;
}else if(currentSession == sessionFront){
NIVision.IMAQdxStopAcquisition(sessionFront);
NIVision.IMAQdxCloseCamera(sessionFront);
sessionBack = NIVision.IMAQdxOpenCamera(RobotMap.BACK_CAMERA, IMAQdxCameraControlMode.CameraControlModeController);
NIVision.IMAQdxConfigureGrab(sessionBack);
NIVision.IMAQdxStartAcquisition(sessionBack);
currentSession = sessionBack;
}
}
示例12: updateParticalAnalysisReports
import com.ni.vision.NIVision; //导入依赖的package包/类
/**
* Takes the processed image and writes information on each particle (blob) into
* the global <reports> array, in order of overall particle area.
*/
public void updateParticalAnalysisReports ()
{
if (this.camera.gethaveCamera() == true
&& this.currentImage != null)
{
final int numParticles = NIVision
.imaqCountParticles(this.currentImage, 0);
// Measure particles and sort by particle size
final Vector<ParticleReport> particles = new Vector<ParticleReport>();
if (numParticles > 0)
{
for (int particleIndex = 0; particleIndex < numParticles; particleIndex++)
{
final ParticleReport particle = new ParticleReport();
particle.PercentAreaToImageArea = NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_AREA_BY_IMAGE_AREA);
particle.area = NIVision.imaqMeasureParticle(
this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_AREA);
particle.ConvexHullArea = NIVision
.imaqMeasureParticle(
this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_CONVEX_HULL_AREA);
particle.boundingRectTop = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_BOUNDING_RECT_TOP);
particle.boundingRectLeft = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_BOUNDING_RECT_LEFT);
particle.boundingRectBottom = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_BOUNDING_RECT_BOTTOM);
particle.boundingRectRight = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_BOUNDING_RECT_RIGHT);
particle.boundingRectWidth = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_BOUNDING_RECT_WIDTH);// par.boundingRectRight
// -
// par.boundingRectLeft;
particle.center_mass_x = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_CENTER_OF_MASS_X);
particle.center_mass_y = (int) NIVision
.imaqMeasureParticle(this.currentImage,
particleIndex, 0,
NIVision.MeasurementType.MT_CENTER_OF_MASS_Y);
particle.imageWidth = NIVision
.imaqGetImageSize(this.currentImage).width;
particles.add(particle);
}
particles.sort(null);
}
this.reports = new ParticleReport[particles.size()];
particles.copyInto(this.reports);
particles.clear();
}
}
示例13: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image Source)
{
final Image largeObjectsImage = NIVision
.imaqCreateImage(ImageType.IMAGE_U8, 0);
try
{
if (this.connectivity8 == true)
{
// final Image newImage =
// NIVision.imaqCreateImage(ImageType.IMAGE_U8, 1);
// NIVision.imaqDuplicate(newImage, Source);
NIVision.imaqSetBorderSize(Source, 1);
NIVision.imaqSizeFilter(largeObjectsImage, Source, 1,
this.erosions,
NIVision.SizeType.KEEP_LARGE, null);// @AHK F**K it
// adjustment
// new NIVision.StructuringElement(3, 3, 0));
// Source.free();
// return newImage;
}
else
{
NIVision.imaqSizeFilter(largeObjectsImage, Source, 0,
this.erosions,
NIVision.SizeType.KEEP_LARGE, null
/* new NIVision.StructuringElement(3, 3, 0) */);
System.out.println("Other. Working???");
}
}
catch (final Exception ex)
{
ex.printStackTrace();
}
Source.free();
return largeObjectsImage;
}
示例14: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image Source)
{
NIVision.imaqWriteJPEGFile(Source, this.fileName, 1000, null);
System.out.println("Printed Image to: " + this.fileName);
return Source;
}
示例15: operate
import com.ni.vision.NIVision; //导入依赖的package包/类
@Override
public Image operate (Image Source)
{
// @TODO We may have to create the image instead of using the source.
NIVision.imaqReadFile(Source, this.fileName);
System.out.println("Loaded Image from: " + this.fileName);
return Source;
}