当前位置: 首页>>代码示例>>Java>>正文


Java VisionException类代码示例

本文整理汇总了Java中com.ni.vision.VisionException的典型用法代码示例。如果您正苦于以下问题:Java VisionException类的具体用法?Java VisionException怎么用?Java VisionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VisionException类属于com.ni.vision包,在下文中一共展示了VisionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openCamera

import com.ni.vision.VisionException; //导入依赖的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;
  }
}
 
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:18,代码来源:USBCamera.java

示例2: initCamera

import com.ni.vision.VisionException; //导入依赖的package包/类
private void initCamera() {
try {
    session = NIVision.IMAQdxOpenCamera("cam0", NIVision.IMAQdxCameraControlMode.CameraControlModeController);
    NIVision.IMAQdxConfigureGrab(session);
  //  NIVision.IMAQdx

    // create images
    image = NIVision.imaqCreateImage(ImageType.IMAGE_RGB, 0);

    // Put default values to SmartDashboard so fields will appear
    SmartDashboard.putBoolean("use binary", false);
} catch (VisionException e) {
    TurtleLogger.critical("Camera Not found");
    e.printStackTrace();
}

   }
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:18,代码来源:TurtwigVision.java

示例3: setImage

import com.ni.vision.VisionException; //导入依赖的package包/类
/**
 * Manually change the image that is served by the MJPEG stream. This can be
 * called to pass custom annotated images to the dashboard. Note that, for
 * 640x480 video, this method could take between 40 and 50 milliseconds to
 * complete.
 *
 * This shouldn't be called if {@link #startAutomaticCapture} is called.
 *
 * @param image The IMAQ image to show on the dashboard
 */
