2 * PROJECT: NyARToolkit JMF utilities.
3 * --------------------------------------------------------------------------------
5 * Copyright (c) 2008 nyatla
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 package jp.nyatla.nyartoolkit.jmf.utils.sample;
30 import javax.media.util.BufferToImage;
31 import javax.media.format.*;
33 import jp.nyatla.nyartoolkit.NyARException;
34 import jp.nyatla.nyartoolkit.jmf.utils.*;
41 public class JmfCaptureTest extends Frame implements JmfCaptureListener
43 private static final long serialVersionUID = -2110888320986446576L;
44 private JmfCaptureDevice _capture;
45 public JmfCaptureTest() throws NyARException
47 setTitle("JmfCaptureTest");
48 setBounds(0, 0, 320 + 64, 240 + 64);
49 JmfCaptureDeviceList dl=new JmfCaptureDeviceList();
50 this._capture=dl.getDevice(0);
51 this._capture.setOnCapture(this);
55 public void onUpdateBuffer(Buffer i_buffer)
57 BufferToImage b2i = new BufferToImage((VideoFormat) i_buffer.getFormat());
58 Image img = b2i.createImage(i_buffer);
59 Graphics g = getGraphics();
60 g.drawImage(img, 32, 32, this);
63 private void startCapture()
66 this._capture.start();
67 } catch (Exception e) {
72 public static void main(String[] args)
75 JmfCaptureTest mainwin = new JmfCaptureTest();
76 mainwin.setVisible(true);
77 mainwin.startCapture();
78 } catch (Exception e) {