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


Java RawData类代码示例

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


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

示例1: setImageData

import com.ni.vision.NIVision.RawData; //导入依赖的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();
 }
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:24,代码来源:CameraServer2832.java

示例2: setImage

import com.ni.vision.NIVision.RawData; //导入依赖的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

示例3: capture

import com.ni.vision.NIVision.RawData; //导入依赖的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

示例4: setImageData

import com.ni.vision.NIVision.RawData; //导入依赖的package包/类
private synchronized void setImageData(RawData data, int start) {
  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();
}
 
开发者ID:MontclairRobotics,项目名称:Sprocket,代码行数:11,代码来源:CameraServers.java

示例5: setImage

import com.ni.vision.NIVision.RawData; //导入依赖的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

示例6: capture

import com.ni.vision.NIVision.RawData; //导入依赖的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

示例7: setImage

import com.ni.vision.NIVision.RawData; //导入依赖的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

示例8: CameraData

import com.ni.vision.NIVision.RawData; //导入依赖的package包/类
public CameraData(RawData d, int s) {
  data = d;
  start = s;
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:5,代码来源:CameraServer2832.java


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