public void setImage(Image image) {
  // handle multi-threadedness

  /* Flatten the IMAQ image to a JPEG */
  RawData data =
      NIVision.imaqFlatten(image, NIVision.FlattenType.FLATTEN_IMAGE,
          NIVision.CompressionType.COMPRESSION_JPEG, 10 * m_quality);
  ByteBuffer buffer = data.getBuffer();
  boolean hwClient;

  synchronized (this) {
    hwClient = m_hwClient;
  }

  /* Find the start of the JPEG data */
  int index = 0;
  if (hwClient) {
    while (index < buffer.limit() - 1) {
      if ((buffer.get(index) & 0xff) == 0xFF && (buffer.get(index + 1) & 0xff) == 0xD8)
        break;
      index++;
    }
  }

  if (buffer.limit() - index - 1 <= 2) {
    throw new VisionException("data size of flattened image is less than 2. Try another camera! ");
  }

  setImageData(data, index);
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:41,代码来源:CameraServer2832.java

示例4: startAutomaticCapture

import com.ni.vision.VisionException; //导入依赖的package包/类
/**
 * Start automatically capturing images to send to the dashboard.
 *
 * You should call this method to just see a camera feed on the dashboard
 * without doing any vision processing on the roboRIO. {@link #setImage}
 * shouldn't be called after this is called.
 *
 * @param cameraName The name of the camera interface (e.g. "cam1")
 */
public void startAutomaticCapture(String cameraName) {
  try {
    USBCamera camera = new USBCamera(cameraName);
    camera.openCamera();
    startAutomaticCapture(camera);
  } catch (VisionException ex) {
    //DriverStation.reportError(
       // "Error when starting the camera: " + cameraName + " " + ex.getMessage(), true);
  }
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:20,代码来源:CameraServer2832.java

示例5: capture

import com.ni.vision.VisionException; //导入依赖的package包/类
protected void capture() {
  Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
  while (true) {
    boolean hwClient;
    ByteBuffer dataBuffer = null;
    synchronized (this) {
      hwClient = m_hwClient;
      if (hwClient) {
        dataBuffer = m_imageDataPool.removeLast();
      }
    }

    try {
      if (hwClient && dataBuffer != null) {
        // Reset the image buffer limit
        dataBuffer.limit(dataBuffer.capacity() - 1);
        m_camera[selectedCamera].getImageData(dataBuffer);
        setImageData(new RawData(dataBuffer), 0);
      } else {
        m_camera[selectedCamera].getImage(frame);
        setImage(frame);
      }
    } catch (VisionException ex) {
      //DriverStation.reportError("Error when getting image from the camera: " + ex.getMessage(),true);
      if (dataBuffer != null) {
        synchronized (this) {
          m_imageDataPool.addLast(dataBuffer);
          Timer.delay(.1);
        }
      }
    }
  }
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:34,代码来源:CameraServer2832.java

示例6: setSelectedCamera

import com.ni.vision.VisionException; //导入依赖的package包/类
public void setSelectedCamera(int id) {
 if (lastSwitch + 2500 > System.currentTimeMillis())
  return;
 if (selectedCamera != id && id >= 0 && id < m_camera.length) {
  try {
	  m_camera[selectedCamera].stopCapture();
	  m_camera[id].startCapture();
	  
	  selectedCamera = id;
  } catch (VisionException e) {
	  //DriverStation.reportError("A camera was unplugged.", true);
  }
  lastSwitch = System.currentTimeMillis();
 }
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:16,代码来源:CameraServer2832.java

示例7: setImage

import com.ni.vision.VisionException; //导入依赖的package包/类
/**
 * Manually change the image that is served by the MJPEG stream. This can be
 * called to pass custom annotated images to the dashboard. Note that, for
 * 640x480 video, this method could take between 40 and 50 milliseconds to
 * complete.
 *
 * 
 *
 * @param image The IMAQ image to show on the dashboard
 */
public void setImage(Image image) {
  // handle multi-threadedness

  /* Flatten the IMAQ image to a JPEG */

  RawData data =
      NIVision.imaqFlatten(image, NIVision.FlattenType.FLATTEN_IMAGE,
          NIVision.CompressionType.COMPRESSION_JPEG, 10 * m_quality);
  ByteBuffer buffer = data.getBuffer();
  boolean hwClient;

  synchronized (this) {
    hwClient = m_hwClient;
  }

  /* Find the start of the JPEG data */
  int index = 0;
  if (hwClient) {
    while (index < buffer.limit() - 1) {
      if ((buffer.get(index) & 0xff) == 0xFF && (buffer.get(index + 1) & 0xff) == 0xD8)
        break;
      index++;
    }
  }

  if (buffer.limit() - index - 1 <= 2) {
    throw new VisionException("data size of flattened image is less than 2. Try another camera! ");
  }

  setImageData(data, index);
}
 
开发者ID:MontclairRobotics,项目名称:Sprocket,代码行数:42,代码来源:CameraServers.java

示例8: startCamera

import com.ni.vision.VisionException; //导入依赖的package包/类
/**
 * Start automatically capturing images to send to the dashboard.
 *
 * You should call this method to just see a camera feed on the dashboard
 * without doing any vision processing on the roboRIO. {@link #setImage}
 * shouldn't be called after this is called.
 *
 * @param cameraName The name of the camera interface (e.g. "cam1")
 */
private USBCamera startCamera(String cameraName) {
  try {
    USBCamera camera = new USBCamera(cameraName);
    camera.openCamera();
    //startAutomaticCapture(camera);
    return camera;
  } catch (VisionException ex) {
    DriverStation.reportError(
        "Error when starting the camera: " + cameraName + " " + ex.getMessage(), true);
  }
  return null;
}
 
开发者ID:MontclairRobotics,项目名称:Sprocket,代码行数:22,代码来源:CameraServers.java

示例9: capture

import com.ni.vision.VisionException; //导入依赖的package包/类
protected void capture() {
  Image frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
  while (true) {
    boolean hwClient;
    ByteBuffer dataBuffer = null;
    synchronized (this) {
      hwClient = m_hwClient;
      if (hwClient) {
        dataBuffer = m_imageDataPool.removeLast();
      }
    }

    try {
      if (hwClient && dataBuffer != null) {
        // Reset the image buffer limit
        dataBuffer.limit(dataBuffer.capacity() - 1);
        m_camera.getImageData(dataBuffer);
        setImageData(new RawData(dataBuffer), 0);
      } else {
        m_camera.getImage(frame);
        setImage(frame);
      }
    } catch (VisionException ex) {
      DriverStation.reportError("Error when getting image from the camera: " + ex.getMessage(),
          true);
      if (dataBuffer != null) {
        synchronized (this) {
          m_imageDataPool.addLast(dataBuffer);
          Timer.delay(.1);
        }
      }
    }
  }
}
 
开发者ID:MontclairRobotics,项目名称:Sprocket,代码行数:35,代码来源:CameraServers.java

示例10: setImage

import com.ni.vision.VisionException; //导入依赖的package包/类
/**
 * Manually change the image that is served by the MJPEG stream. This can be
 * called to pass custom annotated images to the dashboard. Note that, for
 * 640x480 video, this method could take between 40 and 50 milliseconds to
 * complete.
 *
 * This shouldn't be called if {@link #startAutomaticCapture} is called.
 *
 * @param image The IMAQ image to show on the dashboard
 */
public void setImage(Image image) {
  // handle multi-threadedness

  /* Flatten the IMAQ image to a JPEG */

  RawData data =
      NIVision.imaqFlatten(image, NIVision.FlattenType.FLATTEN_IMAGE,
          NIVision.CompressionType.COMPRESSION_JPEG, 10 * m_quality);
  ByteBuffer buffer = data.getBuffer();
  boolean hwClient;

  synchronized (this) {
    hwClient = m_hwClient;
  }

  /* Find the start of the JPEG data */
  int index = 0;
  if (hwClient) {
    while (index < buffer.limit() - 1) {
      if ((buffer.get(index) & 0xff) == 0xFF && (buffer.get(index + 1) & 0xff) == 0xD8)
        break;
      index++;
    }
  }

  if (buffer.limit() - index - 1 <= 2) {
    throw new VisionException("data size of flattened image is less than 2. Try another camera! ");
  }

  setImageData(data, index);
}
 
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:42,代码来源:CameraServer.java

示例11: startAutomaticCapture

import com.ni.vision.VisionException; //导入依赖的package包/类
/**
 * Start automatically capturing images to send to the dashboard.
 *
 * You should call this method to just see a camera feed on the dashboard
 * without doing any vision processing on the roboRIO. {@link #setImage}
 * shouldn't be called after this is called.
 *
 * @param cameraName The name of the camera interface (e.g. "cam1")
 */
public void startAutomaticCapture(String cameraName) {
  try {
    USBCamera camera = new USBCamera(cameraName);
    camera.openCamera();
    startAutomaticCapture(camera);
  } catch (VisionException ex) {
    DriverStation.reportError(
        "Error when starting the camera: " + cameraName + " " + ex.getMessage(), true);
  }
}
 
开发者ID:trc492,项目名称:Frc2016FirstStronghold,代码行数:20,代码来源:CameraServer.java

示例12: execute

import com.ni.vision.VisionException; //导入依赖的package包/类
@Override
protected void execute() {
	try{
		Robot.cameraSubsystem.serveLatestFrame();
	}catch(VisionException e){
		SmartDashboard.putString("Vision Error", e.getMessage()+e.getStackTrace());
	}
	
	String selectionString = (String)cameraChooser.getSelected();
	boolean selection = false;
	if (selectionString=="cam2"){
		selection = true;
	}
	
	/*if (selection!=Robot.cameraSubsystem.getInitilizedCamera()){
		Robot.cameraSubsystem.selectCamera(selection);
		Robot.cameraSubsystem.serveLatestFrame();
	}*/
	
	if(Robot.oi.joystick1.getRawButton(4) || Robot.oi.joystick2.getRawButton(4))
	{
		Robot.cameraSubsystem.selectCamera(true);
	}
	else if(Robot.oi.joystick1.getRawButton(5) || Robot.oi.joystick2.getRawButton(5))
	{
		Robot.cameraSubsystem.selectCamera(false);
	}
		
		
	SmartDashboard.putString("Target XY", SmartDashboard.getString("DIAMOND_COORDINATES", "?"));
}
 
开发者ID:Millerbots,项目名称:FRC2549-2016,代码行数:32,代码来源:StreamCameraCommand.java

示例13: resetAcquisition

import com.ni.vision.VisionException; //导入依赖的package包/类
private void resetAcquisition(){
	if (!broken){
		try{
			NIVision.IMAQdxStopAcquisition(getCurrentSession());
			NIVision.IMAQdxUnconfigureAcquisition(getCurrentSession());
		}catch (VisionException v){broken=true;pushError(v);}
	}
}
 
开发者ID:Millerbots,项目名称:FRC2549-2016,代码行数:9,代码来源:CameraSubsystem.java

示例14: selectCamera

import com.ni.vision.VisionException; //导入依赖的package包/类
public void selectCamera(boolean id){
	if (!broken){
		try{
			if (doneInit) resetAcquisition();
			NIVision.IMAQdxConfigureGrab(getSession(id));
	        NIVision.IMAQdxStartAcquisition(getSession(id));
	        initilizedCamera = id;
	        doneInit=true;
		}catch (VisionException v){broken=true;pushError(v);}
	}
}
 
开发者ID:Millerbots,项目名称:FRC2549-2016,代码行数:12,代码来源:CameraSubsystem.java

示例15: serveLatestFrame

import com.ni.vision.VisionException; //导入依赖的package包/类
public void serveLatestFrame(){
	if(!broken){
		try{
			NIVision.IMAQdxGrab(getCurrentSession(), frame, 1);
			server.setImage(frame);
		}catch (VisionException v){broken=true;pushError(v);}
	}
}
 
开发者ID:Millerbots,项目名称:FRC2549-2016,代码行数:9,代码来源:CameraSubsystem.java


注:本文中的com.ni.vision.VisionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。