在SWT画布上显示IplImage(JavaCV) [英] Display IplImage (JavaCV) on an SWT canvas
问题描述
我正在将JavaCV用于大学项目。它本质上是一个运动检测器。
I'm using JavaCV for a university project. It is essentially a motion detector.
我使用OpenCVFrameGrabber类从网络摄像头获取帧,我想在我的GUI上显示抓取的帧。
I use the OpenCVFrameGrabber class to get the frames from a webcam and I want to display the grabbed frames on my GUI.
我正在使用SWT,我认为将帧显示在Canvas组件中会很好。
我有一个问题,因为OpenCVFrameGrabber提供图像作为IplImage类的实例,而SWT使用org.eclipse.swt.graphics.Image图像类。
I'm using SWT and I thought it would be good to display the frames into a Canvas component. I have a problem because the OpenCVFrameGrabber provides images as instances of the IplImage class and SWT uses org.eclipse.swt.graphics.Image image class.
所以我应该将图像从IplImage转换为SWT Image。最好的方法是什么?
So I should convert the image someway from IplImage to SWT Image. What is the best way to do this?
推荐答案
我最近将BufferedImages(AWT)转换为SWT图像对象。
我使用了以下代码段: java2s.com
I recently converted BufferedImages (AWT) to SWT Image Objects. I made use of the following snippet: java2s.com
也许代码可以帮助您入门。或者某人已将IplImages转换为BufferedImages,您可以管道这两种转换方法。
Maybe the code gets you started. Or someone already converted IplImages to BufferedImages, and you could "pipe" these two conversion methods.
干杯
这篇关于在SWT画布上显示IplImage(JavaCV)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!