• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Frame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: JavavcCameraTest

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
public JavavcCameraTest(int deviceNumber) throws Exception  {
	super(deviceNumber);
	start(); // 开始获取摄像头数据
	// TODO Auto-generated constructor stub
	CanvasFrame canvas = new CanvasFrame("摄像头");
	canvas.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	canvas.setAlwaysOnTop(true);
	canvas.setResizable(true);
	while (true) {
		if (!canvas.isDisplayable()) {// 窗口是否关闭
			stop();// 停止抓取
			System.exit(2);// 退出
		}
		canvas.showImage(grab());// 获取摄像头图像并放到窗口上显示, 这里的Frame
		Frame frame=grab();
										// frame是一帧视频图像
		
		try {
			Thread.sleep(50);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}// 50毫秒刷新一次图像
	}
}
 
开发者ID:binjie09,项目名称:tttclass,代码行数:26,代码来源:JavavcCameraTest.java


示例2: recordFrame

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
private boolean recordFrame(Frame frame)
{
    try
    {
        frameFilter.push(frame);
        Frame filteredFrame;
        while ((filteredFrame = frameFilter.pull()) != null)
        {
            recorder.record(filteredFrame);
        }

        return true;
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
        return false;
    }
}
 
开发者ID:a3349384,项目名称:AndroidVideoRecordEx,代码行数:20,代码来源:VideoRecorderEx.java


