2 * PROJECT: NyARToolkit QuickTime sample program.
3 * --------------------------------------------------------------------------------
5 * Copyright (c) 2008 nyatla
6 * airmail(at)ebony.plala.or.jp
7 * http://nyatla.jp/nyartoolkit/
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 package jp.nyatla.nyartoolkit.qt.sample;
29 import jp.nyatla.nyartoolkit.NyARException;
30 import jp.nyatla.nyartoolkit.qt.utils.*;
31 import jp.nyatla.nyartoolkit.core.types.*;
34 import java.awt.image.*;
38 * On windows, You might get couldntGetRequiredComponent error.
39 * If you got error try to install WinVDIG.
40 * http://www.eden.net.nz/7/20071008/
42 * Windowsの場合、WinVDIGが無いとキャプチャプログラムが動かないことがあります。
43 * couldntGetRequiredComponentエラーが出たら、WinVDIGをインストールしてみてね。
44 * WinVIDGはとりあえずここから入手可能。http://www.eden.net.nz/7/20071008/
48 public class QtCaptureTest extends Frame implements QtCaptureListener
50 private static final long serialVersionUID = -734697739607654631L;
52 public QtCaptureTest() throws NyARException
54 setTitle("QtCaptureTest");
55 setBounds(0, 0, 320 + 64, 240 + 64);
56 capture = new QtCameraCapture(320, 240, 30f);
57 capture.setCaptureListener(this);
59 raster = new QtNyARRaster_RGB(320, 240);
62 private QtCameraCapture capture;
63 private QtNyARRaster_RGB raster;
65 public void onUpdateBuffer(byte[] pixels)
68 this.raster.wrapBuffer(pixels);
76 NyARIntSize s=raster.getSize();
77 WritableRaster wr = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE, s.w,s.h, s.w * 3, 3, new int[] { 0, 1, 2 }, null);
78 BufferedImage bi = new BufferedImage(s.w, s.h, BufferedImage.TYPE_3BYTE_BGR);
80 wr.setDataElements(0, 0, s.w, s.h,raster.getBuffer());
83 Graphics g = getGraphics();
84 g.drawImage(bi, 32, 32, this);
87 private void startCapture()
91 } catch (Exception e) {
96 public static void main(String[] args)
99 QtCaptureTest mainwin = new QtCaptureTest();
100 mainwin.setVisible(true);
101 mainwin.startCapture();
102 } catch (Exception e) {