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 public JmfCaptureTest() throws NyARException
45 setTitle("JmfCaptureTest");
46 setBounds(0, 0, 320 + 64, 240 + 64);
47 capture = new JmfCameraCapture(320, 240, 30f, JmfCameraCapture.PIXEL_FORMAT_RGB);
48 capture.setCaptureListener(this);
51 private JmfCameraCapture capture;
53 public void onUpdateBuffer(Buffer i_buffer)
55 BufferToImage b2i = new BufferToImage((VideoFormat) i_buffer.getFormat());
56 Image img = b2i.createImage(i_buffer);
57 Graphics g = getGraphics();
58 g.drawImage(img, 32, 32, this);
61 private void startCapture()
65 } catch (Exception e) {
70 public static void main(String[] args)
73 JmfCaptureTest mainwin = new JmfCaptureTest();
74 mainwin.setVisible(true);
75 mainwin.startCapture();
76 } catch (Exception e) {