示例3: transform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Override
public ImageWritable transform(ImageWritable image, Random random) {
    if (image == null) {
        canvas.dispose();
        return null;
    }
    if (!canvas.isVisible()) {
        return image;
    }
    Frame frame = image.getFrame();
    canvas.setCanvasSize(frame.imageWidth, frame.imageHeight);
    canvas.showImage(frame);
    if (delay >= 0) {
        try {
            canvas.waitKey(delay);
        } catch (InterruptedException ex) {
            // reset interrupt to be nice
            Thread.currentThread().interrupt();
        }
    }
    return image;
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:23,代码来源:ShowImageTransform.java


示例4: equals

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
    if (obj instanceof ImageWritable) {
        Frame f2 = ((ImageWritable) obj).getFrame();

        Buffer[] b1 = this.frame.image;
        Buffer[] b2 = f2.image;

        if (b1.length != b2.length)
            return false;

        for (int i = 0; i < b1.length; i++) {
            if (!b1[i].equals(b2[i]))
                return false;
        }

        return true;
    } else {
        return false;
    }
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:22,代码来源:ImageWritable.java


示例5: testResizeUpscale1

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testResizeUpscale1() throws Exception {
    ImageWritable srcImg = TestImageTransform.makeRandomImage(32, 32, 3);

    ResizeImageTransform transform = new ResizeImageTransform(200, 200);

    ImageWritable dstImg = transform.transform(srcImg);

    Frame f = dstImg.getFrame();
    assertEquals(f.imageWidth, 200);
    assertEquals(f.imageHeight, 200);

    float[] coordinates = {100, 200};
    float[] transformed = transform.query(coordinates);
    assertEquals(200f * 100 / 32, transformed[0], 0);
    assertEquals(200f * 200 / 32, transformed[1], 0);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:18,代码来源:ResizeImageTransformTest.java


示例6: testResizeDownscale

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testResizeDownscale() throws Exception {
    ImageWritable srcImg = TestImageTransform.makeRandomImage(571, 443, 3);

    ResizeImageTransform transform = new ResizeImageTransform(200, 200);

    ImageWritable dstImg = transform.transform(srcImg);

    Frame f = dstImg.getFrame();
    assertEquals(f.imageWidth, 200);
    assertEquals(f.imageHeight, 200);

    float[] coordinates = {300, 400};
    float[] transformed = transform.query(coordinates);
    assertEquals(200f * 300 / 443, transformed[0], 0);
    assertEquals(200f * 400 / 571, transformed[1], 0);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:18,代码来源:ResizeImageTransformTest.java


示例7: testCropImageTransform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testCropImageTransform() throws Exception {
    ImageWritable writable = makeRandomImage(0, 0, 1);
    Frame frame = writable.getFrame();
    ImageTransform transform = new CropImageTransform(rng, frame.imageHeight / 2, frame.imageWidth / 2,
                    frame.imageHeight / 2, frame.imageWidth / 2);

    for (int i = 0; i < 100; i++) {
        ImageWritable w = transform.transform(writable);
        Frame f = w.getFrame();
        assertTrue(f.imageHeight <= frame.imageHeight);
        assertTrue(f.imageWidth <= frame.imageWidth);
        assertEquals(f.imageChannels, frame.imageChannels);
    }
    assertEquals(null, transform.transform(null));

    transform = new CropImageTransform(1, 2, 3, 4);
    writable = transform.transform(writable);
    float[] coordinates = {1, 2, 3, 4};
    float[] transformed = transform.query(coordinates);
    assertEquals(1 - 2, transformed[0], 0);
    assertEquals(2 - 1, transformed[1], 0);
    assertEquals(3 - 2, transformed[2], 0);
    assertEquals(4 - 1, transformed[3], 0);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:26,代码来源:TestImageTransform.java


示例8: testScaleImageTransform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testScaleImageTransform() throws Exception {
    ImageWritable writable = makeRandomImage(0, 0, 4);
    Frame frame = writable.getFrame();
    ImageTransform transform = new ScaleImageTransform(rng, frame.imageWidth / 2, frame.imageHeight / 2);

    for (int i = 0; i < 100; i++) {
        ImageWritable w = transform.transform(writable);
        Frame f = w.getFrame();
        assertTrue(f.imageHeight >= frame.imageHeight / 2);
        assertTrue(f.imageHeight <= 3 * frame.imageHeight / 2);
        assertTrue(f.imageWidth >= frame.imageWidth / 2);
        assertTrue(f.imageWidth <= 3 * frame.imageWidth / 2);
        assertEquals(f.imageChannels, frame.imageChannels);
    }
    assertEquals(null, transform.transform(null));

    transform = new ScaleImageTransform(frame.imageWidth, 2 * frame.imageHeight);
    writable = transform.transform(writable);
    float[] coordinates = {5, 7, 11, 13};
    float[] transformed = transform.query(coordinates);
    assertEquals(5 * 2,  transformed[0], 0);
    assertEquals(7 * 3,  transformed[1], 0);
    assertEquals(11 * 2, transformed[2], 0);
    assertEquals(13 * 3, transformed[3], 0);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:27,代码来源:TestImageTransform.java


示例9: testRotateImageTransform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testRotateImageTransform() throws Exception {
    ImageWritable writable = makeRandomImage(0, 0, 1);
    Frame frame = writable.getFrame();
    ImageTransform transform =
                    new RotateImageTransform(rng, 180).interMode(INTER_NEAREST).borderMode(BORDER_REFLECT);

    for (int i = 0; i < 100; i++) {
        ImageWritable w = transform.transform(writable);
        Frame f = w.getFrame();
        assertEquals(f.imageHeight, frame.imageHeight);
        assertEquals(f.imageWidth, frame.imageWidth);
        assertEquals(f.imageChannels, frame.imageChannels);
    }
    assertEquals(null, transform.transform(null));

    transform = new RotateImageTransform(0, 0, -90, 0);
    writable = transform.transform(writable);
    float[] coordinates = {frame.imageWidth / 2, frame.imageHeight / 2, 0, 0};
    float[] transformed = transform.query(coordinates);
    assertEquals(frame.imageWidth  / 2, transformed[0], 0);
    assertEquals(frame.imageHeight / 2, transformed[1], 0);
    assertEquals((frame.imageHeight + frame.imageWidth) / 2, transformed[2], 1);
    assertEquals((frame.imageHeight - frame.imageWidth) / 2, transformed[3], 1);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:26,代码来源:TestImageTransform.java


示例10: testMultiImageTransform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testMultiImageTransform() throws Exception {
    ImageWritable writable = makeRandomImage(0, 0, 3);
    Frame frame = writable.getFrame();
    ImageTransform transform = new MultiImageTransform(rng, new CropImageTransform(10),
                    new FlipImageTransform(), new ScaleImageTransform(10), new WarpImageTransform(10));

    for (int i = 0; i < 100; i++) {
        ImageWritable w = transform.transform(writable);
        Frame f = w.getFrame();
        assertTrue(f.imageHeight >= frame.imageHeight - 30);
        assertTrue(f.imageHeight <= frame.imageHeight + 20);
        assertTrue(f.imageWidth >= frame.imageWidth - 30);
        assertTrue(f.imageWidth <= frame.imageWidth + 20);
        assertEquals(f.imageChannels, frame.imageChannels);
    }
    assertEquals(null, transform.transform(null));

    transform = new MultiImageTransform(new ColorConversionTransform(COLOR_BGR2RGB));
    writable = transform.transform(writable);
    float[] transformed = transform.query(new float[] {11, 22});
    assertEquals(11, transformed[0], 0);
    assertEquals(22, transformed[1], 0);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:25,代码来源:TestImageTransform.java


示例11: testFilterImageTransform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Ignore
@Test
public void testFilterImageTransform() throws Exception {
    ImageWritable writable = makeRandomImage(0, 0, 4);
    Frame frame = writable.getFrame();
    ImageTransform transform = new FilterImageTransform("noise=alls=20:allf=t+u,format=rgba", frame.imageWidth,
                    frame.imageHeight, frame.imageChannels);

    for (int i = 0; i < 100; i++) {
        ImageWritable w = transform.transform(writable);
        Frame f = w.getFrame();
        assertEquals(f.imageHeight, frame.imageHeight);
        assertEquals(f.imageWidth, frame.imageWidth);
        assertEquals(f.imageChannels, frame.imageChannels);
    }
    assertEquals(null, transform.transform(null));
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:18,代码来源:TestImageTransform.java


示例12: testRandomCropTransform

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Test
public void testRandomCropTransform() throws Exception {
    ImageWritable writable = makeRandomImage(0, 0, 1);
    Frame frame = writable.getFrame();
    ImageTransform transform = new RandomCropTransform(frame.imageHeight / 2, frame.imageWidth / 2);

    for (int i = 0; i < 100; i++) {
        ImageWritable w = transform.transform(writable);
        Frame f = w.getFrame();
        assertTrue(f.imageHeight == frame.imageHeight / 2);
        assertTrue(f.imageWidth == frame.imageWidth / 2);
    }
    assertEquals(null, transform.transform(null));

    transform = new RandomCropTransform(frame.imageHeight, frame.imageWidth);
    writable = transform.transform(writable);
    float[] coordinates = {2, 4, 6, 8};
    float[] transformed = transform.query(coordinates);
    assertEquals(2, transformed[0], 0);
    assertEquals(4, transformed[1], 0);
    assertEquals(6, transformed[2], 0);
    assertEquals(8, transformed[3], 0);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:24,代码来源:TestImageTransform.java


示例13: makeRandomImage

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
public static ImageWritable makeRandomImage(int height, int width, int channels) {
    if (height <= 0) {
        height = rng.nextInt() % 100 + 200;
    }
    if (width <= 0) {
        width = rng.nextInt() % 100 + 200;
    }
    Mat img = new Mat(height, width, CV_8UC(channels));
    UByteIndexer idx = img.createIndexer();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            for (int k = 0; k < channels; k++) {
                idx.put(i, j, k, rng.nextInt());
            }
        }
    }
    Frame frame = converter.convert(img);
    return new ImageWritable(frame);
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:20,代码来源:TestImageTransform.java


示例14: loadData

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
protected List<Writable> loadData(File file, InputStream inputStream) throws IOException {
    List<Writable> ret = new ArrayList<>();
    try (FFmpegFrameGrabber grabber = inputStream != null ? new FFmpegFrameGrabber(inputStream)
                    : new FFmpegFrameGrabber(file.getAbsolutePath())) {
        grabber.setSampleFormat(AV_SAMPLE_FMT_FLT);
        grabber.start();
        Frame frame;
        while ((frame = grabber.grab()) != null) {
            while (frame.samples != null && frame.samples[0].hasRemaining()) {
                for (int i = 0; i < frame.samples.length; i++) {
                    ret.add(new FloatWritable(((FloatBuffer) frame.samples[i]).get()));
                }
            }
        }
    }
    return ret;
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:18,代码来源:NativeAudioRecordReader.java


示例15: add

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
/**
 * blocking safe exchange of data between different threads external thread
 * adds image data which can be retrieved from the blockingData queue
 * 
 * @param image
 *          - image to be processed through pipeline
 * @return - OpenCVData
 */
public VisionData add(Frame image) {
  FrameGrabber grabber = getGrabber();
  if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
    error("can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
    return null;
  }

  BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
  bqgrabber.add(image);

  try {
    VisionData ret = (VisionData) blockingData.take();
    return ret;
  } catch (InterruptedException e) {
    return null;
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:26,代码来源:Vision.java


示例16: add

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
public OpenCVData add(Frame image) {
  FrameGrabber grabber = videoProcessor.getGrabber();
  if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
    error("can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
    return null;
  }

  BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
  bqgrabber.add(image);

  try {
    OpenCVData ret = (OpenCVData) videoProcessor.blockingData.take();
    return ret;
  } catch (InterruptedException e) {
    return null;
  }
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:18,代码来源:OpenCV.java


示例17: grab

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Override
public Frame grab() {
  if (!cache.containsKey(path)) {
    image = cvLoadImage(path);
    cache.put(path, image);
  } else {
    image = cache.get(path).clone();
  }

  ++frameCounter;

  if (frameCounter > 1) {
    lastImage.release();
  }

  lastImage = image;
  return converter.convert(image);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:19,代码来源:ImageFileFrameGrabber.java


示例18: grab

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Override
public Frame grab() {
  try {
    // pause for the specified delay before loading the image.
    Thread.sleep(delay);
  } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
  // set the file path
  path = imageFiles.get(grabCount).getAbsolutePath();
  log.info("Grabbing file {} - {}", grabCount, path);
  // grab it.
  Frame f = super.grab();
  // increment out count.
  grabCount++;
  grabCount = grabCount % imageFiles.size();

  return f;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:21,代码来源:SlideShowFrameGrabber.java


示例19: grab

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
@Override
public Frame grab() {

  Frame image = null;
  synchronized (imgq) {

    while (image == null) { // while no messages && no messages that are
      // blocking
      if (imgq.size() == 0) {
        try {
          imgq.wait();
        } catch (InterruptedException e) {
        } // must own the lock
      } else {
        image = OpenCVUtils.BufferedImageToFrame(imgq.removeLast().getImage());
        // image = IplImage.createFrom(imgq.removeLast().getImage());
      }
    }
    imgq.notifyAll();
  }

  return image;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:24,代码来源:VideoSourceFrameGrabber.java


示例20: add

import org.bytedeco.javacv.Frame; //导入依赖的package包/类
/**
 * blocking safe exchange of data between different threads external thread
 * adds image data which can be retrieved from the blockingData queue
 * 
 * @param image - a null value, but could support adding an image
 */
public VisionData add(Frame image) {
	FrameGrabber grabber = getGrabber();
	if (grabber == null || grabber.getClass() != BlockingQueueGrabber.class) {
		processor.error(
				"can't add an image to the video processor - grabber must be not null and BlockingQueueGrabber");
		return null;
	}

	BlockingQueueGrabber bqgrabber = (BlockingQueueGrabber) grabber;
	bqgrabber.add(image);

	/*
	try {
		OpenCVData ret = (OpenCVData) blockingData.take();
		return ret;
	} catch (InterruptedException e) {
		return null;
	}
	*/
	return null;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:28,代码来源:OpenCVFilterInput.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ATNConfigSet类代码示例发布时间:2022-05-21
下一篇:
Java Server类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap