OSDN Git Service

[更新]NyARToolkit/nyatlaブランチ
[nyartoolkit-and/nyartoolkit-and.git] / test / jp / nyatla / nyartoolkit / dev / LabelingTest.java
1 package jp.nyatla.nyartoolkit.dev;\r
2 \r
3 import java.awt.Frame;\r
4 import java.io.File;\r
5 import java.io.FileInputStream;\r
6 \r
7 import jp.nyatla.nyartoolkit.core.raster.*;\r
8 import jp.nyatla.nyartoolkit.core.raster.rgb.NyARRgbRaster_BGRA;\r
9 import jp.nyatla.nyartoolkit.core.rasteranalyzer.*;\r
10 import jp.nyatla.nyartoolkit.core.labeling.*;\r
11 import jp.nyatla.nyartoolkit.core.labeling.image.NyARLabelingImage;\r
12 import jp.nyatla.nyartoolkit.core.labeling.types.*;\r
13 import jp.nyatla.utils.j2se.*;\r
14 \r
15 public class LabelingTest extends Frame\r
16 {\r
17     private final String data_file  ="../Data/320x240ABGR.raw";\r
18     public void drawImage() throws Exception\r
19     {\r
20         File f=new File(data_file);\r
21         FileInputStream fs=new FileInputStream(data_file);\r
22         byte[] buf=new byte[(int)f.length()];\r
23         fs.read(buf);\r
24         NyARRgbRaster_BGRA ra=NyARRgbRaster_BGRA.wrap(buf, 320, 240);\r
25         NyARLabelingImage limage=new NyARLabelingImage(320,240);\r
26         INyARLabeling labeling=new NyARLabeling_ARToolKit();\r
27 //      INyARLabeling labeling=new NyLineLabeling();\r
28         INyARRasterReaderFactory rf=new NyARRasterReaderFactory_RgbTotal();\r
29         labeling.attachDestination(limage);\r
30         labeling.labeling(rf.createReader(ra));\r
31         LabelingBufferdImage img=new LabelingBufferdImage(320,240,LabelingBufferdImage.COLOR_125_COLOR);\r
32         img.setLabelingImage(limage);\r
33         this.getGraphics().drawImage(img, 32,32,this);\r
34     }\r
35     public static void main(String[] args)\r
36     {\r
37         try{\r
38             LabelingTest app=new LabelingTest();\r
39             app.setVisible(true);\r
40             app.setBounds(0,0,640,480);\r
41             app.drawImage();\r
42         }catch(Exception e){\r
43             e.printStackTrace();\r
44         }\r
45     }\r
46 }\r