Downloadliste

Systemanforderungen

Die Systemvoraussetzungen sind nicht definiert

Veröffentlicht: 2009-05-29 18:31
NyARToolkit for C Sharp 2.3.0 (1 files Verstecken)

Versionsanmerkungen

NyARToolkit for Java/2.3.1のC#バージョン+バグ修正


+New function -- NyIdMarkerSystem is available.
+Bug fix -- NyARToolkit/2.2.0 and lower has bug that a input image flip vertical.
+Bug fix -- NyARToolkit/2.2.0 and lower version used the Left-hand matrix(projection matrix and transform matrix), but this form is not correct. NyARToolkit/2.3.0 will use Right-hand matrix.

+Ticket:#17014,#17013,#16938

NyARToolkit for Java/2.3.1のC#バージョン+バグ修正


+Idマーカシステム追加 -- NyIdシステムが利用可能になりました。
+画処理系の不具合修正 -- 入力画像が上下反転していた問題を修正しました。
+変換行列の方位変更 -- NyARToolkitCS/2.2.0以前は、誤った左手系の変換行列、射影変換行列を使用していましたが、右手系に修正しました。
+対象チケット:#17014,#17013,#16938

Änderungsprotokoll

Index: forWM5/SimpleLiteDirect3d.WindowsMobile5/ResourceBuilder.cs
===================================================================
--- forWM5/SimpleLiteDirect3d.WindowsMobile5/ResourceBuilder.cs (revision 222)
+++ forWM5/SimpleLiteDirect3d.WindowsMobile5/ResourceBuilder.cs (revision 252)
@@ -65,12 +65,12 @@
}
public WmCapture createWmCapture()
{
- WmCapture result = new WmCapture(this._cap_size);
+ WmCapture result = new WmCapture(this._cap_size,this._cvertical);
return result;
}
public DsRGB565Raster createARRaster()
{
- return new DsRGB565Raster(this._cap_size.Width, this._cap_size.Height,this._cvertical);
+ return new DsRGB565Raster(this._cap_size.Width, this._cap_size.Height);
}
public D3dManager createD3dManager(Form i_form)
{
@@ -86,9 +86,9 @@
{
switch(this._background_type){
case BGMODE_SURFACE:
- return new D3dSurfaceBackground(i_d3dmgr,this._cvertical);
+ return new D3dSurfaceBackground(i_d3dmgr);
case BGMODE_TEXTURE:
- return new D3dTextureBackground(i_d3dmgr, -1);
+ return new D3dTextureBackground(i_d3dmgr);
default:
throw new Exception("unknown this._background_type");
}
Index: forWM5/SimpleLiteDirect3d.WindowsMobile5/SimpleLiteD3d.cs
===================================================================
--- forWM5/SimpleLiteDirect3d.WindowsMobile5/SimpleLiteD3d.cs (revision 222)
+++ forWM5/SimpleLiteDirect3d.WindowsMobile5/SimpleLiteD3d.cs (revision 252)
@@ -129,7 +129,7 @@
}


- public partial class SimpleLiteD3d : IDisposable,INySampleCB
+ public partial class SimpleLiteD3d : IDisposable, IWmCaptureListener
{
private D3dManager _d3dmgr;
private D3dCube _d3dcube;
@@ -171,14 +171,14 @@
/* 髱槫酔譛溘う繝吶Φ繝医ワ繝ウ繝峨Λ
* CaptureDevice縺九i縺ョ繧、繝吶Φ繝医r繝上Φ繝峨Μ繝ウ繧ー縺励※縲√ヰ繝・ヵ繧。縺ィ繝・け繧ケ繝√Ε繧呈峩譁ー縺吶k縲・
*/
- public int OnSample(INySample i_sample)
+ public void onSample(WmCapture i_sender, INySample i_sample)
{
lock (this)
{
IntPtr data=i_sample.GetData();
- this.m_raster.setBuffer(data);
+ this.m_raster.setBuffer(data, i_sender.vertical_flip);
//繝・け繧ケ繝√Ε蜀・ョケ繧呈峩譁ー
- this._back_ground.setSample(i_sample);
+ this._back_ground.CopyFromRaster(this.m_raster);
//繝槭・繧ォ繝シ縺ッ隕九▽縺九▲縺溘°縺ェ・・
is_marker_enable = this.m_ar.detectMarkerLite(this.m_raster, 110);
if (is_marker_enable)
@@ -189,7 +189,7 @@
}
}
Thread.Sleep(0);
- return 0;
+ return;
}
/* 繧ュ繝」繝励メ繝」繧帝幕蟋九☆繧矩未謨ー
*/
@@ -242,6 +242,7 @@
// 3D繧ェ繝悶ず繧ァ繧ッ繝医・謠冗判縺ッ縺薙%縺九i
this._d3dmgr.d3d_device.BeginScene();
this._back_ground.drawBackGround();
+ this._d3dmgr.d3d_device.RenderState.CullMode = Cull.Clockwise;


//繝槭・繧ォ繝シ縺瑚ヲ九▽縺九▲縺ヲ縺・※縲・.3繧医j荳€閾エ縺励※縺溘i謠冗判縺吶k縲・
@@ -249,7 +250,7 @@
{

//遶区婿菴薙r20mm荳奇シ医・繝シ繧ォ繝シ縺ョ荳奇シ峨↓縺壹i縺励※縺翫¥
- Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f);
+ Matrix transform_mat2 = Matrix.Translation(0, 0, 20.0f);

//螟画鋤陦悟・繧呈寺縺代k
transform_mat2 *= trans_matrix;
Index: forWM5/SimpleLiteDirect3d.WindowsMobile5/D3dManager.cs
===================================================================
--- forWM5/SimpleLiteDirect3d.WindowsMobile5/D3dManager.cs (revision 222)
+++ forWM5/SimpleLiteDirect3d.WindowsMobile5/D3dManager.cs (revision 252)
@@ -101,14 +101,12 @@
new_w = i_client_size.Width;
new_h = (int)(cap_size.h * scale);
}
-
//繝薙Η繝シ繝昴・繝井ス懈・
Viewport vp = new Viewport();
- vp.Height = new_h;
- vp.Width = new_w;
vp.X = (i_client_size.Width - new_w) / 2;
vp.Y = (i_client_size.Height - new_h) / 2;
-
+ vp.Height = new_h;
+ vp.Width = new_w;
//繝薙Η繝シ繝昴・繝郁ィュ螳・
this._d3d_device.Viewport = vp;

Index: forWM5/SimpleLiteDirect3d.WindowsMobile5/Program.cs
===================================================================
--- forWM5/SimpleLiteDirect3d.WindowsMobile5/Program.cs (revision 222)
+++ forWM5/SimpleLiteDirect3d.WindowsMobile5/Program.cs (revision 252)
@@ -85,7 +85,7 @@

}
//繧ュ繝」繝励メ繝」縺ョ蛛懈ュ「
- sample.stop();
+ //sample.stop();
}
}
return;
Index: forWM5/SimpleLiteDirect3d.WindowsMobile5/WmCapture.cs
===================================================================
--- forWM5/SimpleLiteDirect3d.WindowsMobile5/WmCapture.cs (revision 222)
+++ forWM5/SimpleLiteDirect3d.WindowsMobile5/WmCapture.cs (revision 252)
@@ -6,12 +6,18 @@

namespace SimpleLiteDirect3d.WindowsMobile5
{
+ public interface IWmCaptureListener
+ {
+ void onSample(WmCapture i_sender, INySample i_sample);
+ }
public class WmCapture : IDisposable,INySampleCB
{
private INyWMCapture _capture;
- private INySampleCB _on_sample_event=null;
+ private IWmCaptureListener _on_sample_event = null;
private bool _is_start = false;
- public WmCapture(Size i_cap_size)
+ private bool _vertical_flip;
+ public bool vertical_flip { get { return this._vertical_flip; } }
+ public WmCapture(Size i_cap_size,bool i_vertical_flip_property)
{
//繧ュ繝」繝励メ繝」菴懊k縲・
NyWMCapture cap = new NyWMCapture();
@@ -33,6 +39,7 @@
throw new Exception("cap_if.Initialize");
}
this._capture = cap_if;
+ this._vertical_flip = i_vertical_flip_property;
return;
}
public void start()
@@ -49,7 +56,7 @@
this._is_start = false;
return;
}
- public void setOnSample(INySampleCB i_handler)
+ public void setOnSample(IWmCaptureListener i_handler)
{
this._on_sample_event=i_handler;
return;
@@ -58,7 +65,7 @@
{
if (this._on_sample_event != null)
{
- return this._on_sample_event.OnSample(i_sample);
+ this._on_sample_event.onSample(this,i_sample);
}
return 0;
}
Index: forWM5/SimpleLiteDirect3d.WindowsMobile5/D3dBackground.cs
===================================================================
--- forWM5/SimpleLiteDirect3d.WindowsMobile5/D3dBackground.cs (revision 222)
+++ forWM5/SimpleLiteDirect3d.WindowsMobile5/D3dBackground.cs (revision 252)
@@ -27,18 +27,21 @@
using System;
using System.Collections.Generic;
using System.Drawing;
+using System.Diagnostics;
using Microsoft.WindowsMobile.DirectX.Direct3D;
using Microsoft.WindowsMobile.DirectX;
using NyARToolkitCSUtils.Direct3d;
using jp.nyatla.cs.NyWMCapture;
+using jp.nyatla.nyartoolkit.cs.core;
+using NyARToolkitCSUtils.NyAR;
+using System.Runtime.InteropServices;

-
namespace SimpleLiteDirect3d.WindowsMobile5
{
public interface ID3dBackground : IDisposable
{
void drawBackGround();
- void setSample(INySample i_sample);
+ void CopyFromRaster(DsRGB565Raster i_raster);
}
public class D3dSurfaceBackground : ID3dBackground
{
@@ -47,16 +50,13 @@
private D3dManager _d3dm;
private Surface _surface;
private Rectangle _src_rect;
- private bool _vertical_order;
-
- public D3dSurfaceBackground(D3dManager i_mgr, bool i_vertical_order)
+ public D3dSurfaceBackground(D3dManager i_mgr)
{
this._d3dm = i_mgr;
this._height = i_mgr.background_size.Height;
this._width = i_mgr.background_size.Width;
this._surface = i_mgr.d3d_device.CreateImageSurface(this._width, this._height, Format.R5G6B5);
this._src_rect = new Rectangle(0, 0, this._width, this._height);
- this._vertical_order = i_vertical_order;
return;
}
public void drawBackGround()
@@ -66,25 +66,26 @@
this._d3dm.d3d_device.StretchRectangle(this._surface, this._src_rect, dest_surface, this._d3dm.view_rect, TextureFilter.None);
return;
}
- public void setSample(INySample i_sample)
+ public void CopyFromRaster(DsRGB565Raster i_raster)
{
+ Debug.Assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE));
int pitch;
GraphicsStream gs = this._surface.LockRectangle(this._src_rect, LockFlags.None, out pitch);
- if (this._vertical_order)
- {
- int st = this._width * 2;
- int s_idx = 0;
- int d_idx = (this._height - 1) * pitch;
- for (int i = this._height - 1; i >= 0; i--)
- {
- i_sample.CopyToBuffer((IntPtr)((int)gs.InternalData + d_idx), s_idx, st);
- s_idx += st;
- d_idx -= pitch;
- }
- }else{
- i_sample.CopyToBuffer(gs.InternalData, 0, this._width * this._height * 2);
+ /*
+ int cp_size = this.m_width * 4;
+ int s_idx=0;
+ int d_idx = (this.m_height - 1) * cp_size;
+ for(int i=this.m_height-1;i>=0;i--){
+ //縺ゥ縺・€・∴縺ヲ繧ゅ・繧、繝ウ繧ソ縺ァ縺吶€・
+ Marshal.Copy((byte[])i_sample.getBufferReader().getBuffer(),s_idx,(IntPtr)((int)gs.InternalData+d_idx),cp_size);
+ s_idx += cp_size;
+ d_idx -= cp_size;
}
+ */
+ Marshal.Copy((short[])i_raster.getBufferReader().getBuffer(), 0, (IntPtr)((int)gs.InternalData), this._width * this._height);
+
this._surface.UnlockRectangle();
+
return;
}
public void Dispose()
@@ -109,7 +110,7 @@
private Sprite _sprite;
private Vector3 _pos_vec;
private Matrix _scaling;
- public D3dTextureBackground(D3dManager i_mgr,int i_mode)
+ public D3dTextureBackground(D3dManager i_mgr)
{
this._d3dm = i_mgr;
float scale = this._d3dm.scale;
@@ -135,18 +136,22 @@
this._sprite.End();
return;
}
- public void setSample(INySample i_sample)
+ public void CopyFromRaster(DsRGB565Raster i_raster)
{
+ //BUFFERFORMAT_WORD1D_R5G6B5_16LE縺励°蜿励¢繧峨l縺セ縺帙s縲・
+ Debug.Assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE));
int pi;
+ int w = this._width;
GraphicsStream gs = this._texture.LockRectangle(0, LockFlags.None, out pi);
- int st = this._width * 2;
+ short[] buf = (short[])i_raster.getBufferReader().getBuffer();
+ int st = this._width;
int s_idx = 0;
- int d_idx = (this._height - 1) * pi;
+ int d_idx = 0;
for (int i = this._height - 1; i >= 0; i--)
{
- i_sample.CopyToBuffer((IntPtr)((int)gs.InternalData + d_idx), s_idx, st);
+ Marshal.Copy(buf, s_idx, (IntPtr)((int)gs.InternalData + d_idx),w);
s_idx += st;
- d_idx -= pi;
+ d_idx += pi;
}
this._texture.UnlockRectangle(0);
return;
Index: forWM5/NyARToolkitCS.WindowsMobile5/NyARToolkitCS.WindowsMobile5.csproj
===================================================================
--- forWM5/NyARToolkitCS.WindowsMobile5/NyARToolkitCS.WindowsMobile5.csproj (revision 222)
+++ forWM5/NyARToolkitCS.WindowsMobile5/NyARToolkitCS.WindowsMobile5.csproj (revision 252)
@@ -78,6 +78,20 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\match\NyARMatchPatt_Color_WITHOUT_PCA.cs">
<Link>cs\core\match\NyARMatchPatt_Color_WITHOUT_PCA.cs</Link>
</Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\match\NyARMatchPatt_BlackWhite.cs">
+ <Link>cs\core\match\NyARMatchPatt_BlackWhite.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\match\NyARMatchPattDeviationBlackWhiteData.cs">
+ <Link>cs\core\match\NyARMatchPattDeviationBlackWhiteData.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\match\NyARMatchPattDeviationColorData.cs">
+ <Link>cs\core\match\NyARMatchPattDeviationColorData.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\match\NyARMatchPattResult.cs">
+ <Link>cs\core\match\NyARMatchPattResult.cs</Link>
+ </Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARCode.cs">
<Link>cs\core\NyARCode.cs</Link>
</Compile>
@@ -114,12 +128,21 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\pca2d\NyARPca2d_MatrixPCA.cs">
<Link>cs\core\pca2d\NyARPca2d_MatrixPCA.cs</Link>
</Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\pickup\INyARColorPatt.cs">
<Link>cs\core\pickup\INyARColorPatt.cs</Link>
</Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\pickup\NyARColorPatt_O3.cs">
<Link>cs\core\pickup\NyARColorPatt_O3.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\pickup\NyARColorPatt_Perspective.cs">
+ <Link>cs\core\pickup\NyARColorPatt_Perspective.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\pickup\NyARColorPatt_PseudoAffine.cs">
+ <Link>cs\core\pickup\NyARColorPatt_PseudoAffine.cs</Link>
+ </Compile>
+
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\rasterfilter\INyARRasterFilter.cs">
<Link>cs\core\rasterfilter\INyARRasterFilter.cs</Link>
</Compile>
@@ -144,6 +167,16 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\rasterreader\NyARBufferReader.cs">
<Link>cs\core\rasterreader\NyARBufferReader.cs</Link>
</Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\rasterreader\NyARRgbPixelReader_INT1D_GLAY_8.cs">
+ <Link>cs\core\rasterreader\NyARRgbPixelReader_INT1D_GLAY_8.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\rasterreader\NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs">
+ <Link>cs\core\rasterreader\NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs</Link>
+ </Compile>
+
+
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\rasterreader\NyARRgbPixelReader_RGB24.cs">
<Link>cs\core\rasterreader\NyARRgbPixelReader_RGB24.cs</Link>
</Compile>
@@ -156,9 +189,14 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\raster\NyARGrayscaleRaster.cs">
<Link>cs\core\raster\NyARGrayscaleRaster.cs</Link>
</Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\raster\NyARRaster_BasicClass.cs">
<Link>cs\core\raster\NyARRaster_BasicClass.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\raster\NyARRaster.cs">
+ <Link>cs\core\raster\NyARRaster.cs</Link>
+ </Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\raster\rgb\INyARRgbRaster.cs">
<Link>cs\core\raster\rgb\INyARRgbRaster.cs</Link>
</Compile>
@@ -219,6 +257,10 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\matrix\NyARDoubleMatrix34.cs">
<Link>cs\core\types\matrix\NyARDoubleMatrix34.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\matrix\NyARDoubleMatrix44.cs">
+ <Link>cs\core\types\matrix\NyARDoubleMatrix44.cs</Link>
+ </Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\NyARDoublePoint2d.cs">
<Link>cs\core\types\NyARDoublePoint2d.cs</Link>
</Compile>
@@ -237,12 +279,31 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\NyARLinear.cs">
<Link>cs\core\types\NyARLinear.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\NyARIntPoint2d.cs">
+ <Link>cs\core\types\NyARIntPoint2d.cs</Link>
+ </Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\stack\NyARIntPointStack.cs">
<Link>cs\core\types\stack\NyARIntPointStack.cs</Link>
</Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\stack\NyARIntRectStack.cs">
<Link>cs\core\types\stack\NyARIntRectStack.cs</Link>
</Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\utils\NyARDoubleMatrixProcessor.cs">
+ <Link>cs\core\utils\NyARDoubleMatrixProcessor.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\utils\NyARPerspectiveParamGenerator.cs">
+ <Link>cs\core\utils\NyARPerspectiveParamGenerator.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\utils\NyARPerspectiveParamGenerator_O1.cs">
+ <Link>cs\core\utils\NyARPerspectiveParamGenerator_O1.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\utils\NyARSystemOfLinearEquationsProcessor.cs">
+ <Link>cs\core\utils\NyARSystemOfLinearEquationsProcessor.cs</Link>
+ </Compile>
+
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\NyARException.cs">
<Link>cs\NyARException.cs</Link>
</Compile>
@@ -264,6 +325,41 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\detector\NyARSingleDetectMarker.cs">
<Link>cs\detector\NyARSingleDetectMarker.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\detector\NyARCustomSingleDetectMarker.cs">
+ <Link>cs\detector\NyARCustomSingleDetectMarker.cs</Link>
+ </Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\NyIdMarkerParam.cs">
+ <Link>cs\nyidmarker\NyIdMarkerParam.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\NyIdMarkerPattern.cs">
+ <Link>cs\nyidmarker\NyIdMarkerPattern.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\NyIdMarkerPickup.cs">
+ <Link>cs\nyidmarker\NyIdMarkerPickup.cs</Link>
+ </Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\data\INyIdMarkerData.cs">
+ <Link>cs\nyidmarker\data\INyIdMarkerData.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\data\INyIdMarkerDataEncoder.cs">
+ <Link>cs\nyidmarker\data\INyIdMarkerDataEncoder.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\data\NyIdMarkerData_RawBit.cs">
+ <Link>cs\nyidmarker\data\NyIdMarkerData_RawBit.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\nyidmarker\data\NyIdMarkerDataEncoder_RawBit.cs">
+ <Link>cs\nyidmarker\data\NyIdMarkerDataEncoder_RawBit.cs</Link>
+ </Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\processor\SingleARMarkerProcesser.cs">
+ <Link>cs\processor\SingleARMarkerProcesser.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\processor\SingleNyIdMarkerProcesser.cs">
+ <Link>cs\processor\SingleNyIdMarkerProcesser.cs</Link>
+ </Compile>
+
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\utils.cs\ArrayUtils.cs">
<Link>cs\utils.cs\ArrayUtils.cs</Link>
</Compile>
@@ -303,6 +399,15 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core2\types\NyARI64Point3d.cs">
<Link>cs\core2\types\NyARI64Point3d.cs</Link>
</Compile>
+
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core2\rasteranalyzer\threshold\INyARRasterThresholdAnalyzer.cs">
+ <Link>cs\core2\rasteranalyzer\threshold\INyARRasterThresholdAnalyzer.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core2\rasteranalyzer\threshold\NyARRasterThresholdAnalyzer_SlidePTile.cs">
+ <Link>cs\core2\rasteranalyzer\threshold\NyARRasterThresholdAnalyzer_SlidePTile.cs</Link>
+ </Compile>
+
+
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
Index: forWM5/NyARToolkitCSUtils.WindowsMobile5/Direct3d/NyARSurface_RGB565.cs
===================================================================
--- forWM5/NyARToolkitCSUtils.WindowsMobile5/Direct3d/NyARSurface_RGB565.cs (revision 222)
+++ forWM5/NyARToolkitCSUtils.WindowsMobile5/Direct3d/NyARSurface_RGB565.cs (revision 252)
@@ -32,8 +32,10 @@
using Microsoft.WindowsMobile.DirectX.Direct3D;
using System.Runtime.InteropServices;
using jp.nyatla.cs.NyWMCapture;
+using jp.nyatla.nyartoolkit.cs.core;
+using NyARToolkitCSUtils.NyAR;
+using System.Diagnostics;

-
namespace NyARToolkitCSUtils.Direct3d
{
/* DsRGB556Raster縺ョ繝ゥ繧ケ繧ソ繝・・繧ソ繧貞叙繧願セシ繧€縺薙→縺悟・譚・繧鬼urface縺ァ縺吶€・
@@ -41,10 +43,11 @@
*/
public class NyARSurface_RGB565 : IDisposable
{
+
private int _width;
private int _height;
private Microsoft.WindowsMobile.DirectX.Direct3D.Device m_ref_dev;
- private Surface m_surface;
+ private Surface _surface;
private Rectangle m_src_rect;
public Rectangle d3d_surface_rect
{
@@ -52,7 +55,7 @@
}
public Surface d3d_surface
{
- get { return this.m_surface; }
+ get { return this._surface; }
}

/* i_width x i_height縺ョ繝・け繧ケ繝√Ε繧呈シ邏阪☆繧九う繝ウ繧ケ繧ソ繝ウ繧ケ繧堤函謌舌@縺セ縺吶€・
@@ -67,42 +70,29 @@
this._height = i_height;
this._width = i_width;

- this.m_surface = i_dev.CreateImageSurface(i_width, i_height, Format.R5G6B5);
+ this._surface = i_dev.CreateImageSurface(i_width, i_height, Format.R5G6B5);
this.m_src_rect = new Rectangle(0, 0, i_width,i_height);

//OK縲∝ョ梧・縺縲・
return;
}
- /* ISample縺ョ蜀・ョケ繧剃ソ晄戟縺励※縺・k繧オ繝シ繝輔ぉ繧、繧ケ縺ォ繧ウ繝斐・縺励∪縺吶€・
- * i_is_top_to_botomm縺ッ縲(_sample縺御ク贋ク句渚霆「逕サ蜒・Y霆ク縺御ク九°繧我ク翫↓蜷代°縺」縺ヲ蠅怜刈縺吶k)縺九r謖・ョ壹@縺セ縺吶€・
- */
- public void CopyFromIntPtr(INySample i_sample,bool i_is_top_to_botomm)
+ public void CopyFromRaster(DsRGB565Raster i_raster)
{
+ Debug.Assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE));
int pitch;
- GraphicsStream gs = this.m_surface.LockRectangle(this.m_src_rect, LockFlags.None, out pitch);
- if (!i_is_top_to_botomm)
- {
- int st = this._width * 2;
- int s_idx = 0;
- int d_idx = (this._height - 1) * pitch;
- for (int i = this._height - 1; i >= 0; i--)
- {
- i_sample.CopyToBuffer((IntPtr)((int)gs.InternalData + d_idx), s_idx, st);
- s_idx += st;
- d_idx -= pitch;
- }
- }else{
- i_sample.CopyToBuffer(gs.InternalData, 0, this._width * this._height * 2);
- }
- this.m_surface.UnlockRectangle();
+ GraphicsStream gs = this._surface.LockRectangle(this.m_src_rect,LockFlags.None, out pitch);
+ Marshal.Copy((short[])i_raster.getBufferReader().getBuffer(), 0, (IntPtr)((int)gs.InternalData), this._width * 2 * this._height);

+ this._surface.UnlockRectangle();
+
return;
- }
+ }
+
public void Dispose()
{
- if (this.m_surface != null)
+ if (this._surface != null)
{
- this.m_surface.Dispose();
+ this._surface.Dispose();
}
return;
}
Index: forWM5/NyARToolkitCSUtils.WindowsMobile5/Direct3d/NyARTexture_RGB565.cs
===================================================================
--- forWM5/NyARToolkitCSUtils.WindowsMobile5/Direct3d/NyARTexture_RGB565.cs (revision 222)
+++ forWM5/NyARToolkitCSUtils.WindowsMobile5/Direct3d/NyARTexture_RGB565.cs (revision 252)
@@ -34,6 +34,9 @@
using Microsoft.WindowsMobile.DirectX.Direct3D;
using System.Runtime.InteropServices;
using jp.nyatla.cs.NyWMCapture;
+using jp.nyatla.nyartoolkit.cs.core;
+using NyARToolkitCSUtils.NyAR;
+using System.Diagnostics;

namespace NyARToolkitCSUtils.Direct3d
{
@@ -97,28 +100,23 @@
//OK縲∝ョ梧・縺縲・
return;
}
- /* DsXRGB32Raster縺ョ蜀・ョケ繧剃ソ晄戟縺励※縺・k繝・け繧ケ繝√Ε縺ォ繧ウ繝斐・縺励∪縺吶€・
- * i_raster縺ョ繧オ繧、繧コ縺ッ縲√%縺ョ繧、繝ウ繧ケ繧ソ繝ウ繧ケ縺ォ謖・ョ壹@縺溘ユ繧ッ繧ケ繝√Ε繧オ繧、繧コ・医さ繝ウ繧ケ繝医Λ繧ッ繧ソ遲峨↓謖・ョ壹@縺溘し繧、繧コ・峨→蜷後§縺ァ縺ゅk蠢・ヲ√〒縺吶€・
- * 繝ゥ繧ケ繧ソ繝・・繧ソ縺ッ繝・け繧ケ繝√Ε縺ョ蟾ヲ荳翫r蝓コ轤ケ縺ォwidth x height縺縺代さ繝斐・縺輔l縲∵ョ九j縺ョ驛ィ蛻・・譖エ譁ー縺輔l縺セ縺帙s縲・
- */
- public void CopyFromIntPtr(INySample i_sample)
+ public void CopyFromRaster(DsRGB565Raster i_raster)
{
+ //BUFFERFORMAT_WORD1D_R5G6B5_16LE縺励°蜿励¢繧峨l縺セ縺帙s縲・
+ Debug.Assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE));
int pi;
+ int w = this.m_width;
GraphicsStream gs = this._texture.LockRectangle(0, LockFlags.None, out pi);
-// if (i_is_top_to_botomm)
-// {
- int st = this.m_width * 2;
- int s_idx = 0;
- int d_idx = (this.m_height - 1) * pi;
- for (int i = this.m_height - 1; i >= 0; i--)
- {
- i_sample.CopyToBuffer((IntPtr)((int)gs.InternalData + d_idx), s_idx, st);
- s_idx += st;
- d_idx -= pi;
- }
-// }else{
-// i_sample.CopyToBuffer(gs.InternalData, 0, this.m_width * this.m_height * 2);
-// }
+ short[] buf = (short[])i_raster.getBufferReader().getBuffer();
+ int st = this.m_width;
+ int s_idx = 0;
+ int d_idx = 0;
+ for (int i = this.m_height - 1; i >= 0; i--)
+ {
+ Marshal.Copy(buf, s_idx, (IntPtr)((int)gs.InternalData + d_idx), w);
+ s_idx += st;
+ d_idx += pi;
+ }
this._texture.UnlockRectangle(0);
return;
}
Index: forFW2.0/NyARToolkitCS.sln
===================================================================
--- forFW2.0/NyARToolkitCS.sln (revision 222)
+++ forFW2.0/NyARToolkitCS.sln (revision 252)
@@ -1,10 +1,8 @@
・ソ
Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C# Express 2008
+# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NyARToolkitCS", "NyARToolkitCS\NyARToolkitCS.csproj", "{80391577-476D-4DAD-A4F8-F03C726ACBD8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaptureTest", "sample\CaptureTest\CaptureTest.csproj", "{BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NyARToolkitCSUtils", "NyARToolkitCSUtils\NyARToolkitCSUtils.csproj", "{1D202933-65C8-4568-9756-87E57D294132}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleLiteDirect3d", "sample\SimpleLiteDirect3d\SimpleLiteDirect3d.csproj", "{9E518563-40C4-41CD-98E4-480C952DA123}"
@@ -20,6 +18,10 @@
{80391577-476D-4DAD-A4F8-F03C726ACBD8} = {80391577-476D-4DAD-A4F8-F03C726ACBD8}
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleNyIdMarkerDirect3d", "sample\SingleNyIdMarkerDirect3d\SingleNyIdMarkerDirect3d.csproj", "{58DB6E91-4B1F-4C08-8925-E02A79708272}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaptureTest", "sample\CaptureTest\CaptureTest.csproj", "{BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -30,10 +32,6 @@
{80391577-476D-4DAD-A4F8-F03C726ACBD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80391577-476D-4DAD-A4F8-F03C726ACBD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80391577-476D-4DAD-A4F8-F03C726ACBD8}.Release|Any CPU.Build.0 = Release|Any CPU
- {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Release|Any CPU.Build.0 = Release|Any CPU
{1D202933-65C8-4568-9756-87E57D294132}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D202933-65C8-4568-9756-87E57D294132}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D202933-65C8-4568-9756-87E57D294132}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -50,6 +48,14 @@
{07B19A8B-33C7-4234-8FF6-2FF240B819AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07B19A8B-33C7-4234-8FF6-2FF240B819AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07B19A8B-33C7-4234-8FF6-2FF240B819AA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {58DB6E91-4B1F-4C08-8925-E02A79708272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {58DB6E91-4B1F-4C08-8925-E02A79708272}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {58DB6E91-4B1F-4C08-8925-E02A79708272}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {58DB6E91-4B1F-4C08-8925-E02A79708272}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BAB42EC0-98F1-464E-AB3D-39B1E7FE0AB3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Index: forFW2.0/tools/ABGRcapture/ABGRAcapture.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/ABGRAcapture.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/ABGRAcapture.cs (revision 252)
@@ -0,0 +1,208 @@
+・ソ/*
+ * Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Threading;
+using System.Windows.Forms;
+using Microsoft.DirectX;
+using Microsoft.DirectX.Direct3D;
+using NyARToolkitCSUtils.Capture;
+using NyARToolkitCSUtils.Direct3d;
+using NyARToolkitCSUtils.NyAR;
+using jp.nyatla.nyartoolkit.cs;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.detector;
+
+namespace SimpleLiteDirect3d
+{
+
+ public partial class ABGRAcapture : IDisposable, CaptureListener
+ {
+ private const int SCREEN_WIDTH = 320;
+ private const int SCREEN_HEIGHT = 240;
+ //DirectShow縺九i縺ョ繧ュ繝」繝励メ繝」
+ private CaptureDevice _cap;
+ //NyAR
+ private DsBGRX32Raster _raster;
+ //閭梧勹繝・け繧ケ繝√Ε
+ private NyARSurface_XRGB32 _surface;
+ /// Direct3D 繝・ヰ繧、繧ケ
+ private Device _device = null;
+ // 鬆らせ繝舌ャ繝輔ぃ/繧、繝ウ繝・ャ繧ッ繧ケ繝舌ャ繝輔ぃ/繧、繝ウ繝・ャ繧ッ繧ケ繝舌ャ繝輔ぃ縺ョ蜷・らせ逡ェ蜿キ驟榊・
+ /* 髱槫酔譛溘う繝吶Φ繝医ワ繝ウ繝峨Λ
+ * CaptureDevice縺九i縺ョ繧、繝吶Φ繝医r繝上Φ繝峨Μ繝ウ繧ー縺励※縲√ヰ繝・ヵ繧。縺ィ繝・け繧ケ繝√Ε繧呈峩譁ー縺吶k縲・
+ */
+ public void OnBuffer(CaptureDevice i_sender, double i_sample_time, IntPtr i_buffer, int i_buffer_len)
+ {
+ int w = i_sender.video_width;
+ int h = i_sender.video_height;
+ int s = w * (i_sender.video_bit_count / 8);
+
+ //繝・け繧ケ繝√Ε縺ォRGB繧貞叙繧願セシ縺ソ()
+ lock (this)
+ {
+ //繧ォ繝。繝ゥ譏蜒上rAR縺ョ繝舌ャ繝輔ぃ縺ォ繧ウ繝斐・
+ this._raster.setBuffer(i_buffer,i_sender.video_vertical_flip);
+
+ //繝・け繧ケ繝√Ε蜀・ョケ繧呈峩譁ー
+ this._surface.CopyFromXRGB32(this._raster);
+ }
+ return;
+ }
+ /* 繧ュ繝」繝励メ繝」繧帝幕蟋九☆繧矩未謨ー
+ */
+ public void StartCap()
+ {
+ this._cap.StartCapture();
+ }
+ /* 繧ュ繝」繝励メ繝」繧貞●豁「縺吶k髢「謨ー
+ */
+ public void StopCap()
+ {
+ this._cap.StopCapture();
+ }
+ public void saveRawFile(String i_filename)
+ {
+ lock (this)
+ {
+ using (FileStream fs = new FileStream(i_filename, FileMode.Create))
+ {
+ using (BinaryWriter bw = new BinaryWriter(fs))
+ {
+ bw.Write((byte[])this._raster.getBufferReader().getBuffer());
+ }
+ }
+ }
+ }
+
+ /* Direct3D繝・ヰ繧、繧ケ繧呈コ門y縺吶k髢「謨ー
+ */
+ private Device PrepareD3dDevice(Control i_window)
+ {
+ PresentParameters pp = new PresentParameters();
+
+ // 繧ヲ繧、繝ウ繝峨え繝「繝シ繝峨↑繧・true縲√ヵ繝ォ繧ケ繧ッ繝ェ繝シ繝ウ繝「繝シ繝峨↑繧・false 繧呈欠螳・
+ pp.Windowed = true;
+ // 繧ケ繝ッ繝・・縺ィ繧翫≠縺医★Discard繧呈欠螳壹€・
+ pp.SwapEffect = SwapEffect.Flip;
+ pp.BackBufferFormat = Format.X8R8G8B8;
+ pp.BackBufferCount = 1;
+ CreateFlags fl_base = CreateFlags.FpuPreserve;
+
+ try
+ {
+ return new Device(0, DeviceType.Hardware, i_window.Handle, fl_base | CreateFlags.HardwareVertexProcessing, pp);
+ }
+ catch (Exception ex1)
+ {
+ Debug.WriteLine(ex1.ToString());
+ try
+ {
+ return new Device(0, DeviceType.Hardware, i_window.Handle, fl_base | CreateFlags.SoftwareVertexProcessing, pp);
+ }
+ catch (Exception ex2)
+ {
+ // 菴懈・縺ォ螟ア謨・
+ Debug.WriteLine(ex2.ToString());
+ try
+ {
+ return new Device(0, DeviceType.Reference, i_window.Handle, fl_base | CreateFlags.SoftwareVertexProcessing, pp);
+ }
+ catch (Exception ex3)
+ {
+ throw ex3;
+ }
+ }
+ }
+ }
+ public bool InitializeApplication(Form1 topLevelForm, CaptureDevice i_cap_device)
+ {
+ //繧ュ繝」繝励メ繝」繧剃ス懊k(QVGA縺ァ繝輔Ξ繝シ繝繝ャ繝シ繝医・30)
+ i_cap_device.SetCaptureListener(this);
+ i_cap_device.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30);
+ this._cap = i_cap_device;
+
+ //AR縺ョ險ュ螳・
+
+ //AR繝ゥ繧ケ繧ソ繧剃ス懊k(DirectShow繧ュ繝」繝励メ繝」莉墓ァ・縲・
+ this._raster = new DsBGRX32Raster(i_cap_device.video_width, i_cap_device.video_height, i_cap_device.video_width * i_cap_device.video_bit_count / 8);
+
+
+
+
+
+ //3d繝・ヰ繧、繧ケ繧呈コ門y縺吶k
+ this._device = PrepareD3dDevice(topLevelForm);
+
+ // 繝ゥ繧、繝医r辟。蜉ケ
+ this._device.RenderState.Lighting = false;
+
+ //閭梧勹繧オ繝シ繝輔ぉ繧、繧ケ繧剃ス懈・
+ this._surface = new NyARSurface_XRGB32(this._device, SCREEN_WIDTH, SCREEN_HEIGHT);
+
+ return true;
+ }
+ private Matrix __MainLoop_trans_matrix = new Matrix();
+ private NyARTransMatResult __MainLoop_nyar_transmat = new NyARTransMatResult();
+ //繝。繧、繝ウ繝ォ繝シ繝怜・逅・
+ public void MainLoop()
+ {
+ //AR縺ョ險育ョ・
+ lock (this)
+ {
+ // 閭梧勹繧オ繝シ繝輔ぉ繧、繧ケ繧堤峩謗・謠冗判
+ Surface dest_surface = this._device.GetBackBuffer(0, 0, BackBufferType.Mono);
+ Rectangle src_dest_rect = new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ this._device.StretchRectangle(this._surface.d3d_surface, src_dest_rect, dest_surface, src_dest_rect, TextureFilter.None);
+
+ // 3D繧ェ繝悶ず繧ァ繧ッ繝医・謠冗判縺ッ縺薙%縺九i
+ this._device.BeginScene();
+
+
+ // 謠冗判縺ッ縺薙%縺セ縺ァ
+ this._device.EndScene();
+
+ // 螳滄圀縺ョ繝・ぅ繧ケ繝励Ξ繧、縺ォ謠冗判
+ this._device.Present();
+ }
+
+ }
+
+ // 繝ェ繧ス繝シ繧ケ縺ョ遐エ譽・r縺吶k縺溘a縺ォ蜻シ縺ー繧後k
+ public void Dispose()
+ {
+ // Direct3D 繝・ヰ繧、繧ケ縺ョ繝ェ繧ス繝シ繧ケ隗」謾セ
+ if (this._device != null)
+ {
+ this._device.Dispose();
+ }
+ }
+ }
+}
Index: forFW2.0/tools/ABGRcapture/Form1.Designer.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Form1.Designer.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Form1.Designer.cs (revision 252)
@@ -0,0 +1,65 @@
+・ソnamespace SimpleLiteDirect3d
+{
+ partial class Form1
+ {
+ /// <summary>
+ /// 蠢・ヲ√↑繝・じ繧、繝雁、画焚縺ァ縺吶€・
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// 菴ソ逕ィ荳ュ縺ョ繝ェ繧ス繝シ繧ケ繧偵☆縺ケ縺ヲ繧ッ繝ェ繝シ繝ウ繧「繝・・縺励∪縺吶€・
+ /// </summary>
+ /// <param name="disposing">繝槭ロ繝シ繧ク 繝ェ繧ス繝シ繧ケ縺檎エ譽・&繧後k蝣エ蜷・true縲∫エ譽・&繧後↑縺・エ蜷医・ false 縺ァ縺吶€・/param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 繝輔か繝シ繝 繝・じ繧、繝翫〒逕滓・縺輔l縺溘さ繝シ繝・
+
+ /// <summary>
+ /// 繝・じ繧、繝・繧オ繝昴・繝医↓蠢・ヲ√↑繝。繧ス繝・ラ縺ァ縺吶€ゅ%縺ョ繝。繧ス繝・ラ縺ョ蜀・ョケ繧・
+ /// 繧ウ繝シ繝・繧ィ繝・ぅ繧ソ縺ァ螟画峩縺励↑縺・〒縺上□縺輔>縲・
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(15, 11);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 0;
+ this.button1.Text = "capture";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(314, 208);
+ this.Controls.Add(this.button1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.Name = "Form1";
+ this.Text = "NyARToolkitCS SimpleLiteDirect3d";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button button1;
+ }
+}
+
Index: forFW2.0/tools/ABGRcapture/Form1.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Form1.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Form1.cs (revision 252)
@@ -0,0 +1,75 @@
+・ソ/*
+ * Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Diagnostics;
+using System.Text;
+using System.Windows.Forms;
+
+namespace SimpleLiteDirect3d
+{
+ public partial class Form1 : Form
+ {
+ public ABGRAcapture ref_cap;
+ public Form1()
+ {
+ InitializeComponent();
+ this.ClientSize = new Size(320,240);
+ }
+
+ private void Form1_MouseDown(object sender, MouseEventArgs e)
+ {
+
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ using (SaveFileDialog s = new SaveFileDialog())
+ {
+ s.DefaultExt = "raw";
+ ref_cap.StopCap();
+ switch (s.ShowDialog(this))
+ {
+ case DialogResult.OK:
+ ref_cap.saveRawFile(s.FileName);
+ break;
+ default:
+ break;
+ }
+ ref_cap.StartCap();
+ }
+ }
+ }
+}
Index: forFW2.0/tools/ABGRcapture/Form2.Designer.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Form2.Designer.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Form2.Designer.cs (revision 252)
@@ -0,0 +1,91 @@
+・ソnamespace SimpleLiteDirect3d
+{
+ partial class Form2
+ {
+ /// <summary>
+ /// 蠢・ヲ√↑繝・じ繧、繝雁、画焚縺ァ縺吶€・
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// 菴ソ逕ィ荳ュ縺ョ繝ェ繧ス繝シ繧ケ繧偵☆縺ケ縺ヲ繧ッ繝ェ繝シ繝ウ繧「繝・・縺励∪縺吶€・
+ /// </summary>
+ /// <param name="disposing">繝槭ロ繝シ繧ク 繝ェ繧ス繝シ繧ケ縺檎エ譽・&繧後k蝣エ蜷・true縲∫エ譽・&繧後↑縺・エ蜷医・ false 縺ァ縺吶€・/param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 繝輔か繝シ繝 繝・じ繧、繝翫〒逕滓・縺輔l縺溘さ繝シ繝・
+
+ /// <summary>
+ /// 繝・じ繧、繝・繧オ繝昴・繝医↓蠢・ヲ√↑繝。繧ス繝・ラ縺ァ縺吶€ゅ%縺ョ繝。繧ス繝・ラ縺ョ蜀・ョケ繧・
+ /// 繧ウ繝シ繝・繧ィ繝・ぅ繧ソ縺ァ螟画峩縺励↑縺・〒縺上□縺輔>縲・
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.comboBox1 = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBox1
+ //
+ this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(14, 34);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(294, 20);
+ this.comboBox1.TabIndex = 0;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(162, 12);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "菴ソ逕ィ縺吶k繧ォ繝。繝ゥ繧帝∈謚槭@縺ヲ荳九&縺・€・;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(121, 106);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 3;
+ this.button1.Text = "OK";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click_1);
+ //
+ // Form2
+ //
+ this.AcceptButton = this.button1;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(318, 141);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.comboBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "Form2";
+ this.RightToLeftLayout = true;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Form2";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button button1;
+ }
+}
\ No newline at end of file
Index: forFW2.0/tools/ABGRcapture/Form2.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Form2.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Form2.cs (revision 252)
@@ -0,0 +1,69 @@
+・ソ/*
+ * Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Windows.Forms;
+using NyARToolkitCSUtils.Capture;
+
+namespace SimpleLiteDirect3d
+{
+ public partial class Form2 : Form
+ {
+ public Form2()
+ {
+ InitializeComponent();
+ }
+ public DialogResult ShowDialog(CaptureDeviceList i_clist,out int o_selected_no)
+ {
+ if (i_clist.count < 1)
+ {
+ throw new Exception("繧ォ繝。繝ゥ縺檎┌縺・・縺ォ驕ク縺シ縺・→縺励※縺ッ縺・¢縺ェ縺・€・);
+ }
+ for (int i = 0; i < i_clist.count; i++)
+ {
+ this.comboBox1.Items.Add(i_clist[i].name + ":");
+ }
+ this.comboBox1.SelectedIndex = 0;
+ DialogResult ret=base.ShowDialog();
+ o_selected_no = this.comboBox1.SelectedIndex;
+ return ret;
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void button1_Click_1(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
Index: forFW2.0/tools/ABGRcapture/Program.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Program.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Program.cs (revision 252)
@@ -0,0 +1,110 @@
+・ソ/*
+ * Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using System.Threading;
+using NyARToolkitCSUtils.Capture;
+/**
+ *
+ * 縺薙・繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝縺ッ縲¨yARToolkit縺ョSimpleLite逶ク蠖薙・繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝縺ァ縺吶€・
+ * Hiro繝槭・繧ォ繝シ繧定ュ伜挨縺励€∵怙繧ゆク€閾エ縺吶k繝槭・繧ォ繝シ縺ョ荳翫↓縲∫ォ区婿菴薙r陦ィ遉コ縺励∪縺吶€・
+ *
+ * Direct3D縺ョ蜊倅ス咲ウサ縺ッ縲・.0繧・mm縺ィ縺励※縺・∪縺吶€・
+ * 隕也せ縺ッ0,0,0縺九i縲〇+譁ケ蜷代r蜷代>縺ヲ縲∽ク頑婿蜷代′Y+縺ァ縺吶€・
+ *
+ * 螳溯」・↓縺ッ縲∽ク玖ィ篭RL縺ョ諠・ア繧貞盾閠・↓縺励※縺・∪縺吶€・
+ * http://sorceryforce.com/manageddirectx/index.html
+ * http://codezine.jp/a/article/aid/226.aspx?p=2
+ */
+namespace SimpleLiteDirect3d
+{
+ static class Program
+ {
+ /// <summary>
+ /// 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ縺ョ繝。繧、繝ウ 繧ィ繝ウ繝医Μ 繝昴う繝ウ繝医〒縺吶€・
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+
+
+ //繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ繝ェ繧ケ繝医r蜿門セ・
+ CaptureDeviceList capture_device_list = new CaptureDeviceList();
+ if (capture_device_list.count < 1)
+ {
+ MessageBox.Show("繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ縺瑚ヲ九▽縺九j縺セ縺帙s縺ァ縺励◆縲・);
+ return;
+ }
+ //繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ繧帝∈謚槭@縺ヲ繧ゅi縺・€・
+ int cdevice_number = 0;
+ using (Form2 frm2 = new Form2())
+ {
+ frm2.ShowDialog(capture_device_list, out cdevice_number);
+ }
+ using (CaptureDevice capture_device = capture_device_list[cdevice_number])
+ {
+
+
+ // 繝輔か繝シ繝縺ィ繝。繧、繝ウ繧オ繝ウ繝励Ν繧ッ繝ゥ繧ケ繧剃ス懈・
+ using (Form1 frm = new Form1())
+ using (ABGRAcapture sample = new ABGRAcapture())
+ {
+ frm.ref_cap = sample;
+ // 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ縺ョ蛻晄悄蛹・
+ if (sample.InitializeApplication(frm, capture_device))
+ {
+ // 繝。繧、繝ウ繝輔か繝シ繝繧定。ィ遉コ
+ frm.Show();
+ //繧ュ繝」繝励メ繝」髢句ァ・
+ sample.StartCap();
+ // 繝輔か繝シ繝縺御ス懈・縺輔l縺ヲ縺・k髢薙・繝ォ繝シ繝励@邯壹¢繧・
+ while (frm.Created)
+ {
+ // 繝。繧、繝ウ繝ォ繝シ繝怜・逅・r陦後≧
+ sample.MainLoop();
+
+ //繧ケ繝ャ繝・ラ繧ケ繧、繝・メ
+ Thread.Sleep(1);
+
+ // 繧、繝吶Φ繝医′縺ゅk蝣エ蜷医・縺昴・蜃ヲ逅・☆繧・
+ Application.DoEvents();
+ }
+ //繧ュ繝」繝励メ繝」縺ョ蛛懈ュ「
+ sample.StopCap();
+ }
+ else
+ {
+ // 蛻晄悄蛹悶↓螟ア謨・
+ }
+ }
+ }
+ }
+ }
+}
Index: forFW2.0/tools/ABGRcapture/Properties/AssemblyInfo.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Properties/AssemblyInfo.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Properties/AssemblyInfo.cs (revision 252)
@@ -0,0 +1,36 @@
+・ソusing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 繧「繧サ繝ウ繝悶Μ縺ォ髢「縺吶k荳€闊ャ諠・ア縺ッ莉・荳九・螻樊€ァ繧サ繝・ヨ繧偵→縺翫@縺ヲ蛻カ蠕。縺輔l縺セ縺吶€・
+// 繧「繧サ繝ウ繝悶Μ縺ォ髢「騾」莉倥¢繧峨l縺ヲ縺・k諠・ア繧貞、画峩縺吶k縺ォ縺ッ縲・
+// 縺薙l繧峨・螻樊€ァ蛟、繧貞、画峩縺励※縺上□縺輔>縲・
+[assembly: AssemblyTitle("SimpleLiteDirect3d")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SimpleLiteDirect3d")]
+[assembly: AssemblyCopyright("Copyright ツゥ 2008")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible 繧・false 縺ォ險ュ螳壹☆繧九→縲√◎縺ョ蝙九・縺薙・繧「繧サ繝ウ繝悶Μ蜀・〒 COM 繧ウ繝ウ繝昴・繝阪Φ繝医°繧・
+// 蜿ら・荳榊庄閭ス縺ォ縺ェ繧翫∪縺吶€・OM 縺九i縺薙・繧「繧サ繝ウ繝悶Μ蜀・・蝙九↓繧「繧ッ繧サ繧ケ縺吶k蝣エ蜷医・縲・
+// 縺昴・蝙九・ ComVisible 螻樊€ァ繧・true 縺ォ險ュ螳壹@縺ヲ縺上□縺輔>縲・
+[assembly: ComVisible(false)]
+
+// 谺。縺ョ GUID 縺ッ縲√%縺ョ繝励Ο繧ク繧ァ繧ッ繝医′ COM 縺ォ蜈ャ髢九&繧後k蝣エ蜷医・縲》ypelib 縺ョ ID 縺ァ縺・
+[assembly: Guid("9a3f25d8-2a14-4379-b8c0-30528689658f")]
+
+// 繧「繧サ繝ウ繝悶Μ縺ョ繝舌・繧ク繝ァ繝ウ諠・ア縺ッ縲∽サ・荳九・ 4 縺、縺ョ蛟、縺ァ讒区・縺輔l縺ヲ縺・∪縺・
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// 縺吶∋縺ヲ縺ョ蛟、繧呈欠螳壹☆繧九°縲∽ク九・繧医≧縺ォ '*' 繧剃スソ縺」縺ヲ繝薙Ν繝峨♀繧医・繝ェ繝薙ず繝ァ繝ウ逡ェ蜿キ繧・
+// 譌「螳壼€、縺ォ縺吶k縺薙→縺後〒縺阪∪縺・
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: forFW2.0/tools/ABGRcapture/Properties/Settings.Designer.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Properties/Settings.Designer.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Properties/Settings.Designer.cs (revision 252)
@@ -0,0 +1,30 @@
+・ソ//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SimpleLiteDirect3d.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
Index: forFW2.0/tools/ABGRcapture/Properties/Resources.Designer.cs
===================================================================
--- forFW2.0/tools/ABGRcapture/Properties/Resources.Designer.cs (revision 0)
+++ forFW2.0/tools/ABGRcapture/Properties/Resources.Designer.cs (revision 252)
@@ -0,0 +1,71 @@
+・ソ//------------------------------------------------------------------------------
+// <auto-generated>
+// 縺薙・繧ウ繝シ繝峨・繝・・繝ォ縺ォ繧医▲縺ヲ逕滓・縺輔l縺セ縺励◆縲・
+// 繝ゥ繝ウ繧ソ繧、繝 繝舌・繧ク繝ァ繝ウ:2.0.50727.1433
+//
+// 縺薙・繝輔ぃ繧、繝ォ縺ク縺ョ螟画峩縺ッ縲∽サ・荳九・迥カ豕∽ク九〒荳肴ュ」縺ェ蜍穂ス懊・蜴溷屏縺ォ縺ェ縺」縺溘j縲・
+// 繧ウ繝シ繝峨′蜀咲函謌舌&繧後k縺ィ縺阪↓謳榊、ア縺励◆繧翫@縺セ縺・
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SimpleLiteDirect3d.Properties
+{
+
+
+ /// <summary>
+ /// 繝ュ繝シ繧ォ繝ゥ繧、繧コ縺輔l縺滓枚蟄怜・縺ェ縺ゥ繧呈、懃エ「縺吶k縺溘a縺ョ縲∝宍蟇・↓蝙区欠螳壹&繧後◆繝ェ繧ス繝シ繧ケ 繧ッ繝ゥ繧ケ縺ァ縺吶€・
+ /// </summary>
+ // 縺薙・繧ッ繝ゥ繧ケ縺ッ StronglyTypedResourceBuilder 繧ッ繝ゥ繧ケ縺・ResGen
+ // 縺セ縺溘・ Visual Studio 縺ョ繧医≧縺ェ繝・・繝ォ繧剃スソ逕ィ縺励※閾ェ蜍慕函謌舌&繧後∪縺励◆縲・
+ // 繝。繝ウ繝舌r霑ス蜉縺セ縺溘・蜑企勁縺吶k縺ォ縺ッ縲・ResX 繝輔ぃ繧、繝ォ繧堤キィ髮・@縺ヲ縲・str 繧ェ繝励す繝ァ繝ウ縺ィ蜈ア縺ォ
+ // ResGen 繧貞ョ溯。後@逶エ縺吶°縲√∪縺溘・ VS 繝励Ο繧ク繧ァ繧ッ繝医r繝薙Ν繝峨@逶エ縺励∪縺吶€・
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// 縺薙・繧ッ繝ゥ繧ケ縺ォ菴ソ逕ィ縺輔l繧九€√く繝」繝・す繝・縺輔l縺・ResourceManager 縺ョ繧、繝ウ繧ケ繧ソ繝ウ繧ケ繧定ソ斐@縺セ縺吶€・
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimpleLiteDirect3d.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// 蜴ウ蟇・↓蝙区欠螳壹&繧後◆縺薙・繝ェ繧ス繝シ繧ケ 繧ッ繝ゥ繧ケ繧剃スソ逕ィ縺励※縲√☆縺ケ縺ヲ縺ョ讀懃エ「繝ェ繧ス繝シ繧ケ縺ォ蟇セ縺励€・
+ /// 迴セ蝨ィ縺ョ繧ケ繝ャ繝・ラ縺ョ CurrentUICulture 繝励Ο繝代ユ繧」繧偵が繝シ繝舌・繝ゥ繧、繝峨@縺セ縺吶€・
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
Index: forFW2.0/sample/CaptureTest/Form1.cs
===================================================================
--- forFW2.0/sample/CaptureTest/Form1.cs (revision 222)
+++ forFW2.0/sample/CaptureTest/Form1.cs (revision 252)
@@ -70,7 +70,7 @@
pictureBox1.Image = b;

//AR縺ョ險育ョ・
- this.m_raster.setBuffer(i_buffer);
+ this.m_raster.setBuffer(i_buffer, i_sender.video_vertical_flip);
if (this.m_ar.detectMarkerLite(this.m_raster, 100))
{
NyARTransMatResult result_mat = new NyARTransMatResult();
Index: forFW2.0/sample/RawTest/NyIdTest.cs
===================================================================
--- forFW2.0/sample/RawTest/NyIdTest.cs (revision 0)
+++ forFW2.0/sample/RawTest/NyIdTest.cs (revision 252)
@@ -0,0 +1,128 @@
+・ソ/*
+ * PROJECT: Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.IO;
+using System.Diagnostics;
+using jp.nyatla.nyartoolkit.cs;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.nyidmarker;
+using jp.nyatla.nyartoolkit.cs.processor;
+
+namespace ConsoleApplication1
+{
+
+ /**
+ * 320x240縺ョBGRA32縺ァ險倬鹸縺輔l縺櫑dmarker繧呈聴蠖ア縺励◆RAW繧、繝。繝シ繧ク縺九i縲・
+ * Id繝槭・繧ォ繧定ェ崎ュ倥@縺セ縺吶€・
+ *
+ */
+ public class NyIdTest
+ {
+ public class MarkerProcessor : SingleNyIdMarkerProcesser
+ {
+ private Object _sync_object = new Object();
+ public NyARTransMatResult transmat = null;
+ public int current_id = -1;
+
+ public MarkerProcessor(NyARParam i_cparam, int i_raster_format)
+ : base(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format)
+ {
+ //繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ蛻晄悄蛹・
+ return;
+ }
+ /**
+ * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ繝上Φ繝峨Λ・医・繝シ繧ォ蜃コ迴セ・・
+ */
+ protected override void onEnterHandler(INyIdMarkerData i_code)
+ {
+ lock (this._sync_object)
+ {
+ NyIdMarkerData_RawBit code = (NyIdMarkerData_RawBit)i_code;
+ if (code.length > 4)
+ {
+ //4繝舌う繝井サ・荳翫・譎ゅ・int螟画鋤縺励↑縺・€・
+ this.current_id = -1;//undefined_id
+ }
+ else
+ {
+ this.current_id = 0;
+ //譛€螟ァ4繝舌う繝育ケ九£縺ヲ・大€九・int蛟、縺ォ螟画鋤
+ for (int i = 0; i < code.length; i++)
+ {
+ this.current_id = (this.current_id << 8) | code.packet[i];
+ }
+ }
+ this.transmat = null;
+ }
+ }
+ /**
+ * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ繝上Φ繝峨Λ・医・繝シ繧ォ豸域サ・シ・
+ */
+ protected override void onLeaveHandler()
+ {
+ lock (this._sync_object)
+ {
+ this.current_id = -1;
+ this.transmat = null;
+ }
+ return;
+ }
+ /**
+ * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ繝上Φ繝峨Λ・医・繝シ繧ォ譖エ譁ー・・
+ */
+ protected override void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result)
+ {
+ lock (this._sync_object)
+ {
+ this.transmat = result;
+ }
+ }
+ }
+ private const String data_file = "../../../../../data/320x240NyId.raw";
+ private const String camera_file = "../../../../../data/camera_para.dat";
+ public NyIdTest()
+ {
+ }
+ public void Test()
+ {
+ //AR逕ィ繧ォ繝。繝ゥ繝代Λ繝。繧ソ繝輔ぃ繧、繝ォ繧偵Ο繝シ繝・
+ NyARParam ap = new NyARParam();
+ ap.loadARParamFromFile(camera_file);
+ ap.changeScreenSize(320, 240);
+
+ //隧ヲ鬨薙う繝。繝シ繧ク縺ョ隱ュ縺ソ蜃コ縺・320x240 BGRA縺ョRAW繝・・繧ソ)
+ StreamReader sr = new StreamReader(data_file);
+ BinaryReader bs = new BinaryReader(sr.BaseStream);
+ byte[] raw = bs.ReadBytes(320 * 240 * 4);
+ NyARRgbRaster_BGRA ra = NyARRgbRaster_BGRA.wrap(raw, 320, 240);
+
+ MarkerProcessor pr = new MarkerProcessor(ap, ra.getBufferReader().getBufferType());
+ pr.detectMarker(ra);
+ return;
+ }
+ }
+}
Index: forFW2.0/sample/RawTest/Main.cs
===================================================================
--- forFW2.0/sample/RawTest/Main.cs (revision 0)
+++ forFW2.0/sample/RawTest/Main.cs (revision 252)
@@ -0,0 +1,57 @@
+・ソ/*
+ * PROJECT: Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.IO;
+using System.Diagnostics;
+namespace ConsoleApplication1
+{
+ class MainApp
+ {
+ static void Main(string[] args)
+ {
+ //縺薙%縺ァ繝・せ繝医☆繧九さ繝シ繝峨r蛻・j譖ソ縺医※縺上□縺輔>縲・
+ int s = 0;
+ switch (s)
+ {
+ case 0:
+ {
+ RawFileTest rf;
+ rf = new RawFileTest();
+ rf.Test();
+ }
+ break;
+ case 1:
+ {
+ NyIdTest rf;
+ rf = new NyIdTest();
+ rf.Test();
+ }
+ break;
+ }
+ }
+ }
+}
Index: forFW2.0/sample/RawTest/RawTest.csproj
===================================================================
--- forFW2.0/sample/RawTest/RawTest.csproj (revision 222)
+++ forFW2.0/sample/RawTest/RawTest.csproj (revision 252)
@@ -41,6 +41,8 @@
<ItemGroup>
<Compile Include="RawTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="NyIdTest.cs" />
+ <Compile Include="Main.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\NyARToolkitCS.sandbox\NyARToolkitCS.sandbox.csproj">
Index: forFW2.0/sample/RawTest/RawTest.cs
===================================================================
--- forFW2.0/sample/RawTest/RawTest.cs (revision 222)
+++ forFW2.0/sample/RawTest/RawTest.cs (revision 252)
@@ -48,7 +48,7 @@
{
NyMath.initialize();
}
- public void Test_arDetectMarkerLite()
+ public void Test()
{
//AR逕ィ繧ォ繝。繝ゥ繝代Λ繝。繧ソ繝輔ぃ繧、繝ォ繧偵Ο繝シ繝・
NyARParam ap = new NyARParam();
@@ -86,24 +86,5 @@
Console.WriteLine(sw.ElapsedMilliseconds + "[ms]");
return;
}
- public static void main(String[] args)
- {
- try
- {
- RawFileTest t = new RawFileTest();
- //t.Test_arGetVersion();
- t.Test_arDetectMarkerLite();
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- }
- static void Main(string[] args)
- {
- RawFileTest rf;
- rf = new RawFileTest();
- rf.Test_arDetectMarkerLite();
- }
}
}
Index: forFW2.0/sample/SimpleLiteDirect3d/SimpleLiteD3d.cs
===================================================================
--- forFW2.0/sample/SimpleLiteDirect3d/SimpleLiteD3d.cs (revision 222)
+++ forFW2.0/sample/SimpleLiteDirect3d/SimpleLiteD3d.cs (revision 252)
@@ -63,21 +63,35 @@
private VertexBuffer _vertexBuffer = null;
private IndexBuffer _indexBuffer = null;
private static Int16[] _vertexIndices = new Int16[] { 2, 0, 1, 1, 3, 2, 4, 0, 2, 2, 6, 4, 5, 1, 0, 0, 4, 5, 7, 3, 1, 1, 5, 7, 6, 2, 3, 3, 7, 6, 4, 6, 7, 7, 5, 4 };
+
+ private NyARTransMatResult __OnBuffer_nyar_transmat = new NyARTransMatResult();
+ private bool _is_marker_enable;
+ private Matrix _trans_mat;
/* 髱槫酔譛溘う繝吶Φ繝医ワ繝ウ繝峨Λ
- * CaptureDevice縺九i縺ョ繧、繝吶Φ繝医r繝上Φ繝峨Μ繝ウ繧ー縺励※縲√ヰ繝・ヵ繧。縺ィ繝・け繧ケ繝√Ε繧呈峩譁ー縺吶k縲・
- */
+ * CaptureDevice縺九i縺ョ繧、繝吶Φ繝医r繝上Φ繝峨Μ繝ウ繧ー縺励※縲√ヰ繝・ヵ繧。縺ィ繝・け繧ケ繝√Ε繧呈峩譁ー縺吶k縲・
+ */
public void OnBuffer(CaptureDevice i_sender, double i_sample_time, IntPtr i_buffer, int i_buffer_len)
{
int w = i_sender.video_width;
int h = i_sender.video_height;
int s = w * (i_sender.video_bit_count / 8);
+ NyARTransMatResult nyar_transmat = this.__OnBuffer_nyar_transmat;

//繝・け繧ケ繝√Ε縺ォRGB繧貞叙繧願セシ縺ソ()
lock (this)
{
//繧ォ繝。繝ゥ譏蜒上rAR縺ョ繝舌ャ繝輔ぃ縺ォ繧ウ繝斐・
- this._raster.setBuffer(i_buffer);
-
+ this._raster.setBuffer(i_buffer, i_sender.video_vertical_flip);
+
+ //繝槭・繧ォ繝シ縺ッ隕九▽縺九▲縺溘°縺ェ・・
+ bool is_marker_enable = this._ar.detectMarkerLite(this._raster, 110);
+ if (is_marker_enable)
+ {
+ //縺ゅl縺ーMatrix繧定ィ育ョ・
+ this._ar.getTransmationMatrix(nyar_transmat);
+ this._utils.toD3dMatrix(nyar_transmat, ref this._trans_mat);
+ }
+ this._is_marker_enable=is_marker_enable;
//繝・け繧ケ繝√Ε蜀・ョケ繧呈峩譁ー
this._surface.CopyFromXRGB32(this._raster);
}
@@ -88,12 +102,14 @@
public void StartCap()
{
this._cap.StartCapture();
+ return;
}
/* 繧ュ繝」繝励メ繝」繧貞●豁「縺吶k髢「謨ー
*/
public void StopCap()
{
this._cap.StopCapture();
+ return;
}


@@ -102,13 +118,12 @@
private Device PrepareD3dDevice(Control i_window)
{
PresentParameters pp = new PresentParameters();
-
- // 繧ヲ繧、繝ウ繝峨え繝「繝シ繝峨↑繧・true縲√ヵ繝ォ繧ケ繧ッ繝ェ繝シ繝ウ繝「繝シ繝峨↑繧・false 繧呈欠螳・
pp.Windowed = true;
- // 繧ケ繝ッ繝・・縺ィ繧翫≠縺医★Discard繧呈欠螳壹€・
pp.SwapEffect = SwapEffect.Flip;
pp.BackBufferFormat = Format.X8R8G8B8;
pp.BackBufferCount = 1;
+ pp.EnableAutoDepthStencil = true;
+ pp.AutoDepthStencilFormat = DepthFormat.D16;
CreateFlags fl_base = CreateFlags.FpuPreserve;

try{
@@ -128,8 +143,10 @@
}
}
}
+
public bool InitializeApplication(Form1 topLevelForm,CaptureDevice i_cap_device)
{
+ topLevelForm.ClientSize=new Size(SCREEN_WIDTH,SCREEN_HEIGHT);
//繧ュ繝」繝励メ繝」繧剃ス懊k(QVGA縺ァ繝輔Ξ繝シ繝繝ャ繝シ繝医・30)
i_cap_device.SetCaptureListener(this);
i_cap_device.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30);
@@ -156,11 +173,14 @@
this._utils = new NyARD3dUtil();

//險育ョ励Δ繝シ繝峨・險ュ螳・
- this._ar.setContinueMode(false);
+ this._ar.setContinueMode(true);

//3d繝・ヰ繧、繧ケ繧呈コ門y縺吶k
this._device = PrepareD3dDevice(topLevelForm);
+ this._device.RenderState.ZBufferEnable = true;
+ this._device.RenderState.Lighting = false;

+
//繧ォ繝。繝ゥProjection縺ョ險ュ螳・
Matrix tmp = new Matrix();
this._utils.toCameraFrustumRH(ap, ref tmp);
@@ -170,10 +190,19 @@
// 0,0,0縺九i縲〇+譁ケ蜷代r蜷代>縺ヲ縲∽ク頑婿蜷代′Y霆ク
this._device.Transform.View = Matrix.LookAtLH(
new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 1.0f, 0.0f));
+ Viewport vp = new Viewport();
+ vp.X = 0;
+ vp.Y = 0;
+ vp.Height = ap.getScreenSize().h;
+ vp.Width = ap.getScreenSize().w;
+ vp.MaxZ = 1.0f;
+ //繝薙Η繝シ繝昴・繝郁ィュ螳・
+ this._device.Viewport = vp;

//遶区婿菴難シ磯らせ謨ー8・峨・貅門y
this._vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored),
8, this._device, Usage.None, CustomVertex.PositionColored.Format, Pool.Managed);
+

//8轤ケ縺ョ諠・ア繧呈シ邏阪☆繧九◆繧√・繝。繝「繝ェ繧堤「コ菫・
CustomVertex.PositionColored[] vertices = new CustomVertex.PositionColored[8];
@@ -213,37 +242,19 @@
// 繧、繝ウ繝・ャ繧ッ繧ケ繝舌ャ繝輔ぃ縺ョ繝ュ繝・け繧定ァ」髯、縺励∪縺・
this._indexBuffer.Unlock();
}
- // 繝ゥ繧、繝医r辟。蜉ケ
- this._device.RenderState.Lighting = false;

- // 繧ォ繝ェ繝ウ繧ー繧堤┌蜉ケ縺ォ縺励※繝昴Μ繧エ繝ウ縺ョ陬上b謠冗判縺吶k
- //this._device.RenderState.CullMode = Cull.None;
-
//閭梧勹繧オ繝シ繝輔ぉ繧、繧ケ繧剃ス懈・
this._surface = new NyARSurface_XRGB32(this._device, SCREEN_WIDTH, SCREEN_HEIGHT);

+ this._is_marker_enable = false;
return true;
}
- private Matrix __MainLoop_trans_matrix = new Matrix();
- private NyARTransMatResult __MainLoop_nyar_transmat = new NyARTransMatResult();
//繝。繧、繝ウ繝ォ繝シ繝怜・逅・
public void MainLoop()
{
//AR縺ョ險育ョ・
- Matrix trans_matrix = this.__MainLoop_trans_matrix;
- NyARTransMatResult trans_result = this.__MainLoop_nyar_transmat;
- bool is_marker_enable;
lock (this)
{
- //繝槭・繧ォ繝シ縺ッ隕九▽縺九▲縺溘°縺ェ・・
- is_marker_enable = this._ar.detectMarkerLite(this._raster, 110);
- if (is_marker_enable)
- {
- //縺ゅl縺ーMatrix繧定ィ育ョ・
- this._ar.getTransmationMatrix(trans_result);
- this._utils.toD3dMatrix(trans_result,ref trans_matrix);
- }
-
// 閭梧勹繧オ繝シ繝輔ぉ繧、繧ケ繧堤峩謗・謠冗判
Surface dest_surface = this._device.GetBackBuffer(0, 0, BackBufferType.Mono);
Rectangle src_dest_rect = new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
@@ -251,10 +262,11 @@

// 3D繧ェ繝悶ず繧ァ繧ッ繝医・謠冗判縺ッ縺薙%縺九i
this._device.BeginScene();
+ this._device.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0);


//繝槭・繧ォ繝シ縺瑚ヲ九▽縺九▲縺ヲ縺・※縲・.4繧医j荳€閾エ縺励※縺溘i謠冗判縺吶k縲・
- if (is_marker_enable && this._ar.getConfidence()>0.4)
+ if (this._is_marker_enable && this._ar.getConfidence()>0.4)
{
// 鬆らせ繝舌ャ繝輔ぃ繧偵ョ繝舌う繧ケ縺ョ繝・・繧ソ繧ケ繝医Μ繝シ繝縺ォ繝舌う繝ウ繝・
this._device.SetStreamSource(0, this._vertexBuffer, 0);
@@ -269,11 +281,12 @@
Matrix transform_mat2 = Matrix.Translation(0,0,20.0f);

//螟画鋤陦悟・繧呈寺縺代k
- transform_mat2 *= trans_matrix;
+ transform_mat2 *= this._trans_mat;
// 險育ョ励@縺溘・繝医Μ繝・け繧ケ縺ァ蠎ァ讓吝、画鋤
this._device.SetTransform(TransformType.World, transform_mat2);

// 繝ャ繝ウ繝€繝ェ繝ウ繧ー・域緒逕サ・・
+ this._device.RenderState.CullMode = Cull.Clockwise;
this._device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12);
}

@@ -283,27 +296,35 @@
// 螳滄圀縺ョ繝・ぅ繧ケ繝励Ξ繧、縺ォ謠冗判
this._device.Present();
}
-
+ return;
}

// 繝ェ繧ス繝シ繧ケ縺ョ遐エ譽・r縺吶k縺溘a縺ォ蜻シ縺ー繧後k
public void Dispose()
{
- // 鬆らせ繝舌ャ繝輔ぃ繧定ァ」謾セ
- if (this._vertexBuffer != null)
+ lock (this)
{
- this._vertexBuffer.Dispose();
- }

- // 繧、繝ウ繝・ャ繧ッ繧ケ繝舌ャ繝輔ぃ繧定ァ」謾セ
- if (this._indexBuffer != null)
- {
- this._indexBuffer.Dispose();
- }
- // Direct3D 繝・ヰ繧、繧ケ縺ョ繝ェ繧ス繝シ繧ケ隗」謾セ
- if (this._device != null)
- {
- this._device.Dispose();
+ // 鬆らせ繝舌ャ繝輔ぃ繧定ァ」謾セ
+ if (this._vertexBuffer != null)
+ {
+ this._vertexBuffer.Dispose();
+ }
+
+ // 繧、繝ウ繝・ャ繧ッ繧ケ繝舌ャ繝輔ぃ繧定ァ」謾セ
+ if (this._indexBuffer != null)
+ {
+ this._indexBuffer.Dispose();
+ }
+ if (this._surface != null)
+ {
+ this._surface.Dispose();
+ }
+ // Direct3D 繝・ヰ繧、繧ケ縺ョ繝ェ繧ス繝シ繧ケ隗」謾セ
+ if (this._device != null)
+ {
+ this._device.Dispose();
+ }
}
}
}
Index: forFW2.0/sample/SimpleLiteDirect3d/Form1.Designer.cs
===================================================================
--- forFW2.0/sample/SimpleLiteDirect3d/Form1.Designer.cs (revision 222)
+++ forFW2.0/sample/SimpleLiteDirect3d/Form1.Designer.cs (revision 252)
@@ -34,7 +34,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(314, 208);
+ this.ClientSize = new System.Drawing.Size(634, 448);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "Form1";
Index: forFW2.0/sample/SimpleLiteDirect3d/Program.cs
===================================================================
--- forFW2.0/sample/SimpleLiteDirect3d/Program.cs (revision 222)
+++ forFW2.0/sample/SimpleLiteDirect3d/Program.cs (revision 252)
@@ -70,8 +70,6 @@
}
using (CaptureDevice capture_device = capture_device_list[cdevice_number])
{
-
-
// 繝輔か繝シ繝縺ィ繝。繧、繝ウ繧オ繝ウ繝励Ν繧ッ繝ゥ繧ケ繧剃ス懈・
using (Form1 frm = new Form1())
using (SimpleLiteD3d sample = new SimpleLiteD3d())
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.resx
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.resx (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.resx (revision 252)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Form1.Designer.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Form1.Designer.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Form1.Designer.cs (revision 252)
@@ -0,0 +1,39 @@
+・ソnamespace SingleNyIdMarkerDirect3d
+{
+ partial class Form1
+ {
+ /// <summary>
+ /// 蠢・ヲ√↑繝・じ繧、繝雁、画焚縺ァ縺吶€・
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// 菴ソ逕ィ荳ュ縺ョ繝ェ繧ス繝シ繧ケ繧偵☆縺ケ縺ヲ繧ッ繝ェ繝シ繝ウ繧「繝・・縺励∪縺吶€・
+ /// </summary>
+ /// <param name="disposing">繝槭ロ繝シ繧ク 繝ェ繧ス繝シ繧ケ縺檎エ譽・&繧後k蝣エ蜷・true縲∫エ譽・&繧後↑縺・エ蜷医・ false 縺ァ縺吶€・/param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 繝輔か繝シ繝 繝・じ繧、繝翫〒逕滓・縺輔l縺溘さ繝シ繝・
+
+ /// <summary>
+ /// 繝・じ繧、繝・繧オ繝昴・繝医↓蠢・ヲ√↑繝。繧ス繝・ラ縺ァ縺吶€ゅ%縺ョ繝。繧ス繝・ラ縺ョ蜀・ョケ繧・
+ /// 繧ウ繝シ繝・繧ィ繝・ぅ繧ソ縺ァ螟画峩縺励↑縺・〒縺上□縺輔>縲・
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Text = "Form1";
+ }
+
+ #endregion
+ }
+}
+
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Form1.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Form1.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Form1.cs (revision 252)
@@ -0,0 +1,18 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace SingleNyIdMarkerDirect3d
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.Designer.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.Designer.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.Designer.cs (revision 252)
@@ -0,0 +1,91 @@
+・ソnamespace SingleNyIdMarkerDirect3d
+{
+ partial class Form2
+ {
+ /// <summary>
+ /// 蠢・ヲ√↑繝・じ繧、繝雁、画焚縺ァ縺吶€・
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// 菴ソ逕ィ荳ュ縺ョ繝ェ繧ス繝シ繧ケ繧偵☆縺ケ縺ヲ繧ッ繝ェ繝シ繝ウ繧「繝・・縺励∪縺吶€・
+ /// </summary>
+ /// <param name="disposing">繝槭ロ繝シ繧ク 繝ェ繧ス繝シ繧ケ縺檎エ譽・&繧後k蝣エ蜷・true縲∫エ譽・&繧後↑縺・エ蜷医・ false 縺ァ縺吶€・/param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 繝輔か繝シ繝 繝・じ繧、繝翫〒逕滓・縺輔l縺溘さ繝シ繝・
+
+ /// <summary>
+ /// 繝・じ繧、繝・繧オ繝昴・繝医↓蠢・ヲ√↑繝。繧ス繝・ラ縺ァ縺吶€ゅ%縺ョ繝。繧ス繝・ラ縺ョ蜀・ョケ繧・
+ /// 繧ウ繝シ繝・繧ィ繝・ぅ繧ソ縺ァ螟画峩縺励↑縺・〒縺上□縺輔>縲・
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.comboBox1 = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.button1 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboBox1
+ //
+ this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(14, 34);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(294, 20);
+ this.comboBox1.TabIndex = 0;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(12, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(162, 12);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "菴ソ逕ィ縺吶k繧ォ繝。繝ゥ繧帝∈謚槭@縺ヲ荳九&縺・€・;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(121, 106);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 3;
+ this.button1.Text = "OK";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click_1);
+ //
+ // Form2
+ //
+ this.AcceptButton = this.button1;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(318, 141);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.comboBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "Form2";
+ this.RightToLeftLayout = true;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Form2";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button button1;
+ }
+}
\ No newline at end of file
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarkerDirect3d.csproj
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarkerDirect3d.csproj (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarkerDirect3d.csproj (revision 252)
@@ -0,0 +1,105 @@
+・ソ<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{58DB6E91-4B1F-4C08-8925-E02A79708272}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SingleNyIdMarkerDirect3d</RootNamespace>
+ <AssemblyName>SingleNyIdMarkerDirect3d</AssemblyName>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="DirectShowLib-2005, Version=2.0.0.0, Culture=neutral, PublicKeyToken=67e7b740cdfc2d3f, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\extlib\DirectShowLibV2\lib\DirectShowLib-2005.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <Reference Include="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Form1.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Form1.Designer.cs">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Form2.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Form2.Designer.cs">
+ <DependentUpon>Form2.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="Form2.resx">
+ <DependentUpon>Form2.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ <Compile Include="SingleNyIdMarker.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\NyARToolkitCSUtils\NyARToolkitCSUtils.csproj">
+ <Project>{1D202933-65C8-4568-9756-87E57D294132}</Project>
+ <Name>NyARToolkitCSUtils</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\NyARToolkitCS\NyARToolkitCS.csproj">
+ <Project>{80391577-476D-4DAD-A4F8-F03C726ACBD8}</Project>
+ <Name>NyARToolkitCS</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Form2.cs (revision 252)
@@ -0,0 +1,69 @@
+・ソ/*
+ * Capture Test NyARToolkitCS繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Windows.Forms;
+using NyARToolkitCSUtils.Capture;
+
+namespace SingleNyIdMarkerDirect3d
+{
+ public partial class Form2 : Form
+ {
+ public Form2()
+ {
+ InitializeComponent();
+ }
+ public DialogResult ShowDialog(CaptureDeviceList i_clist,out int o_selected_no)
+ {
+ if (i_clist.count < 1)
+ {
+ throw new Exception("繧ォ繝。繝ゥ縺檎┌縺・・縺ォ驕ク縺シ縺・→縺励※縺ッ縺・¢縺ェ縺・€・);
+ }
+ for (int i = 0; i < i_clist.count; i++)
+ {
+ this.comboBox1.Items.Add(i_clist[i].name + ":");
+ }
+ this.comboBox1.SelectedIndex = 0;
+ DialogResult ret=base.ShowDialog();
+ o_selected_no = this.comboBox1.SelectedIndex;
+ return ret;
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void button1_Click_1(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Program.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Program.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Program.cs (revision 252)
@@ -0,0 +1,70 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using System.Threading;
+using NyARToolkitCSUtils.Capture;
+
+namespace SingleNyIdMarkerDirect3d
+{
+ static class Program
+ {
+ /// <summary>
+ /// 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ縺ョ繝。繧、繝ウ 繧ィ繝ウ繝医Μ 繝昴う繝ウ繝医〒縺吶€・
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+
+
+ //繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ繝ェ繧ケ繝医r蜿門セ・
+ CaptureDeviceList capture_device_list = new CaptureDeviceList();
+ if (capture_device_list.count < 1)
+ {
+ MessageBox.Show("繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ縺瑚ヲ九▽縺九j縺セ縺帙s縺ァ縺励◆縲・);
+ return;
+ }
+ //繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ繧帝∈謚槭@縺ヲ繧ゅi縺・€・
+ int cdevice_number = 0;
+ using (Form2 frm2 = new Form2())
+ {
+ frm2.ShowDialog(capture_device_list, out cdevice_number);
+ }
+ using (CaptureDevice capture_device = capture_device_list[cdevice_number])
+ {
+ // 繝輔か繝シ繝縺ィ繝。繧、繝ウ繧オ繝ウ繝励Ν繧ッ繝ゥ繧ケ繧剃ス懈・
+ using (Form1 frm = new Form1())
+ using (SimpleLiteD3d sample = new SimpleLiteD3d())
+ {
+ // 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ縺ョ蛻晄悄蛹・
+ if (sample.InitializeApplication(frm, capture_device))
+ {
+ // 繝。繧、繝ウ繝輔か繝シ繝繧定。ィ遉コ
+ frm.Show();
+ //繧ュ繝」繝励メ繝」髢句ァ・
+ sample.StartCap();
+ // 繝輔か繝シ繝縺御ス懈・縺輔l縺ヲ縺・k髢薙・繝ォ繝シ繝励@邯壹¢繧・
+ while (frm.Created)
+ {
+ // 繝。繧、繝ウ繝ォ繝シ繝怜・逅・r陦後≧
+ sample.MainLoop();
+
+ //繧ケ繝ャ繝・ラ繧ケ繧、繝・メ
+ Thread.Sleep(1);
+
+ // 繧、繝吶Φ繝医′縺ゅk蝣エ蜷医・縺昴・蜃ヲ逅・☆繧・
+ Application.DoEvents();
+ }
+ //繧ュ繝」繝励メ繝」縺ョ蛛懈ュ「
+ sample.StopCap();
+ }
+ else
+ {
+ // 蛻晄悄蛹悶↓螟ア謨・
+ }
+ }
+ }
+ }
+ }
+}
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarker.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarker.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarker.cs (revision 252)
@@ -0,0 +1,328 @@
+・ソusing System;
+using System.IO;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Threading;
+using System.Windows.Forms;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.nyidmarker;
+using jp.nyatla.nyartoolkit.cs.processor;
+using jp.nyatla.nyartoolkit.cs.utils;
+using NyARToolkitCSUtils.Capture;
+using NyARToolkitCSUtils.Direct3d;
+using NyARToolkitCSUtils.NyAR;
+using Microsoft.DirectX;
+using Microsoft.DirectX.Direct3D;
+
+namespace SingleNyIdMarkerDirect3d
+{
+ class TextPanel
+ {
+ private Device _device;
+ private System.Drawing.Font _font;
+ public TextPanel(Device i_device,int i_size)
+ {
+ this._device = i_device;
+ this._font = new System.Drawing.Font("System", i_size);
+ return;
+ }
+ public void draw(String i_str, float i_scale)
+ {
+ Mesh m= Mesh.TextFromFont(this._device, this._font, i_str, 5.0f, 0.1f);
+
+ m.DrawSubset(0);
+ m.Dispose();
+ return;
+ }
+ }
+
+ /**
+ * ・大€九・RawBit-Id繝槭・繧ォ繧定ェ崎ュ倥☆繧九Ο繧ク繝・け繧ッ繝ゥ繧ケ縲・
+ * detectMarker髢「謨ー縺ョ蜻シ縺ウ蜃コ縺励↓蜷梧悄縺励※縲》ransmat縺ィcurrent_id繝代Λ繝。繧ソ繧呈峩譁ー縺励∪縺吶€・
+ *
+ *
+ */
+ class MarkerProcessor : SingleNyIdMarkerProcesser
+ {
+ private Object _sync_object = new Object();
+ public NyARTransMatResult transmat = null;
+ public int current_id = -1;
+
+ public MarkerProcessor(NyARParam i_cparam, int i_raster_format)
+ : base(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format)
+ {
+ //繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ蛻晄悄蛹・
+ return;
+ }
+ /**
+ * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ繝上Φ繝峨Λ・医・繝シ繧ォ蜃コ迴セ・・
+ */
+ protected override void onEnterHandler(INyIdMarkerData i_code)
+ {
+ lock (this._sync_object)
+ {
+ NyIdMarkerData_RawBit code = (NyIdMarkerData_RawBit)i_code;
+ if (code.length > 4)
+ {
+ //4繝舌う繝井サ・荳翫・譎ゅ・int螟画鋤縺励↑縺・€・
+ this.current_id = -1;//undefined_id
+ }
+ else
+ {
+ this.current_id = 0;
+ //譛€螟ァ4繝舌う繝育ケ九£縺ヲ・大€九・int蛟、縺ォ螟画鋤
+ for (int i = 0; i < code.length; i++)
+ {
+ this.current_id = (this.current_id << 8) | code.packet[i];
+ }
+ }
+ this.transmat = null;
+ }
+ }
+ /**
+ * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ繝上Φ繝峨Λ・医・繝シ繧ォ豸域サ・シ・
+ */
+ protected override void onLeaveHandler()
+ {
+ lock (this._sync_object)
+ {
+ this.current_id = -1;
+ this.transmat = null;
+ }
+ return;
+ }
+ /**
+ * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ョ繝上Φ繝峨Λ・医・繝シ繧ォ譖エ譁ー・・
+ */
+ protected override void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result)
+ {
+ lock (this._sync_object)
+ {
+ this.transmat = result;
+ }
+ }
+ }
+
+ public partial class SimpleLiteD3d : IDisposable, CaptureListener
+ {
+ private const int SCREEN_WIDTH = 640;
+ private const int SCREEN_HEIGHT = 480;
+ private const String AR_CODE_FILE = "../../../../../data/patt.hiro";
+ private const String AR_CAMERA_FILE = "../../../../../data/camera_para.dat";
+ //DirectShow縺九i縺ョ繧ュ繝」繝励メ繝」
+ private CaptureDevice _cap;
+ private MarkerProcessor _processor;
+ //NyAR
+ private DsBGRX32Raster _raster;
+ private NyARD3dUtil _utils;
+ //閭梧勹繝・け繧ケ繝√Ε
+ private NyARSurface_XRGB32 _surface;
+ /// Direct3D 繝・ヰ繧、繧ケ
+ private Device _device = null;
+ //陦ィ遉コ繧ェ繝悶ず繧ァ繧ッ繝・
+ private TextPanel _text;
+
+ private NyARTransMatResult __OnBuffer_nyar_transmat = new NyARTransMatResult();
+ private Matrix _trans_mat = new Matrix();
+ /* 髱槫酔譛溘う繝吶Φ繝医ワ繝ウ繝峨Λ
+ * CaptureDevice縺九i縺ョ繧、繝吶Φ繝医r繝上Φ繝峨Μ繝ウ繧ー縺励※縲√ヰ繝・ヵ繧。縺ィ繝・け繧ケ繝√Ε繧呈峩譁ー縺吶k縲・
+ */
+ public void OnBuffer(CaptureDevice i_sender, double i_sample_time, IntPtr i_buffer, int i_buffer_len)
+ {
+ int w = i_sender.video_width;
+ int h = i_sender.video_height;
+ int s = w * (i_sender.video_bit_count / 8);
+ //繝・け繧ケ繝√Ε縺ォRGB繧貞叙繧願セシ縺ソ()
+ lock (this)
+ {
+ //繧ォ繝。繝ゥ譏蜒上rAR縺ョ繝舌ャ繝輔ぃ縺ォ繧ウ繝斐・
+ this._raster.setBuffer(i_buffer, i_sender.video_vertical_flip);
+ //繝輔Ξ繝シ繝繝ッ繝シ繧ッ縺ォ逕サ蜒上r霆「騾・
+ this._processor.detectMarker(this._raster);
+ //繝槭・繧ォ繝シ縺ッ隕九▽縺九▲縺溘°縺ェ・・
+ if (this._processor.transmat!=null)
+ {
+ //縺ゅl縺ーMatrix繧定ィ育ョ・
+ this._utils.toD3dMatrix(this._processor.transmat, ref this._trans_mat);
+ }
+ //繝・け繧ケ繝√Ε蜀・ョケ繧呈峩譁ー
+ this._surface.CopyFromXRGB32(this._raster);
+ }
+ return;
+ }
+ /* 繧ュ繝」繝励メ繝」繧帝幕蟋九☆繧矩未謨ー
+ */
+ public void StartCap()
+ {
+ this._cap.StartCapture();
+ return;
+ }
+ /* 繧ュ繝」繝励メ繝」繧貞●豁「縺吶k髢「謨ー
+ */
+ public void StopCap()
+ {
+ this._cap.StopCapture();
+ return;
+ }
+
+
+ /* Direct3D繝・ヰ繧、繧ケ繧呈コ門y縺吶k髢「謨ー
+ */
+ private Device PrepareD3dDevice(Control i_window)
+ {
+ PresentParameters pp = new PresentParameters();
+
+ pp.Windowed = true;
+ pp.SwapEffect = SwapEffect.Flip;
+ pp.BackBufferFormat = Format.X8R8G8B8;
+ pp.BackBufferCount = 1;
+ pp.EnableAutoDepthStencil = true;
+ pp.AutoDepthStencilFormat = DepthFormat.D16;
+ CreateFlags fl_base = CreateFlags.FpuPreserve;
+
+
+ try
+ {
+ return new Device(0, DeviceType.Hardware, i_window.Handle, fl_base | CreateFlags.HardwareVertexProcessing, pp);
+ }
+ catch (Exception ex1)
+ {
+ Debug.WriteLine(ex1.ToString());
+ try
+ {
+ return new Device(0, DeviceType.Hardware, i_window.Handle, fl_base | CreateFlags.SoftwareVertexProcessing, pp);
+ }
+ catch (Exception ex2)
+ {
+ // 菴懈・縺ォ螟ア謨・
+ Debug.WriteLine(ex2.ToString());
+ try
+ {
+ return new Device(0, DeviceType.Reference, i_window.Handle, fl_base | CreateFlags.SoftwareVertexProcessing, pp);
+ }
+ catch (Exception ex3)
+ {
+ throw ex3;
+ }
+ }
+ }
+ }
+
+ public bool InitializeApplication(Form1 topLevelForm, CaptureDevice i_cap_device)
+ {
+ topLevelForm.ClientSize = new Size(SCREEN_WIDTH, SCREEN_HEIGHT);
+ //繧ュ繝」繝励メ繝」繧剃ス懊k(QVGA縺ァ繝輔Ξ繝シ繝繝ャ繝シ繝医・30)
+ i_cap_device.SetCaptureListener(this);
+ i_cap_device.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30);
+ this._cap = i_cap_device;
+
+ //AR繝ゥ繧ケ繧ソ繧剃ス懊k(DirectShow繧ュ繝」繝励メ繝」莉墓ァ・縲・
+ this._raster = new DsBGRX32Raster(i_cap_device.video_width, i_cap_device.video_height, i_cap_device.video_width * i_cap_device.video_bit_count / 8);
+
+ //AR逕ィ繧ォ繝。繝ゥ繝代Λ繝。繧ソ繝輔ぃ繧、繝ォ繧偵Ο繝シ繝峨@縺ヲ險ュ螳・
+ NyARParam ap = new NyARParam();
+ ap.loadARParamFromFile(AR_CAMERA_FILE);
+ ap.changeScreenSize(SCREEN_WIDTH, SCREEN_HEIGHT);
+
+ //繝励Ο繧サ繝・し縺ョ貅門y
+ this._processor = new MarkerProcessor(ap, this._raster.getBufferReader().getBufferType());
+ this._processor.setMarkerWidth(100);
+
+ //Direct3d逕ィ縺ョ繝ヲ繝シ繝・ぅ繝ェ繝・ぅ貅門y
+ this._utils = new NyARD3dUtil();
+
+ //3d繝・ヰ繧、繧ケ繧呈コ門y縺吶k
+ this._device = PrepareD3dDevice(topLevelForm);
+ this._device.RenderState.ZBufferEnable = true;
+ this._device.RenderState.Lighting = false;
+ this._device.RenderState.CullMode = Cull.CounterClockwise;
+
+ Viewport vp = new Viewport();
+ vp.X = 0;
+ vp.Y = 0;
+ vp.Height = ap.getScreenSize().h;
+ vp.Width = ap.getScreenSize().w;
+ vp.MaxZ = 1.0f;
+ //繝薙Η繝シ繝昴・繝郁ィュ螳・
+ this._device.Viewport = vp;
+
+ this._text = new TextPanel(this._device, 1);
+ //繧ォ繝。繝ゥProjection縺ョ險ュ螳・
+ Matrix tmp = new Matrix();
+ this._utils.toCameraFrustumRH(ap, ref tmp);
+ this._device.Transform.Projection = tmp;
+
+ // 繝薙Η繝シ螟画鋤縺ョ險ュ螳・蟾ヲ謇句コァ讓咏ウサ繝薙Η繝シ陦悟・縺ァ險ュ螳壹☆繧・
+ // 0,0,0縺九i縲〇+譁ケ蜷代r蜷代>縺ヲ縲∽ク頑婿蜷代′Y霆ク
+ this._device.Transform.View = Matrix.LookAtLH(
+ new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 1.0f, 0.0f));
+
+ //閭梧勹繧オ繝シ繝輔ぉ繧、繧ケ繧剃ス懈・
+ this._surface = new NyARSurface_XRGB32(this._device, SCREEN_WIDTH, SCREEN_HEIGHT);
+
+ return true;
+ }
+ //繝。繧、繝ウ繝ォ繝シ繝怜・逅・
+ public void MainLoop()
+ {
+ //AR縺ョ險育ョ・
+ Matrix trans_matrix = this._trans_mat;
+ lock (this)
+ {
+ // 閭梧勹繧オ繝シ繝輔ぉ繧、繧ケ繧堤峩謗・謠冗判
+ Surface dest_surface = this._device.GetBackBuffer(0, 0, BackBufferType.Mono);
+ Rectangle src_dest_rect = new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ this._device.StretchRectangle(this._surface.d3d_surface, src_dest_rect, dest_surface, src_dest_rect, TextureFilter.None);
+
+ // 3D繧ェ繝悶ず繧ァ繧ッ繝医・謠冗判縺ッ縺薙%縺九i
+ this._device.BeginScene();
+ this._device.Clear(ClearFlags.ZBuffer, Color.DarkBlue, 1.0f, 0);
+
+ if (this._processor.current_id!=-1)
+ {
+ long d = DateTime.Now.Ticks;
+ float r = (d / 500000) % 360;
+ Matrix transform_mat2 = Matrix.Scaling(20.0f, 20.0f, 20.0f);
+ transform_mat2 *= Matrix.RotationX((float)(90.0 * 3.14 / 180.0));
+ transform_mat2 *= Matrix.Translation(-50f, 0, 50.0f);
+
+ transform_mat2 *= Matrix.RotationZ((float)(r * Math.PI / 180));
+
+ //螟画鋤陦悟・繧呈寺縺代k
+ transform_mat2 *= trans_matrix;
+ // 險育ョ励@縺溘・繝医Μ繝・け繧ケ縺ァ蠎ァ讓吝、画鋤
+ this._device.SetTransform(TransformType.World, transform_mat2);
+
+ this._text.draw("MarkerId:" + this._processor.current_id, 1);
+ // 繝ャ繝ウ繝€繝ェ繝ウ繧ー・域緒逕サ・・
+ this._device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 8, 0, 12);
+ }
+
+ // 謠冗判縺ッ縺薙%縺セ縺ァ
+ this._device.EndScene();
+
+ // 螳滄圀縺ョ繝・ぅ繧ケ繝励Ξ繧、縺ォ謠冗判
+ this._device.Present();
+ }
+ return;
+ }
+
+ // 繝ェ繧ス繝シ繧ケ縺ョ遐エ譽・r縺吶k縺溘a縺ォ蜻シ縺ー繧後k
+ public void Dispose()
+ {
+ lock (this)
+ {
+ if (this._surface != null)
+ {
+ this._surface.Dispose();
+ }
+ // Direct3D 繝・ヰ繧、繧ケ縺ョ繝ェ繧ス繝シ繧ケ隗」謾セ
+ if (this._device != null)
+ {
+ this._device.Dispose();
+ }
+ }
+ }
+ }
+}
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/AssemblyInfo.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/AssemblyInfo.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/AssemblyInfo.cs (revision 252)
@@ -0,0 +1,36 @@
+・ソusing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 繧「繧サ繝ウ繝悶Μ縺ォ髢「縺吶k荳€闊ャ諠・ア縺ッ莉・荳九・螻樊€ァ繧サ繝・ヨ繧偵→縺翫@縺ヲ蛻カ蠕。縺輔l縺セ縺吶€・
+// 繧「繧サ繝ウ繝悶Μ縺ォ髢「騾」莉倥¢繧峨l縺ヲ縺・k諠・ア繧貞、画峩縺吶k縺ォ縺ッ縲・
+// 縺薙l繧峨・螻樊€ァ蛟、繧貞、画峩縺励※縺上□縺輔>縲・
+[assembly: AssemblyTitle("SingleNyIdMarkerDirect3d")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SingleNyIdMarkerDirect3d")]
+[assembly: AssemblyCopyright("Copyright ツゥ 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible 繧・false 縺ォ險ュ螳壹☆繧九→縲√◎縺ョ蝙九・縺薙・繧「繧サ繝ウ繝悶Μ蜀・〒 COM 繧ウ繝ウ繝昴・繝阪Φ繝医°繧・
+// 蜿ら・荳榊庄閭ス縺ォ縺ェ繧翫∪縺吶€・OM 縺九i縺薙・繧「繧サ繝ウ繝悶Μ蜀・・蝙九↓繧「繧ッ繧サ繧ケ縺吶k蝣エ蜷医・縲・
+// 縺昴・蝙九・ ComVisible 螻樊€ァ繧・true 縺ォ險ュ螳壹@縺ヲ縺上□縺輔>縲・
+[assembly: ComVisible(false)]
+
+// 谺。縺ョ GUID 縺ッ縲√%縺ョ繝励Ο繧ク繧ァ繧ッ繝医′ COM 縺ォ蜈ャ髢九&繧後k蝣エ蜷医・縲》ypelib 縺ョ ID 縺ァ縺・
+[assembly: Guid("650db870-217b-43a8-9da9-18b396085db9")]
+
+// 繧「繧サ繝ウ繝悶Μ縺ョ繝舌・繧ク繝ァ繝ウ諠・ア縺ッ縲∽サ・荳九・ 4 縺、縺ョ蛟、縺ァ讒区・縺輔l縺ヲ縺・∪縺・
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// 縺吶∋縺ヲ縺ョ蛟、繧呈欠螳壹☆繧九°縲∽ク九・繧医≧縺ォ '*' 繧剃スソ縺」縺ヲ繝薙Ν繝峨♀繧医・繝ェ繝薙ず繝ァ繝ウ逡ェ蜿キ繧・
+// 譌「螳壼€、縺ォ縺吶k縺薙→縺後〒縺阪∪縺・
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Settings.settings
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Settings.settings (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Settings.settings (revision 252)
@@ -0,0 +1,7 @@
+・ソ<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Settings.Designer.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Settings.Designer.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Settings.Designer.cs (revision 252)
@@ -0,0 +1,30 @@
+・ソ//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SingleNyIdMarkerDirect3d.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Resources.resx
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Resources.resx (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Resources.resx (revision 252)
@@ -0,0 +1,117 @@
+・ソ<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Index: forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Resources.Designer.cs
===================================================================
--- forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Resources.Designer.cs (revision 0)
+++ forFW2.0/sample/SingleNyIdMarkerDirect3d/Properties/Resources.Designer.cs (revision 252)
@@ -0,0 +1,71 @@
+・ソ//------------------------------------------------------------------------------
+// <auto-generated>
+// 縺薙・繧ウ繝シ繝峨・繝・・繝ォ縺ォ繧医▲縺ヲ逕滓・縺輔l縺セ縺励◆縲・
+// 繝ゥ繝ウ繧ソ繧、繝 繝舌・繧ク繝ァ繝ウ:2.0.50727.1433
+//
+// 縺薙・繝輔ぃ繧、繝ォ縺ク縺ョ螟画峩縺ッ縲∽サ・荳九・迥カ豕∽ク九〒荳肴ュ」縺ェ蜍穂ス懊・蜴溷屏縺ォ縺ェ縺」縺溘j縲・
+// 繧ウ繝シ繝峨′蜀咲函謌舌&繧後k縺ィ縺阪↓謳榊、ア縺励◆繧翫@縺セ縺・
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SingleNyIdMarkerDirect3d.Properties
+{
+
+
+ /// <summary>
+ /// 繝ュ繝シ繧ォ繝ゥ繧、繧コ縺輔l縺滓枚蟄怜・縺ェ縺ゥ繧呈、懃エ「縺吶k縺溘a縺ョ縲∝宍蟇・↓蝙区欠螳壹&繧後◆繝ェ繧ス繝シ繧ケ 繧ッ繝ゥ繧ケ縺ァ縺吶€・
+ /// </summary>
+ // 縺薙・繧ッ繝ゥ繧ケ縺ッ StronglyTypedResourceBuilder 繧ッ繝ゥ繧ケ縺・ResGen
+ // 縺セ縺溘・ Visual Studio 縺ョ繧医≧縺ェ繝・・繝ォ繧剃スソ逕ィ縺励※閾ェ蜍慕函謌舌&繧後∪縺励◆縲・
+ // 繝。繝ウ繝舌r霑ス蜉縺セ縺溘・蜑企勁縺吶k縺ォ縺ッ縲・ResX 繝輔ぃ繧、繝ォ繧堤キィ髮・@縺ヲ縲・str 繧ェ繝励す繝ァ繝ウ縺ィ蜈ア縺ォ
+ // ResGen 繧貞ョ溯。後@逶エ縺吶°縲√∪縺溘・ VS 繝励Ο繧ク繧ァ繧ッ繝医r繝薙Ν繝峨@逶エ縺励∪縺吶€・
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ /// <summary>
+ /// 縺薙・繧ッ繝ゥ繧ケ縺ォ菴ソ逕ィ縺輔l繧九€√く繝」繝・す繝・縺輔l縺・ResourceManager 縺ョ繧、繝ウ繧ケ繧ソ繝ウ繧ケ繧定ソ斐@縺セ縺吶€・
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SingleNyIdMarkerDirect3d.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// 蜴ウ蟇・↓蝙区欠螳壹&繧後◆縺薙・繝ェ繧ス繝シ繧ケ 繧ッ繝ゥ繧ケ繧剃スソ逕ィ縺励※縲√☆縺ケ縺ヲ縺ョ讀懃エ「繝ェ繧ス繝シ繧ケ縺ォ蟇セ縺励€・
+ /// 迴セ蝨ィ縺ョ繧ケ繝ャ繝・ラ縺ョ CurrentUICulture 繝励Ο繝代ユ繧」繧偵が繝シ繝舌・繝ゥ繧、繝峨@縺セ縺吶€・
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSquareDetector_Quad.cs
===================================================================
--- forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSquareDetector_Quad.cs (revision 222)
+++ forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSquareDetector_Quad.cs (revision 252)
@@ -418,7 +418,7 @@
}

NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
- NyARIntPoint[] l_imvertex = o_square.imvertex;
+ NyARIntPoint2d[] l_imvertex = o_square.imvertex;
for (int i = 0; i < 4; i++)
{
NyARI64Linear l_line_i = i64liner[i];
Index: forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSingleDetectMarker_Quad.cs
===================================================================
--- forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSingleDetectMarker_Quad.cs (revision 222)
+++ forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSingleDetectMarker_Quad.cs (revision 252)
@@ -38,15 +38,13 @@

namespace jp.nyatla.nyartoolkit.cs.sandbox.quadx2
{
-
-
/**
* 逕サ蜒上°繧陰RCode縺ォ譛€繧ゆク€閾エ縺吶k繝槭・繧ォ繝シ繧・蛟区、懷・縺励€√◎縺ョ螟画鋤陦悟・繧定ィ育ョ励☆繧九け繝ゥ繧ケ縺ァ縺吶€・
*
*/
public class NyARSingleDetectMarker_Quad
{
- private const int AR_SQUARE_MAX = 100;
+ private static int AR_SQUARE_MAX = 100;

private bool _is_continue = false;
private NyARMatchPatt_Color_WITHOUT_PCA _match_patt;
@@ -54,8 +52,6 @@

private NyARSquareStack _square_list = new NyARSquareStack(AR_SQUARE_MAX);

- private NyARCode _code;
-
protected INyARTransMat _transmat;

private double _marker_width;
@@ -87,14 +83,16 @@
this._square_detect = new NyARSquareDetector_Quad(i_param.getDistortionFactor(), scr_size);
this._transmat = new NyARTransMat_X2(i_param);
// 豈碑シ・さ繝シ繝峨r菫晏ュ・
- this._code = i_code;
this._marker_width = i_marker_width;
// 隧穂セ。繝代ち繝シ繝ウ縺ョ繝帙Ν繝€繧剃ス懊k
- this._patt = new NyARColorPatt_O3(_code.getWidth(), _code.getHeight());
- // 隧穂セ。蝎ィ繧剃ス懊k縲・
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA();
+ this._patt = new NyARColorPatt_O3(i_code.getWidth(), i_code.getHeight());
+ // i_code縺ォ蟇セ蠢懊☆繧玖ゥ穂セ。蝎ィ繧剃ス懊k縲・
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);
//・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
this._bin_raster = new NyARBinRaster(scr_size.w / 2, scr_size.h / 2);
+ //蟾ョ蛻・ョ繝シ繧ソ繧、繝ウ繧ケ繧ソ繝ウ繧ケ縺ョ菴懈・
+ this._deviation_data = new NyARMatchPattDeviationColorData(i_code.getWidth(), i_code.getHeight());
+
return;
}

@@ -102,6 +100,9 @@
// private NyARRasterFilter_ARToolkitThreshold _tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100);
private NyARRasterFilter_ARTTh_Quad _tobin_filter = new NyARRasterFilter_ARTTh_Quad(100);

+ private NyARMatchPattResult __detectMarkerLite_mr = new NyARMatchPattResult();
+ private NyARMatchPattDeviationColorData _deviation_data;
+
/**
* i_image縺ォ繝槭・繧ォ繝シ讀懷・蜃ヲ逅・r螳溯。後@縲∫オ先棡繧定ィ倬鹸縺励∪縺吶€・
*
@@ -137,46 +138,39 @@
return false;
}

- // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
- if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(0)))
- {
- // 繝代ち繝シ繝ウ縺ョ蛻・j蜃コ縺励↓螟ア謨・
- return false;
- }
- // 繝代ち繝シ繝ウ繧定ゥ穂セ。蝎ィ縺ォ繧サ繝・ヨ
- if (!this._match_patt.setPatt(this._patt))
- {
- // 險育ョ励↓螟ア謨励@縺溘€・
- throw new NyARException();
- }
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- this._match_patt.evaluate(this._code);
+ bool result = false;
+ NyARMatchPattResult mr = this.__detectMarkerLite_mr;
int square_index = 0;
- int direction = this._match_patt.getDirection();
- double confidence = this._match_patt.getConfidence();
- for (int i = 1; i < number_of_square; i++)
+ int direction = NyARSquare.DIRECTION_UNKNOWN;
+ double confidence = 0;
+ for (int i = 0; i < number_of_square; i++)
{
- // 谺。縺ョ繝代ち繝シ繝ウ繧貞叙蠕・
- this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i));
- // 隧穂セ。蝎ィ縺ォ繧サ繝・ヨ縺吶k縲・
- this._match_patt.setPatt(this._patt);
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- this._match_patt.evaluate(this._code);
- double c2 = this._match_patt.getConfidence();
+ // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
+ if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i)))
+ {
+ continue;
+ }
+ //蜿門セ励ヱ繧ソ繝シ繝ウ繧偵き繝ゥ繝シ蟾ョ蛻・ョ繝シ繧ソ縺ォ螟画鋤縺励※隧穂セ。縺吶k縲・
+ this._deviation_data.setRaster(this._patt);
+ this._match_patt.evaluate(this._deviation_data, mr);
+
+ double c2 = mr.confidence;
if (confidence > c2)
{
continue;
}
// 繧ゅ▲縺ィ荳€閾エ縺吶k繝槭・繧ォ繝シ縺後≠縺」縺溘⊃縺・
square_index = i;
- direction = this._match_patt.getDirection();
+ direction = mr.direction;
confidence = c2;
+ result = true;
}
+
// 繝槭・繧ォ繝シ諠・ア繧剃ソ晏ュ・
this._detected_square = (NyARSquare)l_square_list.getItem(square_index);
this._detected_direction = direction;
this._detected_confidence = confidence;
- return true;
+ return result;
}

/**
Index: forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_X2.cs
===================================================================
--- forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_X2.cs (revision 222)
+++ forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_X2.cs (revision 252)
@@ -414,7 +414,7 @@
}

NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
- NyARIntPoint[] l_imvertex = o_square.imvertex;
+ NyARIntPoint2d[] l_imvertex = o_square.imvertex;
for (int i = 0; i < 4; i++)
{
NyARI64Linear l_line_i = i64liner[i];
Index: forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSingleDetectMarker_X2.cs
===================================================================
--- forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSingleDetectMarker_X2.cs (revision 222)
+++ forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSingleDetectMarker_X2.cs (revision 252)
@@ -36,6 +36,7 @@
using jp.nyatla.nyartoolkit.cs.utils;
namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
{
+
/**
* 逕サ蜒上°繧陰RCode縺ォ譛€繧ゆク€閾エ縺吶k繝槭・繧ォ繝シ繧・蛟区、懷・縺励€√◎縺ョ螟画鋤陦悟・繧定ィ育ョ励☆繧九け繝ゥ繧ケ縺ァ縺吶€・
*
@@ -50,8 +51,6 @@

private NyARSquareStack _square_list = new NyARSquareStack(AR_SQUARE_MAX);

- private NyARCode _code;
-
protected INyARTransMat _transmat;

private double _marker_width;
@@ -80,24 +79,30 @@
{
NyARIntSize scr_size = i_param.getScreenSize();
NyARFixedFloatObserv2IdealMap dist_map = new NyARFixedFloatObserv2IdealMap(i_param.getDistortionFactor(), scr_size);
+
// 隗」譫舌が繝悶ず繧ァ繧ッ繝医r菴懊k
this._square_detect = new NyARSquareDetector_X2(dist_map, scr_size);
this._transmat = new NyARTransMat_X2(i_param);
- // 豈碑シ・さ繝シ繝峨r菫晏ュ・
- this._code = i_code;
this._marker_width = i_marker_width;
+ int cw = i_code.getWidth();
+ int ch = i_code.getHeight();
// 隧穂セ。繝代ち繝シ繝ウ縺ョ繝帙Ν繝€繧剃ス懊k
- this._patt = new NyARColorPatt_O3(_code.getWidth(), _code.getHeight());
+ this._patt = new NyARColorPatt_O3(cw, ch);
// 隧穂セ。蝎ィ繧剃ス懊k縲・
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA();
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);
//・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ //蟾ョ蛻・ョ繝シ繧ソ繧、繝ウ繧ケ繧ソ繝ウ繧ケ縺ョ菴懈・
+ this._deviation_data = new NyARMatchPattDeviationColorData(cw, ch);
return;
}

private NyARBinRaster _bin_raster;
private NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(100);
+ private NyARMatchPattResult __detectMarkerLite_mr = new NyARMatchPattResult();
+ private NyARMatchPattDeviationColorData _deviation_data;

+
/**
* i_image縺ォ繝槭・繧ォ繝シ讀懷・蜃ヲ逅・r螳溯。後@縲∫オ先棡繧定ィ倬鹸縺励∪縺吶€・
*
@@ -115,7 +120,7 @@
throw new NyARException();
}

- //繝ゥ繧ケ繧ソ繧抵シ貞€、繧、繝。繝シ繧ク縺ォ螟画鋤縺吶k.
+ //繝ゥ繧ケ繧ソ繧・1/4縺ョ逕サ蜒上・)・貞€、繧、繝。繝シ繧ク縺ォ螟画鋤縺吶k.
this._tobin_filter.setThreshold(i_threshold);
this._tobin_filter.doFilter(i_raster, this._bin_raster);

@@ -132,47 +137,39 @@
{
return false;
}
-
- // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
- if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(0)))
- {
- // 繝代ち繝シ繝ウ縺ョ蛻・j蜃コ縺励↓螟ア謨・
- return false;
- }
- // 繝代ち繝シ繝ウ繧定ゥ穂セ。蝎ィ縺ォ繧サ繝・ヨ
- if (!this._match_patt.setPatt(this._patt))
- {
- // 險育ョ励↓螟ア謨励@縺溘€・
- throw new NyARException();
- }
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- this._match_patt.evaluate(this._code);
+ bool result = false;
+ NyARMatchPattResult mr = this.__detectMarkerLite_mr;
int square_index = 0;
- int direction = this._match_patt.getDirection();
- double confidence = this._match_patt.getConfidence();
- for (int i = 1; i < number_of_square; i++)
+ int direction = NyARSquare.DIRECTION_UNKNOWN;
+ double confidence = 0;
+ for (int i = 0; i < number_of_square; i++)
{
- // 谺。縺ョ繝代ち繝シ繝ウ繧貞叙蠕・
- this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i));
- // 隧穂セ。蝎ィ縺ォ繧サ繝・ヨ縺吶k縲・
- this._match_patt.setPatt(this._patt);
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- this._match_patt.evaluate(this._code);
- double c2 = this._match_patt.getConfidence();
+ // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
+ if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i)))
+ {
+ continue;
+ }
+ //蜿門セ励ヱ繧ソ繝シ繝ウ繧偵き繝ゥ繝シ蟾ョ蛻・ョ繝シ繧ソ縺ォ螟画鋤縺励※隧穂セ。縺吶k縲・
+ this._deviation_data.setRaster(this._patt);
+ this._match_patt.evaluate(this._deviation_data, mr);
+
+ double c2 = mr.confidence;
if (confidence > c2)
{
continue;
}
// 繧ゅ▲縺ィ荳€閾エ縺吶k繝槭・繧ォ繝シ縺後≠縺」縺溘⊃縺・
square_index = i;
- direction = this._match_patt.getDirection();
+ direction = mr.direction;
confidence = c2;
+ result = true;
}
+
// 繝槭・繧ォ繝シ諠・ア繧剃ソ晏ュ・
this._detected_square = (NyARSquare)l_square_list.getItem(square_index);
this._detected_direction = direction;
this._detected_confidence = confidence;
- return true;
+ return result;
}

/**
@@ -229,4 +226,5 @@
this._is_continue = i_is_continue;
}
}
+
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatFitVecCalculator.cs
===================================================================
--- forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatFitVecCalculator.cs (revision 222)
+++ forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatFitVecCalculator.cs (revision 252)
@@ -23,7 +23,7 @@
ptr = i_mat.getArray();
for (c = 0; c < this.clm; c++)
{
- this.m[c][r] = (double)ptr[c][r] / 0x10000;
+ this._m[c][r] = (double)ptr[c][r] / 0x10000;
}
}
return;
Index: forFW2.0/NyARToolkitCS/NyARToolkitCS.csproj
===================================================================
--- forFW2.0/NyARToolkitCS/NyARToolkitCS.csproj (revision 222)
+++ forFW2.0/NyARToolkitCS/NyARToolkitCS.csproj (revision 252)
@@ -8,7 +8,7 @@
<ProjectGuid>{80391577-476D-4DAD-A4F8-F03C726ACBD8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>jp.nyatla.nyartoolkit.cs</RootNamespace>
+ <RootNamespace>jp.nyatla.nyartoolkit</RootNamespace>
<AssemblyName>NyARToolkitCS</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@@ -38,6 +38,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="cs\core2\rasteranalyzer\threshold\INyARRasterThresholdAnalyzer.cs" />
+ <Compile Include="cs\core2\rasteranalyzer\threshold\NyARRasterThresholdAnalyzer_SlidePTile.cs" />
<Compile Include="cs\core2\types\matrix\NyARFixedFloat16Matrix33.cs" />
<Compile Include="cs\core2\types\matrix\NyARFixedFloat24Matrix33.cs" />
<Compile Include="cs\core2\types\matrix\NyARI64Matrix22.cs" />
@@ -55,6 +57,10 @@
<Compile Include="cs\core\labeling\NyARLabelingLabelStack.cs" />
<Compile Include="cs\core\labeling\NyARLabeling_ARToolKit.cs" />
<Compile Include="cs\core\match\INyARMatchPatt.cs" />
+ <Compile Include="cs\core\match\NyARMatchPattDeviationBlackWhiteData.cs" />
+ <Compile Include="cs\core\match\NyARMatchPattDeviationColorData.cs" />
+ <Compile Include="cs\core\match\NyARMatchPattResult.cs" />
+ <Compile Include="cs\core\match\NyARMatchPatt_BlackWhite.cs" />
<Compile Include="cs\core\match\NyARMatchPatt_Color_WITHOUT_PCA.cs" />
<Compile Include="cs\core\NyARCode.cs" />
<Compile Include="cs\core\NyARSquareDetector.cs" />
@@ -69,6 +75,8 @@
<Compile Include="cs\core\pca2d\NyARPca2d_MatrixPCA.cs" />
<Compile Include="cs\core\pickup\INyARColorPatt.cs" />
<Compile Include="cs\core\pickup\NyARColorPatt_O3.cs" />
+ <Compile Include="cs\core\pickup\NyARColorPatt_Perspective.cs" />
+ <Compile Include="cs\core\pickup\NyARColorPatt_PseudoAffine.cs" />
<Compile Include="cs\core\rasterfilter\INyARRasterFilter.cs" />
<Compile Include="cs\core\rasterfilter\INyARRasterFilter_GsToBin.cs" />
<Compile Include="cs\core\rasterfilter\INyARRasterFilter_RgbToGs.cs" />
@@ -77,10 +85,13 @@
<Compile Include="cs\core\rasterreader\INyARBufferReader.cs" />
<Compile Include="cs\core\rasterreader\INyARRgbPixelReader.cs" />
<Compile Include="cs\core\rasterreader\NyARBufferReader.cs" />
+ <Compile Include="cs\core\rasterreader\NyARRgbPixelReader_INT1D_GLAY_8.cs" />
+ <Compile Include="cs\core\rasterreader\NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs" />
<Compile Include="cs\core\rasterreader\NyARRgbPixelReader_RGB24.cs" />
<Compile Include="cs\core\raster\INyARRaster.cs" />
<Compile Include="cs\core\raster\NyARBinRaster.cs" />
<Compile Include="cs\core\raster\NyARGrayscaleRaster.cs" />
+ <Compile Include="cs\core\raster\NyARRaster.cs" />
<Compile Include="cs\core\raster\NyARRaster_BasicClass.cs" />
<Compile Include="cs\core\raster\rgb\INyARRgbRaster.cs" />
<Compile Include="cs\core\raster\rgb\NyARRgbRaster_BasicClass.cs" />
@@ -102,14 +113,21 @@
<Compile Include="cs\core\types\matrix\NyARDoubleMatrix22.cs" />
<Compile Include="cs\core\types\matrix\NyARDoubleMatrix33.cs" />
<Compile Include="cs\core\types\matrix\NyARDoubleMatrix34.cs" />
+ <Compile Include="cs\core\types\matrix\NyARDoubleMatrix44.cs" />
<Compile Include="cs\core\types\NyARDoublePoint2d.cs" />
<Compile Include="cs\core\types\NyARDoublePoint3d.cs" />
<Compile Include="cs\core\types\NyARIntPoint.cs" />
+ <Compile Include="cs\core\types\NyARIntPoint2d.cs" />
<Compile Include="cs\core\types\NyARIntRect.cs" />
<Compile Include="cs\core\types\NyARIntSize.cs" />
<Compile Include="cs\core\types\NyARLinear.cs" />
<Compile Include="cs\core\types\stack\NyARIntPointStack.cs" />
<Compile Include="cs\core\types\stack\NyARIntRectStack.cs" />
+ <Compile Include="cs\core\utils\NyARDoubleMatrixProcessor.cs" />
+ <Compile Include="cs\core\utils\NyARPerspectiveParamGenerator.cs" />
+ <Compile Include="cs\core\utils\NyARPerspectiveParamGenerator_O1.cs" />
+ <Compile Include="cs\core\utils\NyARSystemOfLinearEquationsProcessor.cs" />
+ <Compile Include="cs\detector\NyARCustomSingleDetectMarker.cs" />
<Compile Include="cs\NyARException.cs" />
<Compile Include="cs\core\NyARMat.cs" />
<Compile Include="cs\core\NyARSquare.cs" />
@@ -118,6 +136,15 @@
<Compile Include="cs\detector\NyARDetectMarker.cs" />
<Compile Include="cs\detector\NyARSingleDetectMarker.cs" />
<Compile Include="cs\core\NyARVertexCounter.cs" />
+ <Compile Include="cs\nyidmarker\data\INyIdMarkerData.cs" />
+ <Compile Include="cs\nyidmarker\data\INyIdMarkerDataEncoder.cs" />
+ <Compile Include="cs\nyidmarker\data\NyIdMarkerDataEncoder_RawBit.cs" />
+ <Compile Include="cs\nyidmarker\data\NyIdMarkerData_RawBit.cs" />
+ <Compile Include="cs\nyidmarker\NyIdMarkerParam.cs" />
+ <Compile Include="cs\nyidmarker\NyIdMarkerPattern.cs" />
+ <Compile Include="cs\nyidmarker\NyIdMarkerPickup.cs" />
+ <Compile Include="cs\processor\SingleARMarkerProcesser.cs" />
+ <Compile Include="cs\processor\SingleNyIdMarkerProcesser.cs" />
<Compile Include="cs\utils.cs\ArrayUtils.cs" />
<Compile Include="cs\utils\IntValue.cs" />
<Compile Include="cs\utils\NyObjectStack.cs" />
Index: forFW2.0/NyARToolkitCS/cs/processor/SingleARMarkerProcesser.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/processor/SingleARMarkerProcesser.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/processor/SingleARMarkerProcesser.cs (revision 252)
@@ -0,0 +1,370 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+
+
+namespace jp.nyatla.nyartoolkit.cs.processor
+{
+ /**
+ * 縺薙・繧ッ繝ゥ繧ケ縺ッ縲∝酔譎ゅ↓・大€九・繝槭・繧ォ繧貞・逅・☆繧九%縺ィ縺ョ縺ァ縺阪k縲√い繝励Μ繧ア繝シ繧キ繝ァ繝ウ繝励Ο繧サ繝・し縺ァ縺吶€・
+ * 繝槭・繧ォ縺ョ蜃コ迴セ繝サ遘サ蜍輔・豸域サ・r縲√う繝吶Φ繝医〒騾夂衍縺吶k縺薙→縺後〒縺阪∪縺吶€・
+ * 繧ッ繝ゥ繧ケ縺ォ縺ッ隍・焚縺ョ繝槭・繧ォ繧堤匳骭イ縺ァ縺阪∪縺吶€ゆク€縺、縺ョ繝槭・繧ォ縺瑚ヲ九▽縺九k縺ィ縲√・繝ュ繧サ繝・し縺ッ邯咏カ壹@縺ヲ蜷後§繝槭・繧ォ繧・
+ * ・代▽縺縺題ェ崎ュ倥@邯壹¢縲∬ヲ句、ア縺・∪縺ァ縺ョ髢薙・莉悶・繝槭・繧ォ繧定ェ崎ュ倥@縺セ縺帙s縲・
+ *
+ * 繧、繝吶Φ繝医・縲・OnEnter竊丹nUpdate[n]竊丹nLeave縺ョ鬆・〒逋コ逕溘@縺セ縺吶€・
+ * 繝槭・繧ォ縺瑚ヲ九▽縺九k縺ィ縺セ縺唹nEnter縺鯉シ大コヲ逋コ逕溘@縺ヲ縲∽ス慕分縺ョ繝槭・繧ォ縺檎匱隕九&繧後◆縺九′繧上°繧翫∪縺吶€・
+ * 谺。縺ォOnUpdate縺ォ繧医j縲∫樟蝨ィ縺ョ螟画鋤陦悟・縺碁€」邯壹@縺ヲ貂。縺輔l縺セ縺吶€よ怙蠕後↓繝槭・繧ォ繧定ヲ句、ア縺・→縲^nLeave
+ * 繧、繝吶Φ繝医′逋コ逕溘@縺セ縺吶€・
+ *
+ */
+ public abstract class SingleARMarkerProcesser
+ {
+ /**
+ * [[STRAGE CLASS]]
+ * selectARCodeIndexFromList縺悟€、繧定ソ斐☆譎ゅ↓菴ソ縺・、画焚蝙九〒縺吶€・
+ */
+
+ private class TResult_selectARCodeIndex
+ {
+ public int direction;
+
+ public double confidence;
+
+ public int code_index;
+ }
+ /**繧ェ繝シ繝翫・縺瑚・逕ア縺ォ菴ソ縺医k繧ソ繧ー螟画焚縺ァ縺吶€・
+ */
+ public object tag;
+
+ private int _lost_delay_count = 0;
+
+ private int _lost_delay = 5;
+
+ private NyARSquareDetector _square_detect;
+
+ protected NyARTransMat _transmat;
+
+ private double _marker_width;
+
+ private NyARMatchPatt_Color_WITHOUT_PCA[] _match_patt;
+
+ private NyARSquareStack _square_list = new NyARSquareStack(100);
+
+ private NyARColorPatt_O3 _patt = null;
+
+ private double _cf_threshold_new = 0.30;
+
+ private double _cf_threshold_exist = 0.15;
+
+ private int _threshold = 110;
+ // [AR]讀懷・邨先棡縺ョ菫晏ュ倡畑
+ private NyARBinRaster _bin_raster;
+
+ private NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110);
+
+ protected int _current_arcode_index = -1;
+
+ private NyARMatchPattDeviationColorData _deviation_data;
+
+
+ public SingleARMarkerProcesser(NyARParam i_param)
+ {
+ NyARIntSize scr_size = i_param.getScreenSize();
+ // 隗」譫舌が繝悶ず繧ァ繧ッ繝医r菴懊k
+ this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
+ this._transmat = new NyARTransMat(i_param);
+ this._deviation_data = new NyARMatchPattDeviationColorData(scr_size.w, scr_size.h);
+
+ // ・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
+ this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ return;
+ }
+
+ public void setThreshold(int i_threshold)
+ {
+ this._threshold = i_threshold;
+ return;
+ }
+
+ /**讀懷・縺吶k繝槭・繧ォ繧ウ繝シ繝峨・驟榊・繧呈欠螳壹@縺セ縺吶€・讀懷・迥カ諷九〒縺薙・髢「謨ー繧貞ョ溯。後☆繧九→縲・
+ * 繧ェ繝悶ず繧ァ繧ッ繝育憾諷九↓蠑キ蛻カ繝ェ繧サ繝・ヨ縺後°縺九j縺セ縺吶€・
+ */
+ public void setARCodeTable(NyARCode[] i_ref_code_table, int i_code_resolution, double i_marker_width)
+ {
+ if (this._current_arcode_index != -1)
+ {
+ // 蠑キ蛻カ繝ェ繧サ繝・ヨ
+ reset(true);
+ }
+ // 讀懷・縺吶k繝槭・繧ォ繧サ繝・ヨ縲∵ュ蝣ア縲∵、懷・蝎ィ繧剃ス懊j逶エ縺吶€・
+ this._patt = new NyARColorPatt_O3(i_code_resolution, i_code_resolution);
+ this._marker_width = i_marker_width;
+
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA[i_ref_code_table.Length];
+ for (int i = 0; i < i_ref_code_table.Length; i++)
+ {
+ this._match_patt[i] = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code_table[i]);
+ }
+ return;
+ }
+
+ public void reset(bool i_is_force)
+ {
+ if (this._current_arcode_index != -1 && i_is_force == false)
+ {
+ // 蠑キ蛻カ譖ク縺肴鋤縺医〒縺ェ縺代l縺ー繧、繝吶Φ繝医さ繝シ繝ォ
+ this.onLeaveHandler();
+ }
+ // 繧ォ繝ャ繝ウ繝医・繝シ繧ォ繧偵Μ繧サ繝・ヨ
+ this._current_arcode_index = -1;
+ return;
+ }
+
+ public void detectMarker(INyARRgbRaster i_raster)
+ {
+ // 繧オ繧、繧コ繝√ぉ繝・け
+ if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize().w / 2, i_raster.getSize().h / 2))
+ {
+ throw new NyARException();
+ }
+
+ // 繧ウ繝シ繝峨ユ繝シ繝悶Ν縺檎┌縺代l縺ー縺薙%縺ァ邨ゅo繧・
+ if (this._match_patt == null)
+ {
+ return;
+ }
+
+ // 繝ゥ繧ケ繧ソ繧・1/4縺ョ逕サ蜒上・)・貞€、繧、繝。繝シ繧ク縺ォ螟画鋤縺吶k.
+ this._tobin_filter.setThreshold(this._threshold);
+ this._tobin_filter.doFilter(i_raster, this._bin_raster);
+
+ NyARSquareStack square_stack = this._square_list;
+ // 繧ケ繧ッ繧ィ繧「繧ウ繝シ繝峨r謗「縺・
+ this._square_detect.detectMarker(this._bin_raster, square_stack);
+ // 隱崎ュ伜・逅・
+ if (this._current_arcode_index == -1)
+ { // 繝槭・繧ォ譛ェ隱崎ュ・
+ detectNewMarker(i_raster, square_stack);
+ }
+ else
+ { // 繝槭・繧ォ隱崎ュ倅クュ
+ detectExistMarker(i_raster, square_stack, this._current_arcode_index);
+ }
+ return;
+ }
+
+
+ private NyARMatchPattResult __detectMarkerLite_mr = new NyARMatchPattResult();
+
+ /**ARCode縺ョ繝ェ繧ケ繝医°繧峨€∵怙繧ゆク€閾エ縺吶k繧ウ繝シ繝臥分蜿キ繧呈、懃エ「縺励∪縺吶€・
+ */
+ private bool selectARCodeIndexFromList(INyARRgbRaster i_raster, NyARSquare i_square, TResult_selectARCodeIndex o_result)
+ {
+ // 迴セ蝨ィ繧ウ繝シ繝峨ユ繝シ繝悶Ν縺ッ繧「繧ッ繝・ぅ繝厄シ・
+ if (this._match_patt == null)
+ {
+ return false;
+ }
+ // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
+ if (!this._patt.pickFromRaster(i_raster, i_square))
+ {
+ return false;
+ }
+ //隧穂セ。繝・・繧ソ繧剃ス懈・縺励※縲∬ゥ穂セ。蝎ィ縺ォ繧サ繝・ヨ
+ this._deviation_data.setRaster(this._patt);
+ NyARMatchPattResult mr = this.__detectMarkerLite_mr;
+ int code_index = 0;
+ int dir = 0;
+ double c1 = 0;
+ // 繧ウ繝シ繝峨→豈碑シ・☆繧・
+ for (int i = 0; i < this._match_patt.Length; i++)
+ {
+ this._match_patt[i].evaluate(this._deviation_data, mr);
+ double c2 = mr.confidence;
+ if (c1 < c2)
+ {
+ code_index = i;
+ c1 = c2;
+ dir = mr.direction;
+ }
+ }
+ o_result.code_index = code_index;
+ o_result.direction = dir;
+ o_result.confidence = c1;
+ return true;
+ }
+
+ private TResult_selectARCodeIndex __detect_X_Marker_detect_result = new TResult_selectARCodeIndex();
+
+ /**譁ー隕上・繝シ繧ォ讀懃エ「 迴セ蝨ィ隱崎ュ倅クュ縺ョ繝槭・繧ォ縺後↑縺・b縺ョ縺ィ縺励※縲∵怙繧りェ崎ュ倥@繧・☆縺・・繝シ繧ォ繧抵シ大€玖ェ崎ュ倥@縺セ縺吶€・
+ */
+ private void detectNewMarker(INyARRgbRaster i_raster, NyARSquareStack i_stack)
+ {
+ int number_of_square = i_stack.getLength();
+ double cf = 0;
+ int dir = 0;
+ int code_index = -1;
+ int square_index = 0;
+ TResult_selectARCodeIndex detect_result = this.__detect_X_Marker_detect_result;
+ for (int i = 0; i < number_of_square; i++)
+ {
+ if (!selectARCodeIndexFromList(i_raster, (NyARSquare)i_stack.getItem(i), detect_result))
+ {
+ // 隕九▽縺九i縺ェ縺・€・
+ return;
+ }
+ if (detect_result.confidence < this._cf_threshold_new)
+ {
+ continue;
+ }
+ if (detect_result.confidence < cf)
+ {
+ // 荳€閾エ蠎ヲ縺御ス弱>縲・
+ continue;
+ }
+ cf = detect_result.confidence;
+ code_index = detect_result.code_index;
+ square_index = i;
+ dir = detect_result.direction;
+ }
+ // 隱崎ュ倡憾諷九r譖エ譁ー
+ updateStatus((NyARSquare)this._square_list.getItem(square_index), code_index, cf, dir);
+ }
+
+ /**繝槭・繧ォ縺ョ邯咏カ夊ェ崎ュ・迴セ蝨ィ隱崎ュ倅クュ縺ョ繝槭・繧ォ繧貞━蜈医@縺ヲ隱崎ュ倥@縺セ縺吶€・
+ * ・域ウィ・峨%縺ョ讖溯・縺ッ縺溘・繧謎サ雁セ後>繧阪>繧咲匱螻輔☆繧九°繧丑ew縺ィ豺キ縺懊↑縺・%縺ィ縲・
+ */
+ private void detectExistMarker(INyARRgbRaster i_raster, NyARSquareStack i_stack, int i_current_id)
+ {
+ int number_of_square = i_stack.getLength();
+ double cf = 0;
+ int dir = 0;
+ int code_index = -1;
+ int square_index = 0;
+ TResult_selectARCodeIndex detect_result = this.__detect_X_Marker_detect_result;
+ for (int i = 0; i < number_of_square; i++)
+ {
+ if (!selectARCodeIndexFromList(i_raster, (NyARSquare)i_stack.getItem(i), detect_result))
+ {
+ // 隕九▽縺九i縺ェ縺・€・
+ return;
+ }
+ // 迴セ蝨ィ縺ョ繝槭・繧ォ繧定ェ崎ュ倥@縺溘°・・
+ if (detect_result.code_index != i_current_id)
+ {
+ // 隱崎ュ倅クュ縺ョ繝槭・繧ォ縺ァ縺ッ縺ェ縺・・縺ァ辟。隕・
+ continue;
+ }
+ if (detect_result.confidence < this._cf_threshold_exist)
+ {
+ continue;
+ }
+ if (detect_result.confidence < cf)
+ {
+ // 荳€閾エ蠎ヲ縺碁ォ倥>譁ケ繧帝∈縺カ
+ continue;
+ }
+ cf = detect_result.confidence;
+ code_index = detect_result.code_index;
+ dir = detect_result.direction;
+ square_index = i;
+ }
+ // 隱崎ュ倡憾諷九r譖エ譁ー
+ updateStatus((NyARSquare)this._square_list.getItem(square_index), code_index, cf, dir);
+ }
+
+ private NyARTransMatResult __NyARSquare_result = new NyARTransMatResult();
+
+ /**繧ェ繝悶ず繧ァ繧ッ繝医・繧ケ繝・・繧ソ繧ケ繧呈峩譁ー縺励€∝ソ・ヲ√↓蠢懊§縺ヲ繝上Φ繝峨Ν髢「謨ー繧帝ァ・虚縺励∪縺吶€・
+ */
+ private void updateStatus(NyARSquare i_square, int i_code_index, double i_cf, int i_dir)
+ {
+ NyARTransMatResult result = this.__NyARSquare_result;
+ if (this._current_arcode_index < 0)
+ {// 譛ェ隱崎ュ倅クュ
+ if (i_code_index < 0)
+ {// 譛ェ隱崎ュ倥°繧画悴隱崎ュ倥・驕キ遘サ
+ // 縺ェ縺ォ繧ゅ@縺ェ縺・h繝シ繧薙€・
+ }
+ else
+ {// 譛ェ隱崎ュ倥°繧芽ェ崎ュ倥・驕キ遘サ
+ this._current_arcode_index = i_code_index;
+ // 繧、繝吶Φ繝育函謌・
+ // OnEnter
+ this.onEnterHandler(i_code_index);
+ // 螟画鋤陦悟・繧剃ス懈・
+ this._transmat.transMat(i_square, i_dir, this._marker_width, result);
+ // OnUpdate
+ this.onUpdateHandler(i_square, result);
+ this._lost_delay_count = 0;
+ }
+ }
+ else
+ {// 隱崎ュ倅クュ
+ if (i_code_index < 0)
+ {// 隱崎ュ倥°繧画悴隱崎ュ倥・驕キ遘サ
+ this._lost_delay_count++;
+ if (this._lost_delay < this._lost_delay_count)
+ {
+ // OnLeave
+ this._current_arcode_index = -1;
+ this.onLeaveHandler();
+ }
+ }
+ else if (i_code_index == this._current_arcode_index)
+ {// 蜷後§ARCode縺ョ蜀崎ェ崎ュ・
+ // 繧、繝吶Φ繝育函謌・
+ // 螟画鋤陦悟・繧剃ス懈・
+ this._transmat.transMat(i_square, i_dir, this._marker_width, result);
+ // OnUpdate
+ this.onUpdateHandler(i_square, result);
+ this._lost_delay_count = 0;
+ }
+ else
+ {// 逡ー縺ェ繧九さ繝シ繝峨・隱崎ュ倪・莉翫・繧オ繝昴・繝医@縺ェ縺・€・
+ throw new NyARException();
+ }
+ }
+ return;
+ }
+
+ protected abstract void onEnterHandler(int i_code);
+
+ protected abstract void onLeaveHandler();
+
+ protected abstract void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result);
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/processor/SingleNyIdMarkerProcesser.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/processor/SingleNyIdMarkerProcesser.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/processor/SingleNyIdMarkerProcesser.cs (revision 252)
@@ -0,0 +1,275 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.core2;
+using jp.nyatla.nyartoolkit.cs.nyidmarker;
+
+
+namespace jp.nyatla.nyartoolkit.cs.processor
+{
+public abstract class SingleNyIdMarkerProcesser
+{
+ /**
+ * 繧ェ繝シ繝翫・縺瑚・逕ア縺ォ菴ソ縺医k繧ソ繧ー螟画焚縺ァ縺吶€・
+ */
+ public object tag;
+
+ /**
+ * 繝ュ繧ケ繝磯≦蟒カ縺ョ邂。逅・
+ */
+ private int _lost_delay_count = 0;
+ private int _lost_delay = 5;
+
+ private NyARSquareDetector _square_detect;
+ protected NyARTransMat _transmat;
+ private double _marker_width=100;
+
+ private NyARSquareStack _square_list = new NyARSquareStack(100);
+ private INyIdMarkerDataEncoder _encoder;
+ private bool _is_active;
+ private INyIdMarkerData _data_temp;
+ private INyIdMarkerData _data_current;
+
+ private int _current_threshold=110;
+ // [AR]讀懷・邨先棡縺ョ菫晏ュ倡畑
+ private NyARBinRaster _bin_raster;
+
+ private NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110);
+
+ private NyIdMarkerPickup _id_pickup = new NyIdMarkerPickup();
+
+
+ protected SingleNyIdMarkerProcesser(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format)
+ {
+ NyARIntSize scr_size = i_param.getScreenSize();
+ // 隗」譫舌が繝悶ず繧ァ繧ッ繝医r菴懊k
+ this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
+ this._transmat = new NyARTransMat(i_param);
+ this._encoder=i_encoder;
+
+ // ・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
+ this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ //繝ッ繝シ繧ッ逕ィ縺ョ繝・・繧ソ繧ェ繝悶ず繧ァ繧ッ繝医r・貞€倶ス懊k
+ this._is_active=false;
+ this._data_temp=i_encoder.createDataInstance();
+ this._data_current=i_encoder.createDataInstance();
+ this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,i_raster_format,4);
+ return;
+ }
+
+ public void setMarkerWidth(int i_width)
+ {
+ this._marker_width=i_width;
+ return;
+ }
+
+ public void reset(bool i_is_force)
+ {
+ if (this._data_current!=null && i_is_force == false) {
+ // 蠑キ蛻カ譖ク縺肴鋤縺医〒縺ェ縺代l縺ー繧、繝吶Φ繝医さ繝シ繝ォ
+ this.onLeaveHandler();
+ }
+ // 繧ォ繝ャ繝ウ繝医・繝シ繧ォ繧偵Μ繧サ繝・ヨ
+ this._data_current = null;
+ return;
+ }
+
+ public void detectMarker(INyARRgbRaster i_raster)
+ {
+ // 繧オ繧、繧コ繝√ぉ繝・け
+ if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h)) {
+ throw new NyARException();
+ }
+ // 繝ゥ繧ケ繧ソ繧抵シ貞€、繧、繝。繝シ繧ク縺ォ螟画鋤縺吶k.
+ this._tobin_filter.setThreshold(this._current_threshold);
+ this._tobin_filter.doFilter(i_raster, this._bin_raster);
+
+ NyARSquareStack square_stack = this._square_list;
+ // 繧ケ繧ッ繧ィ繧「繧ウ繝シ繝峨r謗「縺・
+ this._square_detect.detectMarker(this._bin_raster, square_stack);
+ // 隱崎ュ伜・逅・
+ if (!this._is_active) {
+ // 繝槭・繧ォ譛ェ隱崎ュ倪・譁ー隕剰ェ崎ュ・
+ detectNewMarker(i_raster, square_stack);
+ } else {
+ // 繝槭・繧ォ隱崎ュ倅セ晞シ竊堤カ咏カ夊ェ崎ュ・
+ detectExistMarker(i_raster, square_stack);
+ }
+ return;
+ }
+
+
+ private NyIdMarkerPattern _marker_data=new NyIdMarkerPattern();
+ private NyIdMarkerParam _marker_param=new NyIdMarkerParam();
+ private NyARRasterThresholdAnalyzer_SlidePTile _threshold_detect;
+
+ /**譁ー隕上・繝シ繧ォ讀懃エ「 迴セ蝨ィ隱崎ュ倅クュ縺ョ繝槭・繧ォ縺後↑縺・b縺ョ縺ィ縺励※縲∵怙繧りェ崎ュ倥@繧・☆縺・・繝シ繧ォ繧抵シ大€玖ェ崎ュ倥@縺セ縺吶€・
+ */
+ private void detectNewMarker(INyARRgbRaster i_raster, NyARSquareStack i_stack)
+ {
+ NyIdMarkerParam param=this._marker_param;
+ NyIdMarkerPattern patt_data =this._marker_data;
+ int number_of_square = i_stack.getLength();
+ NyARSquare current_square = null;
+ INyIdMarkerData marker_id = null;
+ for (int i = 0; i < number_of_square; i++) {
+ current_square = (NyARSquare)i_stack.getItem(i);
+ // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
+ if (!this._id_pickup.pickFromRaster(i_raster, current_square, patt_data, param))
+ {
+ continue;
+ }
+ //繧ィ繝ウ繧ウ繝シ繝・
+ if(!this._encoder.encode(patt_data,this._data_temp)){
+ continue;
+ }
+ //隱崎ュ倡紫縺御ク€逡ェ鬮倥>繧ゅ・・亥頃譛蛾擇遨阪′荳€逡ェ螟ァ縺阪>繧ゅ・・峨r驕ク謚槭☆繧・逵∫払)
+ //id隱崎ュ倥′謌仙粥縺励◆繧臥オゆコ・
+ marker_id=this._data_temp;
+ break;
+ }
+
+ // 隱崎ュ倡憾諷九r譖エ譁ー
+ bool is_id_found = updateStatus(current_square, marker_id, param);
+
+ //髢セ蛟、繝輔ぅ繝シ繝峨ヰ繝・け(detectExistMarker縺ォ繧ゅ≠繧九h)
+ if(is_id_found){
+ //繝槭・繧ォ縺後≠繧後・縲√・繝シ繧ォ縺ョ蜻ィ霎コ髢セ蛟、繧貞渚譏
+ this._current_threshold=(this._current_threshold+param.threshold)/2;
+ }else{
+ //繝槭・繧ォ縺後↑縺代l縺ー縲∵爾邏「+DualPTail縺ァ蝓コ貅冶シ晏コヲ讀懃エ「
+ this._threshold_detect.analyzeRaster(i_raster);
+ this._current_threshold=(this._current_threshold+this._threshold_detect.getThreshold())/2;
+ }
+ return;
+ }
+
+ /**繝槭・繧ォ縺ョ邯咏カ夊ェ崎ュ・迴セ蝨ィ隱崎ュ倅クュ縺ョ繝槭・繧ォ繧貞━蜈医@縺ヲ隱崎ュ倥@縺セ縺吶€・
+ * ・域ウィ・峨%縺ョ讖溯・縺ッ縺溘・繧謎サ雁セ後>繧阪>繧咲匱螻輔☆繧九°繧丑ew縺ィ豺キ縺懊↑縺・%縺ィ縲・
+ */
+ private void detectExistMarker(INyARRgbRaster i_raster, NyARSquareStack i_stack)
+ {
+ NyIdMarkerParam param=this._marker_param;
+ NyIdMarkerPattern patt_data =this._marker_data;
+ int number_of_square = i_stack.getLength();
+ NyARSquare current_square = null;
+ INyIdMarkerData marker_id = null;
+ for (int i = 0; i < number_of_square; i++){
+ //id繝槭・繧ォ繧定ェ崎ュ・
+ current_square = (NyARSquare)i_stack.getItem(i);
+ if (!this._id_pickup.pickFromRaster(i_raster, current_square, patt_data, param))
+ {
+ continue;
+ }
+ if(!this._encoder.encode(patt_data,this._data_temp)){
+ continue;
+ }
+ //迴セ蝨ィ隱崎ュ倅クュ縺ョid縺狗「コ隱・
+ if(!this._data_current.isEqual((this._data_temp))){
+ continue;
+ }
+ //迴セ蝨ィ隱崎ュ倅クュ縺ョ繧ゅ・縺ァ縺ゅl縺ー縲∫オゆコ・
+ marker_id=this._data_temp;
+ break;
+ }
+ // 隱崎ュ倡憾諷九r譖エ譁ー
+ bool is_id_found = updateStatus(current_square, marker_id, param);
+
+ //髢セ蛟、繝輔ぅ繝シ繝峨ヰ繝・け(detectExistMarker縺ォ繧ゅ≠繧九h)
+ if(is_id_found){
+ //繝槭・繧ォ縺後≠繧後・縲√・繝シ繧ォ縺ョ蜻ィ霎コ髢セ蛟、繧貞渚譏
+ this._current_threshold=(this._current_threshold+param.threshold)/2;
+ }else{
+ //繝槭・繧ォ縺後↑縺代l縺ー縲∵爾邏「+DualPTail縺ァ蝓コ貅冶シ晏コヲ讀懃エ「
+ this._threshold_detect.analyzeRaster(i_raster);
+ this._current_threshold=(this._current_threshold+this._threshold_detect.getThreshold())/2;
+ }
+ return;
+ }
+
+ private NyARTransMatResult __NyARSquare_result = new NyARTransMatResult();
+
+ /**繧ェ繝悶ず繧ァ繧ッ繝医・繧ケ繝・・繧ソ繧ケ繧呈峩譁ー縺励€∝ソ・ヲ√↓蠢懊§縺ヲ繝上Φ繝峨Ν髢「謨ー繧帝ァ・虚縺励∪縺吶€・
+ */
+ private bool updateStatus(NyARSquare i_square, INyIdMarkerData i_marker_data,NyIdMarkerParam i_param)
+ {
+ bool is_id_found=false;
+ NyARTransMatResult result = this.__NyARSquare_result;
+ if (!this._is_active) {// 譛ェ隱崎ュ倅クュ
+ if (i_marker_data==null) {// 譛ェ隱崎ュ倥°繧画悴隱崎ュ倥・驕キ遘サ
+ // 縺ェ縺ォ繧ゅ@縺ェ縺・h繝シ繧薙€・
+ this._is_active=false;
+ } else {// 譛ェ隱崎ュ倥°繧芽ェ崎ュ倥・驕キ遘サ
+ this._data_current.copyFrom(i_marker_data);
+ // 繧、繝吶Φ繝育函謌・
+ // OnEnter
+ this.onEnterHandler(this._data_current);
+ // 螟画鋤陦悟・繧剃ス懈・
+ this._transmat.transMat(i_square,i_param.direction, this._marker_width, result);
+ // OnUpdate
+ this.onUpdateHandler(i_square, result);
+ this._lost_delay_count = 0;
+ this._is_active=true;
+ is_id_found=true;
+ }
+ } else {// 隱崎ュ倅クュ
+ if (i_marker_data==null) {
+ // 隱崎ュ倥°繧画悴隱崎ュ倥・驕キ遘サ
+ this._lost_delay_count++;
+ if (this._lost_delay < this._lost_delay_count) {
+ // OnLeave
+ this.onLeaveHandler();
+ this._is_active=false;
+ }
+ } else if(this._data_current.isEqual(i_marker_data)) {
+ //蜷後§id縺ョ蜀崎ェ崎ュ・
+ this._transmat.transMat(i_square, i_param.direction, this._marker_width, result);
+ // OnUpdate
+ this.onUpdateHandler(i_square, result);
+ this._lost_delay_count = 0;
+ is_id_found=true;
+ } else {// 逡ー縺ェ繧九さ繝シ繝峨・隱崎ュ倪・莉翫・繧オ繝昴・繝医@縺ェ縺・€・
+ throw new NyARException();
+ }
+ }
+ return is_id_found;
+ }
+ //騾夂衍繝上Φ繝峨Λ
+ protected abstract void onEnterHandler(INyIdMarkerData i_code);
+ protected abstract void onLeaveHandler();
+ protected abstract void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result);
+}
+
+}
Index: forFW2.0/NyARToolkitCS/cs/utils/NyObjectStack.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/utils/NyObjectStack.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/utils/NyObjectStack.cs (revision 252)
@@ -1,12 +1,6 @@
/*
* PROJECT: NyARToolkitCS
* --------------------------------------------------------------------------------
- * This work is based on the original ARToolKit developed by
- * Hirokazu Kato
- * Mark Billinghurst
- * HITLab, University of Washington, Seattle
- * http://www.hitl.washington.edu/artoolkit/
- *
* The NyARToolkit is Java version ARToolkit class library.
* Copyright (C)2008 R.Iizuka
*
Index: forFW2.0/NyARToolkitCS/cs/utils/DoubleValue.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/utils/DoubleValue.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/utils/DoubleValue.cs (revision 252)
@@ -1,12 +1,6 @@
/*
* PROJECT: NyARToolkitCS
* --------------------------------------------------------------------------------
- * This work is based on the original ARToolKit developed by
- * Hirokazu Kato
- * Mark Billinghurst
- * HITLab, University of Washington, Seattle
- * http://www.hitl.washington.edu/artoolkit/
- *
* The NyARToolkit is Java version ARToolkit class library.
* Copyright (C)2008 R.Iizuka
*
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPickup.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPickup.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPickup.cs (revision 252)
@@ -0,0 +1,1144 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+using jp.nyatla.nyartoolkit.cs.core;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ /**
+ * NyARColorPatt_NyIdMarker縺後Λ繧ケ繧ソ縺九iPerspective螟画鋤縺励※隱ュ縺ソ縺縺吶◆繧√・繧ッ繝ゥ繧ケ
+ *
+ */
+ class PerspectivePixelReader
+ {
+ private NyARPerspectiveParamGenerator _param_gen = new NyARPerspectiveParamGenerator_O1(1, 1, 100, 100);
+ private double[] _cparam = new double[8];
+
+ private INyARRgbRaster _raster;
+ private NyARIntSize _raster_size;
+
+ public PerspectivePixelReader()
+ {
+ return;
+ }
+ public void setSourceRaster(INyARRgbRaster i_raster)
+ {
+ this._raster = i_raster;
+ this._raster_size = i_raster.getSize();
+ return;
+ }
+ public bool setSourceSquare(NyARIntPoint2d[] i_vertex)
+ {
+ return this._param_gen.getParam(i_vertex, this._cparam);
+ }
+
+ /**
+ * 遏ゥ蠖「縺九i繝斐け繧サ繝ォ繧貞・繧雁・縺励∪縺・
+ * @param i_lt_x
+ * @param i_lt_y
+ * @param i_step_x
+ * @param i_step_y
+ * @param i_width
+ * @param i_height
+ * @param i_out_st
+ * o_pixel縺ク縺ョ譬シ邏榊エ謇€縺ョ蜈磯ュ繧、繝ウ繝・け繧ケ
+ * @param o_pixel
+ * @throws NyARException
+ */
+ private bool rectPixels(int i_lt_x, int i_lt_y, int i_step_x, int i_step_y, int i_width, int i_height, int i_out_st, int[] o_pixel)
+ {
+ double[] cpara = this._cparam;
+ INyARRgbPixelReader reader = this._raster.getRgbPixelReader();
+ int[] ref_x = this._ref_x;
+ int[] ref_y = this._ref_y;
+ int[] pixcel_temp = this._pixcel_temp;
+ int raster_width = this._raster_size.w;
+ int raster_height = this._raster_size.h;
+
+ int out_index = i_out_st;
+ double cpara_6 = cpara[6];
+ double cpara_0 = cpara[0];
+ double cpara_3 = cpara[3];
+
+ for (int i = 0; i < i_height; i++)
+ {
+ //1蛻怜・縺ョ繝斐け繧サ繝ォ縺ョ繧、繝ウ繝・ャ繧ッ繧ケ蛟、繧定ィ育ョ励☆繧九€・
+ int cy0 = 1 + i * i_step_y + i_lt_y;
+ double cpy0_12 = cpara[1] * cy0 + cpara[2];
+ double cpy0_45 = cpara[4] * cy0 + cpara[5];
+ double cpy0_7 = cpara[7] * cy0 + 1.0;
+ int pt = 0;
+ for (int i2 = 0; i2 < i_width; i2++)
+ {
+ int cx0 = 1 + i2 * i_step_x + i_lt_x;
+ double d = cpara_6 * cx0 + cpy0_7;
+ int x = (int)((cpara_0 * cx0 + cpy0_12) / d);
+ int y = (int)((cpara_3 * cx0 + cpy0_45) / d);
+ if (x < 0 || y < 0 || x >= raster_width || y >= raster_height)
+ {
+ return false;
+ }
+ ref_x[pt] = x;
+ ref_y[pt] = y;
+ pt++;
+ }
+ //1陦悟・縺ョ繝斐け繧サ繝ォ繧貞叙蠕・蝣エ蜷医↓繧医▲縺ヲ縺ッ蟆ら畑繧「繧ッ繧サ繧オ繧呈嶌縺・◆譁ケ縺後>縺・
+ reader.getPixelSet(ref_x, ref_y, i_width, pixcel_temp);
+ //繧ー繝ャ繝シ繧ケ繧ア繝シ繝ォ縺ォ縺励↑縺後i縲〕ine竊知ap縺ク縺ョ霆「蜀・
+ for (int i2 = 0; i2 < i_width; i2++)
+ {
+ int index = i2 * 3;
+ o_pixel[out_index] = (pixcel_temp[index + 0] + pixcel_temp[index + 1] + pixcel_temp[index + 2]) / 3;
+ out_index++;
+ }
+ }
+ return true;
+ }
+ /**
+ * i_freq縺ォ縺ゅk繧シ繝ュ繧ッ繝ュ繧ケ轤ケ縺ョ蜻ィ譛溘′縲∫ュ蛾俣髫斐°隱ソ縺ケ縺セ縺吶€・
+ * 谺。谿オ蜊雁捉譛溘′縲∝燕谿オ縺ョ80%繧医j螟ァ縺阪¥縲・20%譛ェ貅€縺ァ縺ゅk繧ゅ・繧偵€∫ュ蛾俣髫泌捉譛溘〒縺ゅk縺ィ縺ソ縺ェ縺励∪縺吶€・
+ * @param i_freq
+ * @param i_width
+ */
+ private static bool checkFreqWidth(int[] i_freq, int i_width)
+ {
+ int c = i_freq[1] - i_freq[0];
+ int count = i_width * 2 - 1;
+ for (int i = 1; i < count; i++)
+ {
+ int n = i_freq[i + 1] - i_freq[i];
+ int v = n * 100 / c;
+ if (v > 150 || v < 50)
+ {
+ return false;
+ }
+ c = n;
+ }
+ return true;
+ }
+ /**
+ * i_freq_count_table縺ィi_freq_table縺ョ蜀・ョケ繧定ェソ譟サ縺励€∵怙繧ょ、ァ縺阪↑蜻ィ豕「謨ー謌仙・繧定ソ斐@縺セ縺吶€・
+ * @param i_freq_count_table
+ * @param i_freq_table
+ * @param o_freq_table
+ * @return
+ * 隕九▽縺九l縺ー0莉・荳翫€∝ッ・セ帙¢繧後・0譛ェ貅€
+ */
+ private static int getMaxFreq(int[] i_freq_count_table, int[] i_freq_table, int[] o_freq_table)
+ {
+ //荳€逡ェ謌仙・縺ョ螟ァ縺阪>繧ゅ・繧貞セ励k
+ int index = -1;
+ int max = 0;
+ for (int i = 0; i < MAX_FREQ; i++)
+ {
+ if (max < i_freq_count_table[i])
+ {
+ index = i;
+ max = i_freq_count_table[i];
+ }
+ }
+ if (index == -1)
+ {
+ return -1;
+ }
+ /*蜻ィ豕「謨ー繧、繝ウ繝・け繧ケ繧定ィ育ョ・/
+ int st = (index - 1) * index;
+ for (int i = 0; i < index * 2; i++)
+ {
+ o_freq_table[i] = i_freq_table[st + i] * FRQ_STEP / max;
+ }
+ return index;
+ }
+
+
+ //繧ソ繧、繝溘Φ繧ー繝代ち繝シ繝ウ逕ィ縺ョ繝代Λ繝。繧ソ(FRQ_POINTS*FRQ_STEP縺・00繧定カ・∴縺ェ縺・h縺・↓縺吶k縺薙→)
+ private const int FRQ_EDGE = 5;
+ private const int FRQ_STEP = 2;
+ private const int FRQ_POINTS = (100 - (FRQ_EDGE * 2)) / FRQ_STEP;
+
+
+ private const int MIN_FREQ = 3;
+ private const int MAX_FREQ = 10;
+ private const int FREQ_SAMPLE_NUM = 4;
+ private const int MAX_DATA_BITS = MAX_FREQ + MAX_FREQ - 1;
+
+ private int[] _ref_x = new int[108];
+ private int[] _ref_y = new int[108];
+ //(model+1)*4*3縺ィTHRESHOLD_PIXEL*3縺ョ縺ゥ縺。繧峨°螟ァ縺阪>譁ケ
+ private int[] _pixcel_temp = new int[108 * 3];
+
+ private int[] _freq_count_table = new int[MAX_FREQ];
+ private int[] _freq_table = new int[(MAX_FREQ * 2 - 1) * MAX_FREQ * 2 / 2];
+
+ /**
+ * i_y1陦檎岼縺ィi_y2陦檎岼繧貞ケウ蝮・@縺ヲ縲√ち繧、繝溘Φ繧ー繝代ち繝シ繝ウ縺ョ蜻ィ豕「謨ー繧貞セ励∪縺吶€・
+ * LHL繧・蜻ィ譛溘→縺励※縲√◆縺ィ縺医・LHLHL縺ョ蝣エ蜷医・2繧定ソ斐@縺セ縺吶€・HLH繧ЗLHL遲峨・蟋狗ォッ縺ィ邨らォッ縺ョ繝ャ繝吶Ν縺檎焚縺ェ繧九ヱ繧ソ繝シ繝ウ繧・
+ * 讀懷・縺励◆蝣エ蜷医€・未謨ー縺ッ螟ア謨励@縺セ縺吶€・
+ *
+ * @param i_y1
+ * @param i_y2
+ * @param i_th_h
+ * @param i_th_l
+ * @param o_edge_index
+ * 讀懷・縺励◆繧ィ繝・ず菴咲スョ(H->L,L->H)縺ョ繧、繝ウ繝・け繧ケ繧貞女縺大叙繧矩・蛻励〒縺吶€・
+ * [FRQ_POINTS]莉・荳翫・驟榊・繧呈欠螳壹@縺ヲ縺上□縺輔>縲・
+ * @return
+ * @throws NyARException
+ */
+ public int getRowFrequency(int i_y1, int i_th_h, int i_th_l, int[] o_edge_index)
+ {
+ //3,4,5,6,7,8,9,10
+ int[] freq_count_table = this._freq_count_table;
+ //0,2,4,6,8,10,12,14,16,18,20縺ョ隕∫エ繧呈戟縺、驟榊・
+ int[] freq_table = this._freq_table;
+ //蛻晄悄蛹・
+ double[] cpara = this._cparam;
+ INyARRgbPixelReader reader = this._raster.getRgbPixelReader();
+ int[] ref_x = this._ref_x;
+ int[] ref_y = this._ref_y;
+ int[] pixcel_temp = this._pixcel_temp;
+ for (int i = 0; i < 10; i++)
+ {
+ freq_count_table[i] = 0;
+ }
+ for (int i = 0; i < 110; i++)
+ {
+ freq_table[i] = 0;
+ }
+ int raster_width = this._raster_size.w;
+ int raster_height = this._raster_size.h;
+
+ double cpara_0 = cpara[0];
+ double cpara_3 = cpara[3];
+ double cpara_6 = cpara[6];
+
+ //10-20繝斐け繧サ繝ォ逶ョ縺九i繧ソ繧、繝溘Φ繧ー繝代ち繝シ繝ウ繧呈、懷・
+ for (int i = 0; i < FREQ_SAMPLE_NUM; i++)
+ {
+ //2陦悟・縺ョ繝斐け繧サ繝ォ繧、繝ウ繝・ャ繧ッ繧ケ繧定ィ育ョ・
+ double cy0 = 1 + i_y1 + i;
+ double cpy0_12 = cpara[1] * cy0 + cpara[2];
+ double cpy0_45 = cpara[4] * cy0 + cpara[5];
+ double cpy0_7 = cpara[7] * cy0 + 1.0;
+
+ int pt = 0;
+ for (int i2 = 0; i2 < FRQ_POINTS; i2++)
+ {
+ double cx0 = 1 + i2 * FRQ_STEP + FRQ_EDGE;
+ double d = (cpara_6 * cx0) + cpy0_7;
+ int x = (int)((cpara_0 * cx0 + cpy0_12) / d);
+ int y = (int)((cpara_3 * cx0 + cpy0_45) / d);
+ if (x < 0 || y < 0 || x >= raster_width || y >= raster_height)
+ {
+ return -1;
+ }
+ ref_x[pt] = x;
+ ref_y[pt] = y;
+ pt++;
+ }
+
+ //繝斐け繧サ繝ォ繧貞叙蠕・蜈・蜉帷判蜒上r螟壽ァ伜喧縺吶k縺ェ繧峨%縺薙°繧牙・繧定ェソ謨エ縺吶k縺薙→)
+ reader.getPixelSet(ref_x, ref_y, FRQ_POINTS, pixcel_temp);
+
+ //o_edge_index繧剃ク€譎ら噪縺ォ遐エ螢翫@縺ヲ隱ソ譟サ縺吶k
+ int freq_t = getFreqInfo(pixcel_temp, i_th_h, i_th_l, o_edge_index);
+
+ //蜻ィ譛溘・3-10縺ァ縺ゅk縺薙→
+ if (freq_t < MIN_FREQ || freq_t > MAX_FREQ)
+ {
+ continue;
+ }
+ //蜻ィ譛溘・遲蛾俣髫斐〒縺ゅk縺薙→
+ if (!checkFreqWidth(o_edge_index, freq_t))
+ {
+ continue;
+ }
+ //讀懷・繧ォ繧ヲ繝ウ繧ソ繧定ソス蜉
+ freq_count_table[freq_t]++;
+ int table_st = (freq_t - 1) * freq_t;
+ for (int i2 = 0; i2 < freq_t * 2; i2++)
+ {
+ freq_table[table_st + i2] += o_edge_index[i2];
+ }
+ }
+ return getMaxFreq(freq_count_table, freq_table, o_edge_index);
+ }
+
+ public int getColFrequency(int i_x1, int i_th_h, int i_th_l, int[] o_edge_index)
+ {
+ double[] cpara = this._cparam;
+ INyARRgbPixelReader reader = this._raster.getRgbPixelReader();
+ int[] ref_x = this._ref_x;
+ int[] ref_y = this._ref_y;
+ int[] pixcel_temp = this._pixcel_temp;
+ //0,2,4,6,8,10,12,14,16,18,20=(11*20)/2=110
+ //蛻晄悄蛹・
+ int[] freq_count_table = this._freq_count_table;
+ for (int i = 0; i < 10; i++)
+ {
+ freq_count_table[i] = 0;
+ }
+ int[] freq_table = this._freq_table;
+ for (int i = 0; i < 110; i++)
+ {
+ freq_table[i] = 0;
+ }
+ int raster_width = this._raster_size.w;
+ int raster_height = this._raster_size.h;
+
+
+ double cpara7 = cpara[7];
+ double cpara4 = cpara[4];
+ double cpara1 = cpara[1];
+ //蝓コ貅也せ縺九i4繝斐け繧サ繝ォ繧貞盾辣ァ繝代ち繝シ繝ウ縺ィ縺励※謚ス蜃コ
+ for (int i = 0; i < FREQ_SAMPLE_NUM; i++)
+ {
+
+ int cx0 = 1 + i + i_x1;
+ double cp6_0 = cpara[6] * cx0;
+ double cpx0_0 = cpara[0] * cx0 + cpara[2];
+ double cpx3_0 = cpara[3] * cx0 + cpara[5];
+
+ int pt = 0;
+ for (int i2 = 0; i2 < FRQ_POINTS; i2++)
+ {
+ int cy = 1 + i2 * FRQ_STEP + FRQ_EDGE;
+
+ double d = cp6_0 + cpara7 * cy + 1.0;
+ int x = (int)((cpx0_0 + cpara1 * cy) / d);
+ int y = (int)((cpx3_0 + cpara4 * cy) / d);
+ if (x < 0 || y < 0 || x >= raster_width || y >= raster_height)
+ {
+ return -1;
+ }
+ ref_x[pt] = x;
+ ref_y[pt] = y;
+ pt++;
+ }
+
+ //繝斐け繧サ繝ォ繧貞叙蠕・蜈・蜉帷判蜒上r螟壽ァ伜喧縺吶k縺ェ繧峨%縺薙r隱ソ謨エ縺吶k縺薙→)
+ reader.getPixelSet(ref_x, ref_y, FRQ_POINTS, pixcel_temp);
+
+ int freq_t = getFreqInfo(pixcel_temp, i_th_h, i_th_l, o_edge_index);
+ //蜻ィ譛溘・3-10縺ァ縺ゅk縺薙→
+ if (freq_t < MIN_FREQ || freq_t > MAX_FREQ)
+ {
+ continue;
+ }
+ //蜻ィ譛溘・遲蛾俣髫斐〒縺ゅk縺薙→
+ if (!checkFreqWidth(o_edge_index, freq_t))
+ {
+ continue;
+ }
+ //讀懷・繧ォ繧ヲ繝ウ繧ソ繧定ソス蜉
+ freq_count_table[freq_t]++;
+ int table_st = (freq_t - 1) * freq_t;
+ for (int i2 = 0; i2 < freq_t * 2; i2++)
+ {
+ freq_table[table_st + i2] += o_edge_index[i2];
+ }
+ }
+ return getMaxFreq(freq_count_table, freq_table, o_edge_index);
+ }
+
+ /**
+ * 繝・ヰ繝・け縺吶s縺繧鋭tatic縺ォ縺励※縺奇ス・
+ * @param i_pixcels
+ * @param i_th_h
+ * @param i_th_l
+ * @param o_edge_index
+ * @return
+ */
+ private static int getFreqInfo(int[] i_pixcels, int i_th_h, int i_th_l, int[] o_edge_index)
+ {
+ //繝医・繧ッ繝ウ繧定ァ」譫舌@縺ヲ縲∝捉豕「謨ー繧定ィ育ョ・
+ int i = 0;
+ int frq_l2h = 0;
+ int frq_h2l = 0;
+ while (i < FRQ_POINTS)
+ {
+ //L->H繝医・繧ッ繝ウ繧呈、懷・縺吶k
+ while (i < FRQ_POINTS)
+ {
+ int index = i * 3;
+ int pix = (i_pixcels[index + 0] + i_pixcels[index + 1] + i_pixcels[index + 2]) / 3;
+ if (pix > i_th_h)
+ {
+ //繝医・繧ッ繝ウ逋コ隕・
+ o_edge_index[frq_l2h + frq_h2l] = i;
+ frq_l2h++;
+ break;
+ }
+ i++;
+ }
+ i++;
+ //L->H繝医・繧ッ繝ウ繧呈、懷・縺吶k
+ while (i < FRQ_POINTS)
+ {
+ int index = i * 3;
+ int pix = (i_pixcels[index + 0] + i_pixcels[index + 1] + i_pixcels[index + 2]) / 3;
+ if (pix <= i_th_l)
+ {
+ //繝医・繧ッ繝ウ逋コ隕・
+ o_edge_index[frq_l2h + frq_h2l] = i;
+ frq_h2l++;
+ break;
+ }
+ i++;
+ }
+ i++;
+ }
+ return frq_l2h == frq_h2l ? frq_l2h : -1;
+ }
+
+ private const int THRESHOLD_EDGE = 10;
+ private const int THRESHOLD_STEP = 2;
+ private const int THRESHOLD_WIDTH = 10;
+ private const int THRESHOLD_PIXEL = THRESHOLD_WIDTH / THRESHOLD_STEP;
+ private const int THRESHOLD_SAMPLE = THRESHOLD_PIXEL * THRESHOLD_PIXEL;
+ private const int THRESHOLD_SAMPLE_LT = THRESHOLD_EDGE;
+ private const int THRESHOLD_SAMPLE_RB = 100 - THRESHOLD_WIDTH - THRESHOLD_EDGE;
+
+ public class TThreshold
+ {
+ public int th_h;
+ public int th_l;
+ public int th;
+ public int lt_x;
+ public int lt_y;
+ public int rb_x;
+ public int rb_y;
+ }
+
+ class THighAndLow
+ {
+ public int h;
+ public int l;
+ }
+ /**
+ * 繝斐け繧サ繝ォ驟榊・縺ョ荳贋ス阪€∽ク倶ス阪・4繝斐け繧サ繝ォ縺ョ繝斐け繧サ繝ォ蛟、蟷ウ蝮・r豎ゅa縺セ縺吶€・
+ * 縺薙・髢「謨ー縺ッ縲・4/i_pixcel.length)縺ョ鬆伜沺繧貞頃譛峨☆繧輝tail豕輔〒蜿梧婿蜷代・髢セ蛟、繧呈アゅa繧九%縺ィ縺ォ縺ェ繧翫∪縺吶€・
+ * @param i_pixcel
+ * @param i_initial
+ * @param i_out
+ */
+ private void getPtailHighAndLow(int[] i_pixcel, THighAndLow i_out)
+ {
+ int h3, h2, h1, h0, l3, l2, l1, l0;
+ h3 = h2 = h1 = h0 = l3 = l2 = l1 = l0 = i_pixcel[0];
+
+ for (int i = i_pixcel.Length - 1; i >= 1; i--)
+ {
+ int pix = i_pixcel[i];
+ if (h0 < pix)
+ {
+ if (h1 < pix)
+ {
+ if (h2 < pix)
+ {
+ if (h3 < pix)
+ {
+ h0 = h1;
+ h1 = h2;
+ h2 = h3;
+ h3 = pix;
+ }
+ else
+ {
+ h0 = h1;
+ h1 = h2;
+ h2 = pix;
+ }
+ }
+ else
+ {
+ h0 = h1;
+ h1 = pix;
+ }
+ }
+ else
+ {
+ h0 = pix;
+ }
+ }
+ if (l0 > pix)
+ {
+ if (l1 > pix)
+ {
+ if (l2 > pix)
+ {
+ if (l3 > pix)
+ {
+ l0 = l1;
+ l1 = l2;
+ l2 = l3;
+ l3 = pix;
+ }
+ else
+ {
+ l0 = l1;
+ l1 = l2;
+ l2 = pix;
+ }
+ }
+ else
+ {
+ l0 = l1;
+ l1 = pix;
+ }
+ }
+ else
+ {
+ l0 = pix;
+ }
+ }
+ }
+ i_out.l = (l0 + l1 + l2 + l3) / 4;
+ i_out.h = (h0 + h1 + h2 + h3) / 4;
+ return;
+ }
+ private THighAndLow __detectThresholdValue_hl = new THighAndLow();
+ private NyARIntPoint2d __detectThresholdValue_tpt = new NyARIntPoint2d();
+ private int[] _th_pixels = new int[THRESHOLD_SAMPLE * 4];
+ /**
+ * 謖・ョ壹@縺溷エ謇€縺ョ繝斐け繧サ繝ォ蛟、繧定ェソ譟サ縺励※縲・明蛟、繧定ィ育ョ励@縺ヲ霑斐@縺セ縺吶€・
+ * @param i_reader
+ * @param i_x
+ * @param i_y
+ * @return
+ * @throws NyARException
+ */
+ public void detectThresholdValue(INyARRgbPixelReader i_reader, int i_x, int i_y, TThreshold o_threshold)
+ {
+ int[] th_pixels=this._th_pixels;
+
+ //蟾ヲ荳翫・繝斐ャ繧ッ繧「繝・・鬆伜沺縺九i繝斐け繧サ繝ォ繧貞セ励k(00-24)
+ rectPixels(THRESHOLD_SAMPLE_LT,THRESHOLD_SAMPLE_LT,THRESHOLD_STEP,THRESHOLD_STEP,THRESHOLD_PIXEL,THRESHOLD_PIXEL,0,th_pixels);
+
+ //蟾ヲ荳九・繝斐ャ繧ッ繧「繝・・鬆伜沺縺九i繝斐け繧サ繝ォ繧貞セ励k(25-49)
+ rectPixels(THRESHOLD_SAMPLE_LT,THRESHOLD_SAMPLE_RB,THRESHOLD_STEP,THRESHOLD_STEP,THRESHOLD_PIXEL,THRESHOLD_PIXEL,THRESHOLD_SAMPLE,th_pixels);
+
+ //蜿ウ荳翫・繝斐ャ繧ッ繧「繝・・鬆伜沺縺九i繝斐け繧サ繝ォ繧貞セ励k(50-74)
+ rectPixels(THRESHOLD_SAMPLE_RB,THRESHOLD_SAMPLE_LT,THRESHOLD_STEP,THRESHOLD_STEP,THRESHOLD_PIXEL,THRESHOLD_PIXEL,THRESHOLD_SAMPLE*2,th_pixels);
+
+ //蜿ウ荳九・繝斐ャ繧ッ繧「繝・・鬆伜沺縺九i繝斐け繧サ繝ォ繧貞セ励k(75-99)
+ rectPixels(THRESHOLD_SAMPLE_RB,THRESHOLD_SAMPLE_RB,THRESHOLD_STEP,THRESHOLD_STEP,THRESHOLD_PIXEL,THRESHOLD_PIXEL,THRESHOLD_SAMPLE*3,th_pixels);
+
+ THighAndLow hl=this.__detectThresholdValue_hl;
+ //Ptail縺ァ豎ゅa縺溘ヴ繧ッ繧サ繝ォ蟷ウ蝮・
+ getPtailHighAndLow(th_pixels,hl);
+
+
+
+ //髢セ蛟、荳ュ蠢・
+ int th=(hl.h+hl.l)/2;
+ //繝偵せ繝・Μ繧キ繧ケ(蟾ョ蛻・・20%)
+ int th_sub=(hl.h-hl.l)/5;
+
+ o_threshold.th=th;
+ o_threshold.th_h=th+th_sub;//繝偵せ繝・Μ繧キ繧ケ莉倥″髢セ蛟、
+ o_threshold.th_l=th-th_sub;//繝偵せ繝・Μ繧キ繧ケ莉倥″髢セ蛟、
+
+ //繧ィ繝・ず繧定ィ育ョ・譏守せ驥榊ソ・
+ int lt_x,lt_y,lb_x,lb_y,rt_x,rt_y,rb_x,rb_y;
+ NyARIntPoint2d tpt=this.__detectThresholdValue_tpt;
+ //LT
+ if(getHighPixelCenter(0,th_pixels,THRESHOLD_PIXEL,THRESHOLD_PIXEL,th,tpt)){
+ lt_x=tpt.x*THRESHOLD_STEP;
+ lt_y=tpt.y*THRESHOLD_STEP;
+ }else{
+ lt_x=11;
+ lt_y=11;
+ }
+ //LB
+ if(getHighPixelCenter(THRESHOLD_SAMPLE*1,th_pixels,THRESHOLD_PIXEL,THRESHOLD_PIXEL,th,tpt)){
+ lb_x=tpt.x*THRESHOLD_STEP;
+ lb_y=tpt.y*THRESHOLD_STEP;
+ }else{
+ lb_x=11;
+ lb_y=-1;
+ }
+ //RT
+ if(getHighPixelCenter(THRESHOLD_SAMPLE*2,th_pixels,THRESHOLD_PIXEL,THRESHOLD_PIXEL,th,tpt)){
+ rt_x=tpt.x*THRESHOLD_STEP;
+ rt_y=tpt.y*THRESHOLD_STEP;
+ }else{
+ rt_x=-1;
+ rt_y=11;
+ }
+ //RB
+ if(getHighPixelCenter(THRESHOLD_SAMPLE*3,th_pixels,THRESHOLD_PIXEL,THRESHOLD_PIXEL,th,tpt)){
+ rb_x=tpt.x*THRESHOLD_STEP;
+ rb_y=tpt.y*THRESHOLD_STEP;
+ }else{
+ rb_x=-1;
+ rb_y=-1;
+ }
+ //繝医Λ繝・く繝ウ繧ー髢句ァ倶ス咲スョ縺ョ豎コ螳・
+ o_threshold.lt_x=(lt_x+lb_x)/2+THRESHOLD_SAMPLE_LT-1;
+ o_threshold.rb_x=(rt_x+rb_x)/2+THRESHOLD_SAMPLE_RB+1;
+ o_threshold.lt_y=(lt_y+rt_y)/2+THRESHOLD_SAMPLE_LT-1;
+ o_threshold.rb_y=(lb_y+rb_y)/2+THRESHOLD_SAMPLE_RB+1;
+ return;
+ }
+
+ private bool getHighPixelCenter(int i_st, int[] i_pixels, int i_width, int i_height, int i_th, NyARIntPoint2d o_point)
+ {
+ int rp = i_st;
+ int pos_x = 0;
+ int pos_y = 0;
+ int number_of_pos = 0;
+ for (int i = 0; i < i_height; i++)
+ {
+ for (int i2 = 0; i2 < i_width; i2++)
+ {
+ if (i_pixels[rp++] > i_th)
+ {
+ pos_x += i2;
+ pos_y += i;
+ number_of_pos++;
+ }
+ }
+ }
+ if (number_of_pos > 0)
+ {
+ pos_x /= number_of_pos;
+ pos_y /= number_of_pos;
+ }
+ else
+ {
+ return false;
+ }
+ o_point.x = pos_x;
+ o_point.y = pos_y;
+ return true;
+ }
+ private int[] __detectDataBitsIndex_freq_index1 = new int[FRQ_POINTS];
+ private int[] __detectDataBitsIndex_freq_index2 = new int[FRQ_POINTS];
+ private int detectDataBitsIndex(PerspectivePixelReader.TThreshold i_th, double[] o_index_row, double[] o_index_col)
+ {
+ //蜻ィ豕「謨ー繧呈クャ螳・
+ int[] freq_index1=this.__detectDataBitsIndex_freq_index1;
+ int[] freq_index2=this.__detectDataBitsIndex_freq_index2;
+
+
+ int frq_t=getRowFrequency(i_th.lt_y,i_th.th_h,i_th.th_l,freq_index1);
+ int frq_b=getRowFrequency(i_th.rb_y,i_th.th_h,i_th.th_l,freq_index2);
+ //蜻ィ豕「謨ー縺ッ縺セ縺ィ繧ゑシ・
+ if((frq_t<0 && frq_b<0) || frq_t==frq_b){
+ return -1;
+ }
+ //繧ソ繧、繝溘Φ繧ー繝代ち繝シ繝ウ縺九i繧、繝ウ繝・け繧ケ繧剃ス懈・
+ int freq_h,freq_v;
+ int[] index;
+ if(frq_t>frq_b){
+ freq_h=frq_t;
+ index=freq_index1;
+ }else{
+ freq_h=frq_b;
+ index=freq_index2;
+ }
+ for(int i=0;i<freq_h+freq_h-1;i++){
+ o_index_row[i*2]=((index[i+1]-index[i])*2/5+index[i])+FRQ_EDGE;
+ o_index_row[i*2+1]=((index[i+1]-index[i])*3/5+index[i])+FRQ_EDGE;
+ }
+
+
+ int frq_l=getColFrequency(i_th.lt_x,i_th.th_h,i_th.th_l,freq_index1);
+ int frq_r=getColFrequency(i_th.rb_x,i_th.th_h,i_th.th_l,freq_index2);
+ //蜻ィ豕「謨ー縺ッ縺セ縺ィ繧ゑシ・
+ if((frq_l<0 && frq_r<0) || frq_l==frq_r){
+ return -1;
+ }
+ //繧ソ繧、繝溘Φ繧ー繝代ち繝シ繝ウ縺九i繧、繝ウ繝・け繧ケ繧剃ス懈・
+ if(frq_l>frq_r){
+ freq_v=frq_l;
+ index=freq_index1;
+ }else{
+ freq_v=frq_r;
+ index=freq_index2;
+ }
+ //蜷後§蜻ィ譛滂シ・
+ if(freq_v!=freq_h){
+ return -1;
+ }
+
+ for(int i=0;i<freq_v+freq_v-1;i++){
+ int w=index[i];
+ int w2=index[i+1]-w;
+ o_index_col[i*2]=((w2)*2/5+w)+FRQ_EDGE;
+ o_index_col[i*2+1]=((w2)*3/5+w)+FRQ_EDGE;
+ }
+ //Lv4莉・荳翫・辟。逅・
+ if(freq_v>MAX_FREQ){
+ return -1;
+ }
+ return freq_v;
+
+ }
+ private double[] __readDataBits_index_bit_x = new double[MAX_DATA_BITS * 2];
+ private double[] __readDataBits_index_bit_y = new double[MAX_DATA_BITS * 2];
+
+ public bool readDataBits(PerspectivePixelReader.TThreshold i_th, MarkerPattEncoder o_bitbuffer)
+ {
+ double[] index_x = this.__readDataBits_index_bit_x;
+ double[] index_y = this.__readDataBits_index_bit_y;
+ //隱ュ縺ソ蜃コ縺嶺ス咲スョ繧貞叙蠕・
+ int size = detectDataBitsIndex(i_th, index_x, index_y);
+ int resolution = size + size - 1;
+ if (size < 0)
+ {
+ return false;
+ }
+ if (!o_bitbuffer.initEncoder(size - 1))
+ {
+ return false;
+ }
+
+ double[] cpara = this._cparam;
+ int[] ref_x = this._ref_x;
+ int[] ref_y = this._ref_y;
+ INyARRgbPixelReader reader = this._raster.getRgbPixelReader();
+ int[] pixcel_temp = this._pixcel_temp;
+
+ double cpara_0 = cpara[0];
+ double cpara_1 = cpara[1];
+ double cpara_3 = cpara[3];
+ double cpara_6 = cpara[6];
+
+
+ int th = i_th.th;
+ int p = 0;
+ for (int i = 0; i < resolution; i++)
+ {
+ //1蛻怜・縺ョ繝斐け繧サ繝ォ縺ョ繧、繝ウ繝・ャ繧ッ繧ケ蛟、繧定ィ育ョ励☆繧九€・
+ double cy0 = 1 + index_y[i * 2 + 0];
+ double cy1 = 1 + index_y[i * 2 + 1];
+ double cpy0_12 = cpara_1 * cy0 + cpara[2];
+ double cpy0_45 = cpara[4] * cy0 + cpara[5];
+ double cpy0_7 = cpara[7] * cy0 + 1.0;
+ double cpy1_12 = cpara_1 * cy1 + cpara[2];
+ double cpy1_45 = cpara[4] * cy1 + cpara[5];
+ double cpy1_7 = cpara[7] * cy1 + 1.0;
+
+ int pt = 0;
+ for (int i2 = 0; i2 < resolution; i2++)
+ {
+
+ double d;
+ double cx0 = 1 + index_x[i2 * 2 + 0];
+ double cx1 = 1 + index_x[i2 * 2 + 1];
+
+ double cp6_0 = cpara_6 * cx0;
+ double cpx0_0 = cpara_0 * cx0;
+ double cpx3_0 = cpara_3 * cx0;
+
+ double cp6_1 = cpara_6 * cx1;
+ double cpx0_1 = cpara_0 * cx1;
+ double cpx3_1 = cpara_3 * cx1;
+
+ d = cp6_0 + cpy0_7;
+ ref_x[pt] = (int)((cpx0_0 + cpy0_12) / d);
+ ref_y[pt] = (int)((cpx3_0 + cpy0_45) / d);
+ pt++;
+
+ d = cp6_0 + cpy1_7;
+ ref_x[pt] = (int)((cpx0_0 + cpy1_12) / d);
+ ref_y[pt] = (int)((cpx3_0 + cpy1_45) / d);
+ pt++;
+
+ d = cp6_1 + cpy0_7;
+ ref_x[pt] = (int)((cpx0_1 + cpy0_12) / d);
+ ref_y[pt] = (int)((cpx3_1 + cpy0_45) / d);
+ pt++;
+
+ d = cp6_1 + cpy1_7;
+ ref_x[pt] = (int)((cpx0_1 + cpy1_12) / d);
+ ref_y[pt] = (int)((cpx3_1 + cpy1_45) / d);
+ pt++;
+ }
+ //1陦悟・縺ョ繝斐け繧サ繝ォ繧貞叙蠕・蝣エ蜷医↓繧医▲縺ヲ縺ッ蟆ら畑繧「繧ッ繧サ繧オ繧呈嶌縺・◆譁ケ縺後>縺・
+ reader.getPixelSet(ref_x, ref_y, resolution * 4, pixcel_temp);
+ //繧ー繝ャ繝シ繧ケ繧ア繝シ繝ォ縺ォ縺励↑縺後i縲〕ine竊知ap縺ク縺ョ霆「蜀・
+ for (int i2 = 0; i2 < resolution; i2++)
+ {
+ int index = i2 * 3 * 4;
+ int pixel = (pixcel_temp[index + 0] + pixcel_temp[index + 1] + pixcel_temp[index + 2] +
+ pixcel_temp[index + 3] + pixcel_temp[index + 4] + pixcel_temp[index + 5] +
+ pixcel_temp[index + 6] + pixcel_temp[index + 7] + pixcel_temp[index + 8] +
+ pixcel_temp[index + 9] + pixcel_temp[index + 10] + pixcel_temp[index + 11]) / (4 * 3);
+ //證礼せ繧・縲∵・轤ケ繧・縺ァ陦ィ迴セ縺励∪縺吶€・
+ o_bitbuffer.setBitByBitIndex(p, pixel > th ? 0 : 1);
+ p++;
+ }
+ }
+ /*
+ for(int i=0;i<225*4;i++){
+ this.vertex_x[i]=0;
+ this.vertex_y[i]=0;
+ }
+ for(int i=0;i<(resolution)*2;i++){
+ for(int i2=0;i2<(resolution)*2;i2++){
+ this.vertex_x[i*(resolution)*2+i2]=(int)index_x[i2];
+ this.vertex_y[i*(resolution)*2+i2]=(int)index_y[i];
+
+ }
+ }
+ */
+ return true;
+ }
+ public bool setSquare(NyARIntPoint2d[] i_vertex)
+ {
+ if (!this._param_gen.getParam(i_vertex, this._cparam))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ }
+ class MarkerPattDecoder
+ {
+ public void decode(int model, int domain, int mask)
+ {
+
+ }
+ }
+ /**
+ * 繝槭・繧ォ繝代ち繝シ繝ウ縺ョ繧ィ繝ウ繧ウ繝シ繝€縺ァ縺吶€・
+ *
+ */
+ class MarkerPattEncoder
+ {
+ private static int[] _bit_table_3 ={
+ 25, 26, 27, 28, 29, 30, 31,
+ 48, 9, 10, 11, 12, 13, 32,
+ 47, 24, 1, 2, 3, 14, 33,
+ 46, 23, 8, 0, 4, 15, 34,
+ 45, 22, 7, 6, 5, 16, 35,
+ 44, 21, 20, 19, 18, 17, 36,
+ 43, 42, 41, 40, 39, 38, 37
+ };
+ private static int[] _bit_table_2 ={
+ 9, 10, 11, 12, 13,
+ 24, 1, 2, 3, 14,
+ 23, 8, 0, 4, 15,
+ 22, 7, 6, 5, 16,
+ 21, 20, 19, 18, 17};
+ private static int[][] _bit_tables ={
+ _bit_table_2,_bit_table_3,null,null,null,null,null,
+ };
+ /**
+ * RECT(0):[0]=(0)
+ * RECT(1):[1]=(1-8)
+ * RECT(2):[2]=(9-16),[3]=(17-24)
+ * RECT(3):[4]=(25-32),[5]=(33-40),[6]=(41-48)
+ */
+ int[] _bit_table;
+ int[] _bits = new int[16];
+ int[] _work = new int[16];
+ int _model;
+ public void setBitByBitIndex(int i_index_no, int i_value)
+ {
+ Debug.Assert(i_value == 0 || i_value == 1);
+ int bit_no = this._bit_table[i_index_no];
+ if (bit_no == 0)
+ {
+ this._bits[0] = i_value;
+ }
+ else
+ {
+ int bidx = (bit_no - 1) / 8 + 1;
+ int sidx = (bit_no - 1) % 8;
+ this._bits[bidx] = (this._bits[bidx] & (~(0x01 << sidx))) | (i_value << sidx);
+ }
+ return;
+ }
+
+ public void setBit(int i_bit_no, int i_value)
+ {
+ Debug.Assert(i_value == 0 || i_value == 1);
+ if (i_bit_no == 0)
+ {
+ this._bits[0] = i_value;
+ }
+ else
+ {
+ int bidx = (i_bit_no - 1) / 8 + 1;
+ int sidx = (i_bit_no - 1) % 8;
+ this._bits[bidx] = (this._bits[bidx] & (~(0x01 << sidx))) | (i_value << sidx);
+ }
+ return;
+ }
+ public int getBit(int i_bit_no)
+ {
+ if (i_bit_no == 0)
+ {
+ return this._bits[0];
+ }
+ else
+ {
+ int bidx = (i_bit_no - 1) / 8 + 1;
+ int sidx = (i_bit_no - 1) % 8;
+ return (this._bits[bidx] >> (sidx)) & (0x01);
+ }
+ }
+ public int getModel()
+ {
+ return this._model;
+ }
+ private static int getControlValue(int i_model, int[] i_data)
+ {
+ int v;
+ switch (i_model)
+ {
+ case 2:
+ v = (i_data[2] & 0x0e) >> 1;
+ return v >= 5 ? v - 1 : v;
+ case 3:
+ v = (i_data[4] & 0x3e) >> 1;
+ return v >= 21 ? v - 1 : v;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ default:
+ break;
+ }
+ return -1;
+ }
+ public static int getCheckValue(int i_model, int[] i_data)
+ {
+ int v;
+ switch (i_model)
+ {
+ case 2:
+ v = (i_data[2] & 0xe0) >> 5;
+ return v > 5 ? v - 1 : v;
+ case 3:
+ v = ((i_data[4] & 0x80) >> 7) | ((i_data[5] & 0x0f) << 1);
+ return v > 21 ? v - 1 : v;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ default:
+ break;
+ }
+ return -1;
+ }
+ public bool initEncoder(int i_model)
+ {
+ if (i_model > 3 || i_model < 2)
+ {
+ //Lv4莉・髯阪↓蟇セ蠢懊☆繧区凾縺ッ縲√%縺ョ蛻カ髯舌r螟峨∴繧九€・
+ return false;
+ }
+ this._bit_table = _bit_tables[i_model - 2];
+ this._model = i_model;
+ return true;
+ }
+ private int getDirection()
+ {
+ int l, t, r, b;
+ int timing_pat;
+ switch (this._model)
+ {
+ case 2:
+ //繝医Λ繝・く繝ウ繧ー繧サ繝ォ繧貞セ励k
+ t = this._bits[2] & 0x1f;
+ r = ((this._bits[2] & 0xf0) >> 4) | ((this._bits[3] & 0x01) << 4);
+ b = this._bits[3] & 0x1f;
+ l = ((this._bits[3] & 0xf0) >> 4) | ((this._bits[2] & 0x01) << 4);
+ timing_pat = 0x0a;
+ break;
+ case 3:
+ t = this._bits[4] & 0x7f;
+ r = ((this._bits[4] & 0xc0) >> 6) | ((this._bits[5] & 0x1f) << 2);
+ b = ((this._bits[5] & 0xf0) >> 4) | ((this._bits[6] & 0x07) << 4);
+ l = ((this._bits[6] & 0xfc) >> 2) | ((this._bits[4] & 0x01) << 6);
+ timing_pat = 0x2a;
+ break;
+ default:
+ return -3;
+ }
+ //繧ソ繧、繝溘Φ繧ー繝代ち繝シ繝ウ縺ョ豈碑シ・
+ if (t == timing_pat)
+ {
+ if (r == timing_pat)
+ {
+ return (b != timing_pat && l != timing_pat) ? 2 : -2;
+ }
+ else if (l == timing_pat)
+ {
+ return (b != timing_pat && r != timing_pat) ? 3 : -2;
+ }
+ }
+ else if (b == timing_pat)
+ {
+ if (r == timing_pat)
+ {
+ return (t != timing_pat && l != timing_pat) ? 1 : -2;
+ }
+ else if (l == timing_pat)
+ {
+ return (t != timing_pat && r != timing_pat) ? 0 : -2;
+ }
+ }
+ return -1;
+ }
+ /**
+ * 譬シ邏阪@縺ヲ縺・k繝槭・繧ォ繝代ち繝シ繝ウ繧偵お繝ウ繧ウ繝シ繝峨@縺ヲ縲√・繝シ繧ォ繝・・繧ソ繧定ソ斐@縺セ縺吶€・
+ * @param o_out
+ * @return
+ * 謌仙粥縺吶l縺ー繝槭・繧ォ縺ョ譁ケ菴阪r霑泌唆縺励∪縺吶€ょ、ア謨励☆繧九→-1繧定ソ斐@縺セ縺吶€・
+ */
+
+ public int encode(NyIdMarkerPattern o_out)
+ {
+ int d = getDirection();
+ if (d < 0)
+ {
+ return -1;
+ }
+ //蝗櫁サ「繝薙ャ繝医・蜿門セ・
+ getRotatedBits(d, o_out.data);
+ int model = this._model;
+ //蜻ィ霎コ繝薙ャ繝医・蜿門セ・
+ o_out.model = model;
+ int control_bits = getControlValue(model, o_out.data);
+ o_out.check = getCheckValue(model, o_out.data);
+ o_out.ctrl_mask = control_bits % 5;
+ o_out.ctrl_domain = control_bits / 5;
+ if (o_out.ctrl_domain != 0 || o_out.ctrl_mask != 0)
+ {
+ return -1;
+ }
+ //繝槭せ繧ッ隗」髯、蜃ヲ逅・r螳溯」・☆繧九%縺ィ
+ return d;
+ }
+ private void getRotatedBits(int i_direction, int[] o_out)
+ {
+ int sl = i_direction * 2;
+ int sr = 8 - sl;
+
+ int w1;
+ o_out[0] = this._bits[0];
+ //RECT1
+ w1 = this._bits[1];
+ o_out[1] = ((w1 << sl) | (w1 >> sr)) & 0xff;
+
+ //RECT2
+ sl = i_direction * 4;
+ sr = 16 - sl;
+ w1 = this._bits[2] | (this._bits[3] << 8);
+ w1 = (w1 << sl) | (w1 >> sr);
+ o_out[2] = w1 & 0xff;
+ o_out[3] = (w1 >> 8) & 0xff;
+
+ if (this._model < 2)
+ {
+ return;
+ }
+
+ //RECT3
+ sl = i_direction * 6;
+ sr = 24 - sl;
+ w1 = this._bits[4] | (this._bits[5] << 8) | (this._bits[6] << 16);
+ w1 = (w1 << sl) | (w1 >> sr);
+ o_out[4] = w1 & 0xff;
+ o_out[5] = (w1 >> 8) & 0xff;
+ o_out[6] = (w1 >> 16) & 0xff;
+
+ if (this._model < 3)
+ {
+ return;
+ }
+ //RECT4(Lv4莉・髯阪・縺薙%縺ョ蛻カ髯舌r螟峨∴繧・
+ // shiftLeft(this._bits,7,3,i_direction*8);
+ // if(this._model<4){
+ // return;
+ // }
+ return;
+ }
+ public void shiftLeft(int[] i_pack, int i_start, int i_length, int i_ls)
+ {
+ int[] work = this._work;
+ //遶ッ謨ー繧キ繝輔ヨ
+ int mod_shift = i_ls % 8;
+ for (int i = i_length - 1; i >= 1; i--)
+ {
+ work[i] = (i_pack[i + i_start] << mod_shift) | (0xff & (i_pack[i + i_start - 1] >> (8 - mod_shift)));
+ }
+ work[0] = (i_pack[i_start] << mod_shift) | (0xff & (i_pack[i_start + i_length - 1] >> (8 - mod_shift)));
+ //繝舌う繝医す繝輔ヨ
+ int byte_shift = (i_ls / 8) % i_length;
+ for (int i = i_length - 1; i >= 0; i--)
+ {
+ i_pack[(byte_shift + i) % i_length + i_start] = 0xff & work[i];
+ }
+ return;
+ }
+ }
+ /**
+ * 繝ゥ繧ケ繧ソ逕サ蜒上・莉サ諢冗洸蠖「縺九i縲¨yARIdMarkerData繧呈歓蜃コ縺励∪縺吶€・
+ *
+ */
+ public class NyIdMarkerPickup
+ {
+ private PerspectivePixelReader _perspective_reader;
+ private PerspectivePixelReader.TThreshold __pickFromRaster_th = new PerspectivePixelReader.TThreshold();
+ private MarkerPattEncoder __pickFromRaster_encoder = new MarkerPattEncoder();
+
+
+ public NyIdMarkerPickup()
+ {
+ this._perspective_reader = new PerspectivePixelReader();
+ return;
+ }
+ /**
+ * i_image縺九i縲(d繝槭・繧ォ繧定ェュ縺ソ縺縺励∪縺吶€・
+ * o_data縺ォ縺ッ繝槭・繧ォ繝・・繧ソ縲{_param縺ォ縺ッ縺セ繝シ縺九・繝代Λ繝。繝シ繧ソ繧定ソ泌唆縺励∪縺吶€・
+ * @param image
+ * @param i_square
+ * @param o_data
+ * @param o_param
+ * @return
+ * @throws NyARException
+ */
+ public bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
+ {
+ this._perspective_reader.setSourceRaster(image);
+
+ //驕霑第ウ輔・繝代Λ繝。繝シ繧ソ繧定ィ育ョ・
+ if (!this._perspective_reader.setSourceSquare(i_square.imvertex))
+ {
+ return false;
+ };
+
+ INyARRgbPixelReader reader = image.getRgbPixelReader();
+
+
+ PerspectivePixelReader.TThreshold th = this.__pickFromRaster_th;
+ MarkerPattEncoder encoder = this.__pickFromRaster_encoder;
+ //繝槭・繧ォ繝代Λ繝。繝シ繧ソ繧貞叙蠕・
+ this._perspective_reader.detectThresholdValue(reader, 10, 10, th);
+
+ if (!this._perspective_reader.readDataBits(th, encoder))
+ {
+ return false;
+ }
+ int d = encoder.encode(o_data);
+ if (d < 0)
+ {
+ return false;
+ }
+ o_param.direction = d;
+ o_param.threshold = th.th;
+
+ return true;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPattern.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPattern.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPattern.cs (revision 252)
@@ -0,0 +1,21 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ /**
+ * [[Strage class]]
+ * ID繝槭・繧ォ繝代ち繝シ繝ウ蛟、繧呈シ邏阪☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ * 繧ッ繝ゥ繧ケ縺ッ縲∵悴謨エ蠖「縺ョ繝槭・繧ォ繝・・繧ソ繧呈シ邏阪@縺ヲ縺・∪縺吶€・
+ *
+ */
+ public class NyIdMarkerPattern
+ {
+ public int model;
+ public int ctrl_domain;
+ public int ctrl_mask;
+ public int check;
+ public int[] data = new int[32];
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.cs (revision 252)
@@ -0,0 +1,42 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ public class NyIdMarkerDataEncoder_RawBit : INyIdMarkerDataEncoder
+ {
+ private const int _DOMAIN_ID = 0;
+ private int[] _mod_data = { 7, 31, 127, 511, 2047, 4095 };
+ public bool encode(NyIdMarkerPattern i_data, INyIdMarkerData o_dest)
+ {
+ NyIdMarkerData_RawBit dest = (NyIdMarkerData_RawBit)o_dest;
+ if (i_data.ctrl_domain != _DOMAIN_ID)
+ {
+ return false;
+ }
+ //繝代こ繝・ヨ謨ー險育ョ・
+ int resolution_len = (i_data.model + 1);
+ int packet_length = (resolution_len * resolution_len) / 8 + 1;
+ int sum = 0;
+ for (int i = 0; i < packet_length; i++)
+ {
+ dest.packet[i] = i_data.data[i];
+ sum += i_data.data[i];
+ }
+ //繝√ぉ繝・け繝峨ャ繝亥€、險育ョ・
+ sum = sum % _mod_data[i_data.model - 2];
+ //繝√ぉ繝・け繝峨ャ繝域ッ碑シ・
+ if (i_data.check != sum)
+ {
+ return false;
+ }
+ dest.length = packet_length;
+ return true;
+ }
+ public INyIdMarkerData createDataInstance()
+ {
+ return new NyIdMarkerData_RawBit();
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerData_RawBit.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerData_RawBit.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerData_RawBit.cs (revision 252)
@@ -0,0 +1,39 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ /**
+ * [[Strage class]]
+ *
+ */
+ public class NyIdMarkerData_RawBit : INyIdMarkerData
+ {
+ public int[] packet = new int[22];
+ public int length;
+ public bool isEqual(INyIdMarkerData i_target)
+ {
+ NyIdMarkerData_RawBit s = (NyIdMarkerData_RawBit)i_target;
+ if (s.length != this.length)
+ {
+ return false;
+ }
+ for (int i = s.length - 1; i >= 0; i--)
+ {
+ if (s.packet[i] != s.packet[i])
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ public void copyFrom(INyIdMarkerData i_source)
+ {
+ NyIdMarkerData_RawBit s = (NyIdMarkerData_RawBit)i_source;
+ System.Array.Copy(s.packet, 0, this.packet, 0, s.length);
+ this.length = s.length;
+ return;
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerData.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerData.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerData.cs (revision 252)
@@ -0,0 +1,23 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ public interface INyIdMarkerData
+ {
+ /**
+ * i_target縺ョ繝槭・繧ォ繝・・繧ソ縺ィ閾ェ霄ォ縺ョ繝・・繧ソ縺檎ュ峨@縺・°繧定ソ斐@縺セ縺吶€・
+ * @param i_target
+ * 豈碑シ・☆繧九・繝シ繧ォ繧ェ繝悶ず繧ァ繧ッ繝・
+ * @return
+ * 遲峨@縺・°縺ョ逵溷⊃蛟、
+ */
+ bool isEqual(INyIdMarkerData i_target);
+ /**
+ * i_source縺九i繝槭・繧ォ繝・・繧ソ繧偵さ繝斐・縺励∪縺吶€・
+ * @param i_source
+ */
+ void copyFrom(INyIdMarkerData i_source);
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerDataEncoder.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerDataEncoder.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerDataEncoder.cs (revision 252)
@@ -0,0 +1,12 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ public interface INyIdMarkerDataEncoder
+ {
+ bool encode(NyIdMarkerPattern i_data, INyIdMarkerData o_dest);
+ INyIdMarkerData createDataInstance();
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerParam.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerParam.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerParam.cs (revision 252)
@@ -0,0 +1,24 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.nyidmarker
+{
+ /**
+ * [[Strage class]]
+ * 繝槭・繧ォ繧呈歓蜃コ縺励◆譎ゅ・繝代Λ繝。繝シ繧ソ繧呈シ邏阪☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ *
+ */
+ public class NyIdMarkerParam
+ {
+ /**
+ * 繝槭・繧ォ縺ョ譁ケ菴榊€、縺ァ縺吶€・
+ */
+ public int direction;
+ /**
+ * 繝槭・繧ォ蜻ィ霎コ縺ョ繝代ち繝シ繝ウ髢セ蛟、縺ァ縺吶€・
+ */
+ public int threshold;
+
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/core/NyARMat.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/NyARMat.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/NyARMat.cs (revision 252)
@@ -31,6 +31,7 @@
*/

using System;
+using System.Diagnostics;
using jp.nyatla.nyartoolkit.cs.utils;
namespace jp.nyatla.nyartoolkit.cs.core
{
@@ -44,9 +45,11 @@
* 驟榊・繧オ繧、繧コ縺ィ陦悟・繧オ繧、繧コ縺ッ蠢・★縺励b荳€閾エ縺励↑縺・%縺ィ縺ォ豕ィ諢・霑斐&繧後◆驟榊・縺ョ繧オ繧、繧コ繧定。悟・縺ョ螟ァ縺阪&縺ィ縺励※菴ソ繧上↑縺・%縺ィ・・
*
*/
- protected double[][] m;
+ protected double[][] _m;
+ private int[] __matrixSelfInv_nos;

- protected int clm, row;
+ protected int clm;
+ protected int row;

/**
* 繝・ヵ繧ゥ繝ォ繝医さ繝ウ繧ケ繝医Λ繧ッ繧ソ縺ッ讖溯・縺励∪縺帙s縲・
@@ -60,143 +63,96 @@

public NyARMat(int i_row, int i_clm)
{
- m = ArrayUtils.newDouble2dArray(i_row, i_clm);
- clm = i_clm;
- row = i_row;
- }
-
- /**
- * i_row x i_clm繧オ繧、繧コ縺ョ陦悟・繧呈シ邏阪〒縺阪k繧医≧縺ォ陦悟・繧オ繧、繧コ繧貞、画峩縺励∪縺吶€・螳溯。悟セ後€∬。悟・縺ョ蜷・€、縺ッ荳榊ョ壹↓縺ェ繧翫∪縺吶€・
- *
- * @param i_row
- * @param i_clm
- */
- public void realloc(int i_row, int i_clm)
- {
- if (i_row <= this.m.Length && i_clm <= this.m[0].Length)
- {
- // 蜊∝・縺ェ驟榊・縺後≠繧後・菴輔b縺励↑縺・€・
- }
- else
- {
- // 荳榊香蛻・↑繧牙叙繧顔峩縺吶€・
- m = ArrayUtils.newDouble2dArray(i_row, i_clm);
- }
+ this._m = ArrayUtils.newDouble2dArray(i_row, i_clm);//new double[i_row][i_clm];
this.clm = i_clm;
this.row = i_row;
+ this.__matrixSelfInv_nos = new int[i_row];
+ return;
}

+ /**
+ * 陦悟・縺ョ蛻玲焚繧定ソ斐@縺セ縺吶€・
+ * @return
+ */
public int getClm()
{
return clm;
}
-
+ /**
+ * 陦悟・縺ョ陦梧焚繧定ソ斐@縺セ縺吶€・
+ * @return
+ */
public int getRow()
{
return row;
}

/**
- * 陦悟・繧偵ぞ繝ュ繧ッ繝ェ繧「縺吶k縲・
+ * 陦悟・縺ョ繧オ繧、繧コ繧貞、画峩縺励∪縺吶€・
+ * 螳溯。悟セ後€∬。悟・縺ョ蜷・€、縺ッ荳榊ョ壹↓縺ェ繧翫∪縺吶€・
+ * @param i_row
+ * @param i_clm
*/
- public void zeroClear()
+ public void realloc(int i_row, int i_clm)
{
- int i, i2;
- // For鬆・、画峩OK
- for (i = row - 1; i >= 0; i--)
+ if (i_row <= this._m.Length && i_clm <= this._m[0].Length)
{
- for (i2 = clm - 1; i2 >= 0; i2--)
- {
- m[i][i2] = 0.0;
- }
+ // 蜊∝・縺ェ驟榊・縺後≠繧後・菴輔b縺励↑縺・€・
}
- }
-
- /**
- * i_copy_from縺ョ蜀・ョケ繧定・蛻・・霄ォ縺ォ繧ウ繝斐・縺励∪縺吶€・鬮倥&繝サ蟷・・蜷御ク€縺ァ辟。縺・→螟ア謨励@縺セ縺吶€・
- *
- * @param i_copy_from
- */
- public void copyFrom(NyARMat i_copy_from)
- {
- // 繧オ繧、繧コ遒コ隱・
- if (this.row != i_copy_from.row || this.clm != i_copy_from.clm)
+ else
{
- throw new NyARException();
+ // 荳榊香蛻・↑繧牙叙繧顔峩縺吶€・
+ this._m = ArrayUtils.newDouble2dArray(i_row, i_clm);
+ this.__matrixSelfInv_nos = new int[i_row];
}
- // 蛟、繧ウ繝斐・
- for (int r = this.row - 1; r >= 0; r--)
- {
- for (int c = this.clm - 1; c >= 0; c--)
- {
- this.m[r][c] = i_copy_from.m[r][c];
- }
- }
+ this.clm = i_clm;
+ this.row = i_row;
+ return;
}

- public double[][] getArray()
- {
- return m;
- }

- // public void getRowVec(int i_row,NyARVec o_vec)
- // {
- // o_vec.set(this.m[i_row],this.clm);
- // }
+
/**
- * a縺ィb縺ョ遨阪r閾ェ蛻・・霄ォ縺ォ譬シ邏阪☆繧九€BrMatrixMul()縺ョ莉」譖ソ蜩・
- *
- * @param a
- * @param b
+ * i_mat_a縺ィi_mat_b縺ョ遨阪r險育ョ励@縺ヲ縲》his縺ク譬シ邏阪@縺セ縺吶€・
+ * @param i_mat_a
+ * @param i_mat_b
* @throws NyARException
*/
- public void matrixMul(NyARMat a, NyARMat b)
+ public void matrixMul(NyARMat i_mat_a, NyARMat i_mat_b)
{
- if (a.clm != b.row || this.row != a.row || this.clm != b.clm)
- {
- throw new NyARException();
- }
+ Debug.Assert(i_mat_a.clm == i_mat_b.row && this.row == i_mat_a.row && this.clm == i_mat_b.clm);
+
double w;
int r, c, i;
- double[][] am = a.m, bm = b.m, dm = this.m;
+ double[][] am = i_mat_a._m, bm = i_mat_b._m, dm = this._m;
// For鬆・、画峩遖∵ュ「
for (r = 0; r < this.row; r++)
{
for (c = 0; c < this.clm; c++)
{
- w = 0.0;// dest.setARELEM0(r, c,0.0);
- for (i = 0; i < a.clm; i++)
+ w = 0.0;
+ for (i = 0; i < i_mat_a.clm; i++)
{
- w += am[r][i] * bm[i][c];// ARELEM0(dest, r, c) +=
- // ARELEM0(a, r, i) * ARELEM0(b,
- // i, c);
+ w += am[r][i] * bm[i][c];
}
dm[r][c] = w;
}
}
+ return;
}

- private int[] wk_nos_matrixSelfInv = new int[50];
-
- // private final static double matrixSelfInv_epsl=1.0e-10;
/**
- * i_target繧帝€・。悟・縺ォ螟画鋤縺吶k縲BrMatrixSelfInv()縺ィ縲∥rMatrixSelfInv_minv()髢「謨ー繧貞粋謌舌@縺ヲ縺ゅj縺セ縺吶€・
- * OPTIMIZE STEP[485->422]
- *
- * @param i_target
- * 騾・。悟・縺ォ縺吶k陦悟・
- * @return 騾・。悟・縺後≠繧後・TRUE/辟。縺代l縺ーFALSE
- *
+ * 騾・。悟・繧定ィ育ョ励@縺ヲ縲》his縺ク譬シ邏阪@縺セ縺吶€・
* @throws NyARException
*/
public bool matrixSelfInv()
{
- double[][] ap = this.m;
+ double[][] ap = this._m;
int dimen = this.row;
int dimen_1 = dimen - 1;
double[] ap_n, ap_ip, ap_i;// wap;
int j, ip, nwork;
- int[] nos = wk_nos_matrixSelfInv;// 縺薙・髢「謨ー縺ァ蛻晄悄蛹悶&繧後k縲・
+ int[] nos = __matrixSelfInv_nos;//繝ッ繝シ繧ッ螟画焚
// double epsl;
double p, pbuf, work;

@@ -225,9 +181,7 @@
ap_n = ap[n];// wcp = ap + n * rowa;
p = 0.0;
for (int i = n; i < dimen; i++)
- {// for(i = n, wap = wcp, p =
- // 0.0; i < dimen ; i++, wap +=
- // rowa)
+ {
if (p < (pbuf = Math.Abs(ap[i][0])))
{
p = pbuf;
@@ -256,8 +210,7 @@

work = ap_n[0];
for (j = 0; j < dimen_1; j++)
- {// for(j = 1, wap = wcp, work =
- // *wcp; j < dimen ; j++, wap++)
+ {
ap_n[j] = ap_n[j + 1] / work;// *wap = *(wap + 1) / work;
}
ap_n[j] = 1.0 / work;// *wap = 1.0 / work;
@@ -266,7 +219,6 @@
if (i != n)
{
ap_i = ap[i];// wap = ap + i * rowa;
-
work = ap_i[0];
for (j = 0; j < dimen_1; j++)
{// for(j = 1, wbp = wcp,work = *wap;j < dimen ;j++, wap++, wbp++)
@@ -288,9 +240,7 @@
}
nos[j] = nos[n];
for (int i = 0; i < dimen; i++)
- {// for(i = 0, wap = ap + j, wbp
- // = ap + n; i < dimen ;i++, wap
- // += rowa, wbp += rowa) {
+ {
ap_i = ap[i];
work = ap_i[j];// work = *wap;
ap_i[j] = ap_i[n];// *wap = *wbp;
@@ -301,6 +251,50 @@
}

/**
+ * 陦悟・繧偵ぞ繝ュ繧ッ繝ェ繧「縺吶k縲・
+ */
+ public void zeroClear()
+ {
+ int i, i2;
+ // For鬆・、画峩OK
+ for (i = row - 1; i >= 0; i--)
+ {
+ for (i2 = clm - 1; i2 >= 0; i2--)
+ {
+ _m[i][i2] = 0.0;
+ }
+ }
+ }
+
+ /**
+ * i_copy_from縺ョ蜀・ョケ繧定・蛻・・霄ォ縺ォ繧ウ繝斐・縺励∪縺吶€・鬮倥&繝サ蟷・・蜷御ク€縺ァ辟。縺・→螟ア謨励@縺セ縺吶€・
+ *
+ * @param i_copy_from
+ */
+ public void copyFrom(NyARMat i_copy_from)
+ {
+ // 繧オ繧、繧コ遒コ隱・
+ if (this.row != i_copy_from.row || this.clm != i_copy_from.clm)
+ {
+ throw new NyARException();
+ }
+ // 蛟、繧ウ繝斐・
+ for (int r = this.row - 1; r >= 0; r--)
+ {
+ for (int c = this.clm - 1; c >= 0; c--)
+ {
+ this._m[r][c] = i_copy_from._m[r][c];
+ }
+ }
+ }
+
+ public double[][] getArray()
+ {
+ return _m;
+ }
+
+
+ /**
* source縺ョ霆「鄂ョ陦悟・繧壇est縺ォ蠕励k縲BrMatrixTrans()縺ョ莉」譖ソ蜩・
*
* @param dest
@@ -319,7 +313,7 @@
{
for (int c = 0; c < dest.clm; c++)
{
- dest.m[r][c] = source.m[c][r];
+ dest._m[r][c] = source._m[c][r];
}
}
}
@@ -343,11 +337,11 @@
{
if (r == c)
{
- unit.m[r][c] = 1.0;
+ unit._m[r][c] = 1.0;
}
else
{
- unit.m[r][c] = 0.0;
+ unit._m[r][c] = 0.0;
}
}
}
@@ -366,8 +360,8 @@
// 蜀・ョケ繧定サ「蜀・
int r, c;
double[][] src_m, dest_m;
- src_m = i_source.m;
- dest_m = this.m;
+ src_m = i_source._m;
+ dest_m = this._m;
// 繧ウ繝斐・縺ッFor鬆・r螟峨∴縺ヲ繧0K
for (r = this.row - 1; r >= 0; r--)
{
@@ -384,8 +378,8 @@
// 繧ウ繝斐・
int r, c;
double[][] dest_m, src_m;
- dest_m = result.m;
- src_m = this.m;
+ dest_m = result._m;
+ src_m = this._m;
// 繧ウ繝斐・縺ッFor鬆・r螟峨∴縺ヲ繧0K
for (r = this.row - 1; r >= 0; r--)
{
@@ -397,79 +391,7 @@
return result;
}

- /**
- * arMatrixInv髢「謨ー縺ョ莉」譖ソ蜩√〒縺吶€・dest縺ォsource縺ョ騾・。悟・繧定ソ斐@縺セ縺吶€・
- *
- * @param dest
- * @param source
- * @throws NyARException
- */
- public static void matrixInv(NyARMat dest, NyARMat source)
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- dest.matrixDup(source);

- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- dest.matrixSelfInv();
- }
-
- public NyARMat matrixAllocInv()
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- NyARMat result = matrixAllocDup();
-
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- result.matrixSelfInv();
- return result;
- }
-
- /**
- * dim x dim 縺ョ蜊倅ス崎。悟・繧剃ス懊k縲・
- *
- * @param dim
- * @return
- * @throws NyARException
- */
- public static NyARMat matrixAllocUnit(int dim)
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- NyARMat result = new NyARMat(dim, dim);
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- NyARMat.matrixUnit(result);
- return result;
- }
-
- /**
- * arMatrixDisp縺ョ莉」譖ソ蜩・
- *
- * @param m
- * @return
- */
- public int matrixDisp()
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- System.Console.WriteLine(" === matrix (" + row + "," + clm + ") ===");// printf("
- // ===
- // matrix
- // (%d,%d)
- // ===\n",
- // m->row,
- // m->clm);
- for (int r = 0; r < row; r++)
- {// for(int r = 0; r < m->row; r++) {
- System.Console.Write(" |");// printf(" |");
- for (int c = 0; c < clm; c++)
- {// for(int c = 0; c < m->clm; c++) {
- System.Console.Write(" " + m[r][c]);// printf(" %10g", ARELEM0(m, r,
- // c));
- }
- System.Console.WriteLine(" |");// printf(" |\n");
- }
- System.Console.WriteLine(" ======================");// printf("
- // ======================\n");
- return 0;
- }
-
private const double PCA_EPS = 1e-6; // #define EPS 1e-6

private const int PCA_MAX_ITER = 100; // #define MAX_ITER 100
@@ -490,7 +412,7 @@
int i, i2;
lrow = this.row;
lclm = this.clm;
- double[][] lm = this.m;
+ double[][] lm = this._m;

if (lrow <= 0 || lclm <= 0)
{
@@ -529,13 +451,13 @@
double[] v;
int row, clm;

- row = inout.getRow();
- clm = inout.getClm();
+ row = inout.row;
+ clm = inout.clm;
if (mean.getClm() != clm)
{
throw new NyARException();
}
- double[][] im = inout.m;
+ double[][] im = inout._m;
double[] im_i;
double w0, w1;
v = mean.getArray();
@@ -605,20 +527,18 @@
if (j < i)
{
NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- output.m[i][j] = output.m[j][i];// *out =
+ output._m[i][j] = output._m[j][i];// *out =
// output->m[j*row+i];
}
else
{
NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- in1 = input.m[i];// input.getRowArray(i);//in1 =
- // &(input->m[clm*i]);
- in2 = input.m[j];// input.getRowArray(j);//in2 =
- // &(input->m[clm*j]);
- output.m[i][j] = 0;// *out = 0.0;
+ in1 = input._m[i];// input.getRowArray(i);//in1 = &(input->m[clm*i]);
+ in2 = input._m[j];// input.getRowArray(j);//in2 = &(input->m[clm*j]);
+ output._m[i][j] = 0;// *out = 0.0;
for (int k = 0; k < clm; k++)
{
- output.m[i][j] += (in1[k] * in2[k]);// *out += *(in1++)
+ output._m[i][j] += (in1[k] * in2[k]);// *out += *(in1++)
// * *(in2++);
}
}
@@ -635,20 +555,20 @@
* @param i_output
* @throws NyARException
*/
- private static void PCA_xt_by_x(NyARMat i_input, NyARMat i_output)
+ private static void PCA_xt_by_x(NyARMat input, NyARMat i_output)
{
double[] in_;
int row, clm;

- row = i_input.row;
- clm = i_input.clm;
+ row = input.row;
+ clm = input.clm;
if (i_output.row != clm || i_output.clm != clm)
{
throw new NyARException();
}

int k, j;
- double[][] out_m = i_output.m;
+ double[][] out_m = i_output._m;
double w;
for (int i = 0; i < clm; i++)
{
@@ -663,7 +583,7 @@
w = 0.0;// *out = 0.0;
for (k = 0; k < row; k++)
{
- in_ = i_input.m[k];// in=input.getRowArray(k);
+ in_ = input._m[k];// in=input.getRowArray(k);
w += (in_[i] * in_[j]);// *out += *in1 * *in2;
}
out_m[i][j] = w;
@@ -704,7 +624,7 @@
{
throw new NyARException();
}
- double[][] L_m = this.m;
+ double[][] L_m = this._m;
this.vecTridiagonalize(dv, ev, 1);

ev_array[0] = 0.0;// ev->v[0] = 0.0;
@@ -770,7 +690,7 @@
ev_array[k] = c * ev_array[k] - s * y;// ev->v[k]= c *ev->v[k]- s * y;
}
}
- ev_array[k + 1] += s * (c * w - 2 * s * ev_array[k + 1]);// ev->v[k+1]+= s* (c* w - 2* s*ev->v[k+1]);
+ ev_array[k + 1] += s * (c * w - 2 * s * ev_array[k + 1]);// ev->v[k+1]+= s * (c* w- 2* s *ev->v[k+1]);

for (int i = 0; i < dim; i++)
{
@@ -820,7 +740,7 @@
{
int i;
double w;
- double[] r1 = this.m[i_row_1], r2 = this.m[i_row_2];
+ double[] r1 = this._m[i_row_1], r2 = this._m[i_row_2];
// For鬆・、画峩OK
for (i = clm - 1; i >= 0; i--)
{
@@ -831,7 +751,8 @@
}

/**
- * static int EV_create( ARMat *input, ARMat *u, ARMat *output, ARVec *ev)縺ョ莉」譖ソ髢「謨ー
+ * static int EV_create( ARMat *input, ARMat *u, ARMat *output, ARVec *ev
+ * )縺ョ莉」譖ソ髢「謨ー
*
* @param input
* @param u
@@ -839,22 +760,25 @@
* @param ev
* @throws NyARException
*/
- private static void PCA_EV_create(NyARMat i_input, NyARMat u, NyARMat output, NyARVec ev)
+ private static void PCA_EV_create(NyARMat input, NyARMat u, NyARMat output, NyARVec ev)
{
NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
int row, clm;
- row = i_input.row;// row = input->row;
- clm = i_input.clm;// clm = input->clm;
+ row = input.row;// row = input->row;
+ clm = input.clm;// clm = input->clm;
if (row <= 0 || clm <= 0)
{
throw new NyARException();
}
if (u.row != row || u.clm != row)
- {// if( u->row != row || u->clm != row ){
+ {// if( u->row != row || u->clm !=
+ // row ){
throw new NyARException();
}
if (output.row != row || output.clm != clm)
- {// if( output->row !=row || output->clm !=clm ){
+ {// if( output->row !=
+ // row || output->clm !=
+ // clm ){
throw new NyARException();
}
if (ev.getClm() != row)
@@ -866,8 +790,8 @@
double sum, work;

NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- m = output.m;// m = output->m;
- in_ = i_input.m;
+ m = output._m;// m = output->m;
+ in_ = input._m;
int i;
ev_array = ev.getArray();
for (i = 0; i < row; i++)
@@ -883,7 +807,7 @@
for (int j = 0; j < clm; j++)
{
sum = 0.0;
- m1 = u.m[i];// m1 = &(u->m[i*row]);
+ m1 = u._m[i];// m1 = &(u->m[i*row]);
// m2=input.getPointer(j);//m2 = &(input->m[j]);
for (int k = 0; k < row; k++)
{
@@ -976,8 +900,8 @@
}
else
{
- m1 = u.m;// m1 = u->m;
- m2 = o_output.m;// m2 = output->m;
+ m1 = u._m;// m1 = u->m;
+ m2 = o_output._m;// m2 = output->m;
int i;
for (i = 0; i < min; i++)
{
@@ -1001,80 +925,42 @@
}
}
}
-
- private NyARMat wk_work_matrixPCA = null;
-
/**
- * int arMatrixPCA( ARMat *input, ARMat *evec, ARVec *ev, ARVec *mean );
- * 髢「謨ー縺ョ鄂ョ縺肴鋤縺医€Jnput蠑墓焚縺荊his縺ォ縺ェ繧九€・Optimize:2008.04.19
- *
+ * 荳サ謌仙・蛻・梵繧貞ョ溯。後@縺ヲ縲∫オ先棡繧稚his縺ィ蠑墓焚縺ク譬シ邏阪@縺セ縺吶€・
* @param o_evec
* @param o_ev
- *
- * @param mean
+ * @param o_mean
* @throws NyARException
*/
- public void matrixPCA(NyARMat o_evec, NyARVec o_ev, NyARVec mean)
+ public void pca(NyARMat o_evec, NyARVec o_ev, NyARVec o_mean)
{
- double srow, sum;
- int l_row, l_clm;
- int check;
+ double l_row = this.row;// row = input->row;
+ double l_clm = this.clm;// clm = input->clm;
+ double check = (l_row < l_clm) ? l_row : l_clm;

- l_row = this.row;// row = input->row;
- l_clm = this.clm;// clm = input->clm;
- check = (l_row < l_clm) ? l_row : l_clm;
- if (l_row < 2 || l_clm < 2)
- {
- throw new NyARException();
- }
- if (o_evec.clm != l_clm || o_evec.row != check)
- {// if( evec->clm !=
- // input->clm ||
- // evec->row !=
- // check ){
- throw new NyARException();
- }
- if (o_ev.getClm() != check)
- {// if( ev->clm != check ){
- throw new NyARException();
- }
- if (mean.getClm() != l_clm)
- {// if( mean->clm != input->clm ){
- throw new NyARException();
- }
+ Debug.Assert(l_row >= 2 || l_clm >= 2);
+ Debug.Assert(o_evec.clm == l_clm && o_evec.row == check);
+ Debug.Assert(o_ev.getClm() == check);
+ Debug.Assert(o_mean.getClm() == l_clm);

- // 閾ェ蛻・・蜀・ョケ繧偵Ρ繝シ繧ッ縺ォ繧ウ繝斐・(鬮倬€溷喧縺ョ轤コ縺ォ縲・蠎ヲ菴懊▲縺溘う繝ウ繧ケ繧ソ繝ウ繧ケ縺ッ菴ソ縺・∪繧上☆)
- NyARMat work;
- if (this.wk_work_matrixPCA == null)
- {
- work = this.matrixAllocDup();
- this.wk_work_matrixPCA = work;
- }
- else
- {
- work = this.wk_work_matrixPCA;
- work.matrixDup(this);// arMatrixAllocDup( input );work =
- // arMatrixAllocDup( input );
- }
+ double srow = Math.Sqrt((double)l_row);
+ PCA_EX(o_mean);

- srow = Math.Sqrt((double)l_row);
- work.PCA_EX(mean);
+ PCA_CENTER(this, o_mean);

- PCA_CENTER(work, mean);
-
int i, j;
// For鬆・、画峩OK
for (i = 0; i < l_row; i++)
{
for (j = 0; j < l_clm; j++)
{
- work.m[i][j] /= srow;// work->m[i] /= srow;
+ this._m[i][j] /= srow;// work->m[i] /= srow;
}
}

- work.PCA_PCA(o_evec, o_ev);
+ PCA_PCA(o_evec, o_ev);

- sum = 0.0;
+ double sum = 0.0;
double[] ev_array = o_ev.getArray();
int ev_clm = o_ev.getClm();
// For鬆・、画峩遖∵ュ「
@@ -1087,118 +973,11 @@
{// for(int i = 0; i < ev->clm; i++ ){
ev_array[i] /= sum;// ev->v[i] /= sum;
}
- }
-
- /* int arMatrixPCA2( ARMat *input, ARMat *evec, ARVec *ev ); */
- public static void arMatrixPCA2(NyARMat input, NyARMat evec, NyARVec ev)
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- NyARMat work;
- // double srow; // unreferenced
- double sum;
- int row, clm;
- int check;
-
- row = input.row;// row = input->row;
- clm = input.clm;// clm = input->clm;
- check = (row < clm) ? row : clm;
- if (row < 2 || clm < 2)
- {
- throw new NyARException();
- }
- if (evec.getClm() != input.clm || evec.row != check)
- {// if( evec->clm!= input->clm|| evec->row!= check ){
- throw new NyARException();
- }
- if (ev.getClm() != check)
- {// if( ev->clm != check ){
- throw new NyARException();
- }
-
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- work = input.matrixAllocDup();
-
- NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- work.PCA_PCA(evec, ev);// rval = PCA( work, evec, ev );
- sum = 0.0;
- double[] ev_array = ev.getArray();
- for (int i = 0; i < ev.getClm(); i++)
- {// for( i = 0; i < ev->clm; i++
- // ){
- NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- sum += ev_array[i];// sum += ev->v[i];
- }
- for (int i = 0; i < ev.getClm(); i++)
- {// for(int i = 0; i < ev->clm;i++ ){
- NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- ev_array[i] /= sum;// ev->v[i] /= sum;
- }
return;
}

- public static NyARMat matrixAllocMul(NyARMat a, NyARMat b)
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- NyARMat dest = new NyARMat(a.row, b.clm);
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- dest.matrixMul(a, b);
- return dest;
- }

- /* static double mdet(double *ap, int dimen, int rowa) */
- private static double Det_mdet(double[][] ap, int dimen, int rowa)
- {
- NyARException.trap("蜍穂ス懈悴繝√ぉ繝・け/驟榊・蛹匁悴繝√ぉ繝・け");
- double det = 1.0;
- double work;
- int is_ = 0;
- int mmax;

- for (int k = 0; k < dimen - 1; k++) {
- mmax = k;
- for (int i = k + 1; i < dimen; i++) {
- // if (Math.abs(arMatrixDet_MATRIX_get(ap, i, k, rowa)) >
- // Math.abs(arMatrixDet_MATRIX_get(ap, mmax, k, rowa))){
- if (Math.Abs(ap[i][k]) > Math.Abs(ap[mmax][k])) {
- mmax = i;
- }
- }
- if (mmax != k) {
- for (int j = k; j < dimen; j++) {
- work = ap[k][j];// work = MATRIX(ap, k, j, rowa);
- ap[k][j] = ap[mmax][j];// MATRIX(ap, k, j, rowa) =MATRIX(ap, mmax, j, rowa);
- ap[mmax][j] = work;// MATRIX(ap, mmax, j, rowa) = work;
- }
- is_++;
- }
- for (int i = k + 1; i < dimen; i++) {
- work = ap[i][k] / ap[k][k];// work = arMatrixDet_MATRIX_get(ap,i, k, rowa) /arMatrixDet_MATRIX_get(ap, k, k,rowa);
- for (int j = k + 1; j < dimen; j++) {
- // MATRIX(ap, i, j, rowa) -= work * MATRIX(ap, k, j, rowa);
- ap[i][j] -= work * ap[k][j];
- }
- }
- }
- for (int i = 0; i < dimen; i++) {
- det = ap[i][i];// det *= MATRIX(ap, i, i, rowa);
- }
- for (int i = 0; i < is_; i++) {
- det *= -1.0;
- }
- return det;
- }
-
- /* double arMatrixDet(ARMat *m); */
- public static double arMatrixDet(NyARMat m)
- {
- NyARException.trap("蜍穂ス懈悴繝√ぉ繝・け/驟榊・蛹匁悴繝√ぉ繝・け");
- if (m.row != m.clm)
- {
- return 0.0;
- }
- return Det_mdet(m.getArray(), m.row, m.clm);// return mdet(m->m, m->row,m->row);
- }
-
private NyARVec wk_vecTridiagonalize_vec = new NyARVec(0);

private NyARVec wk_vecTridiagonalize_vec2 = new NyARVec(0);
@@ -1243,7 +1022,7 @@
for (int k = 0; k < dim - 2; k++)
{

- a_vec_k = this.m[k];
+ a_vec_k = this._m[k];
vec.setNewArray(a_vec_k, clm);// vec=this.getRowVec(k);//double[]
// vec_array=vec.getArray();
NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
@@ -1265,12 +1044,12 @@
for (int j = k + 1; j < i; j++)
{
NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- s += this.m[j][i] * a_vec_k[j];// s += a_array[j][i] *vec.v[j];//s +=a.get(j*dim+i) *v.get(j);//s +=a->m[j*dim+i] * v[j];
+ s += this._m[j][i] * a_vec_k[j];// s += a_array[j][i] *vec.v[j];//s +=a.get(j*dim+i) *v.get(j);//s +=a->m[j*dim+i] * v[j];
}
for (int j = i; j < dim; j++)
{
NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- s += this.m[i][j] * a_vec_k[j];// s += a_array[i][j] *vec.v[j];//s +=a.get(i*dim+j) *v.get(j);//s +=a->m[i*dim+j] * v[j];
+ s += this._m[i][j] * a_vec_k[j];// s += a_array[i][j] *vec.v[j];//s +=a.get(i*dim+j) *v.get(j);//s +=a->m[i*dim+j] * v[j];
}
NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
d_vec[i] = s;// d.v[i]=s;//d->v[i] = s;
@@ -1279,7 +1058,7 @@
// wv1.clm = wv2.clm = dim-k-1;
// wv1.v = &(v[k+1]);
// wv2.v = &(d->v[k+1]);
- a_vec_k = this.m[k];
+ a_vec_k = this._m[k];
vec.setNewArray(a_vec_k, clm);// vec=this.getRowVec(k);
// vec_array=vec.getArray();
NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
@@ -1293,25 +1072,25 @@
for (int j = i; j < dim; j++)
{
NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- this.m[i][j] -= p * (d_vec[j] + q * a_vec_k[j]);// a.m[i][j]-=p*(d.v[j] +q*vec.v[j]);//a->m[i*dim+j] -=p*(d->v[j]) + q*v[j];
+ this._m[i][j] -= p * (d_vec[j] + q * a_vec_k[j]);// a.m[i][j]-=p*(d.v[j] +q*vec.v[j]);//a->m[i*dim+j] -=p*(d->v[j]) + q*v[j];
}
}
}

if (dim >= 2)
{
- d_vec[dim - 2] = this.m[dim - 2][dim - 2];// d.v[dim-2]=a.m[dim-2][dim-2];//d->v[dim-2]=a->m[(dim-2)*dim+(dim-2)];
- e_vec[dim - 2 + i_e_start] = this.m[dim - 2][dim - 1];// e.v[dim-2+i_e_start]=a.m[dim-2][dim-1];//e->v[dim-2] = a->m[(dim-2)*dim+(dim-1)];
+ d_vec[dim - 2] = this._m[dim - 2][dim - 2];// d.v[dim-2]=a.m[dim-2][dim-2];//d->v[dim-2]=a->m[(dim-2)*dim+(dim-2)];
+ e_vec[dim - 2 + i_e_start] = this._m[dim - 2][dim - 1];// e.v[dim-2+i_e_start]=a.m[dim-2][dim-1];//e->v[dim-2] = a->m[(dim-2)*dim+(dim-1)];
}

if (dim >= 1)
{
- d_vec[dim - 1] = this.m[dim - 1][dim - 1];// d.v[dim-1]=a_array[dim-1][dim-1];//d->v[dim-1] =a->m[(dim-1)*dim+(dim-1)];
+ d_vec[dim - 1] = this._m[dim - 1][dim - 1];// d.v[dim-1]=a_array[dim-1][dim-1];//d->v[dim-1] =a->m[(dim-1)*dim+(dim-1)];
}
NyARVec vec2 = this.wk_vecTridiagonalize_vec2;
for (int k = dim - 1; k >= 0; k--)
{
- a_vec_k = this.m[k];
+ a_vec_k = this._m[k];
vec.setNewArray(a_vec_k, clm);// vec=this.getRowVec(k);//v =a.getPointer(k*dim);//v = &(a->m[k*dim]);
if (k < dim - 2)
{
@@ -1320,13 +1099,13 @@
// wv1.clm = wv2.clm = dim-k-1;
// wv1.v = &(v[k+1]);
// wv2.v = &(a->m[i*dim+k+1]);
- vec2.setNewArray(this.m[i], clm);// vec2=this.getRowVec(i);
+ vec2.setNewArray(this._m[i], clm);// vec2=this.getRowVec(i);

t = vec.vecInnerproduct(vec2, k + 1);
for (int j = k + 1; j < dim; j++)
{
NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- this.m[i][j] -= t * a_vec_k[j];// a_array[i][j]-=t*vec.v[j];//a.subValue(i*dim+j,t*v.get(j));//a->m[i*dim+j]-= t * v[j];
+ this._m[i][j] -= t * a_vec_k[j];// a_array[i][j]-=t*vec.v[j];//a.subValue(i*dim+j,t*v.get(j));//a->m[i*dim+j]-= t * v[j];
}
}
}
Index: forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GLAY_8.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GLAY_8.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GLAY_8.cs (revision 252)
@@ -0,0 +1,68 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARRgbPixelReader_INT1D_GLAY_8 : INyARRgbPixelReader
+ {
+ protected int[] _ref_buf;
+
+ private NyARIntSize _size;
+
+ public NyARRgbPixelReader_INT1D_GLAY_8(int[] i_buf, NyARIntSize i_size)
+ {
+ this._ref_buf = i_buf;
+ this._size = i_size;
+ }
+
+ public void getPixel(int i_x, int i_y, int[] o_rgb)
+ {
+ o_rgb[0] = o_rgb[1] = o_rgb[2] = this._ref_buf[i_x + i_y * this._size.w];
+ return;
+ }
+
+ public void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] o_rgb)
+ {
+ int width = this._size.w;
+ int[] ref_buf = this._ref_buf;
+ for (int i = i_num - 1; i >= 0; i--)
+ {
+ o_rgb[i * 3 + 0] = o_rgb[i * 3 + 1] = o_rgb[i * 3 + 2] = ref_buf[i_x[i] + i_y[i] * width];
+ }
+ return;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs (revision 252)
@@ -0,0 +1,74 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARRgbPixelReader_INT1D_X8R8G8B8_32 : INyARRgbPixelReader
+ {
+ protected int[] _ref_buf;
+
+ private NyARIntSize _size;
+
+ public NyARRgbPixelReader_INT1D_X8R8G8B8_32(int[] i_buf, NyARIntSize i_size)
+ {
+ this._ref_buf = i_buf;
+ this._size = i_size;
+ }
+
+ public void getPixel(int i_x, int i_y, int[] o_rgb)
+ {
+ int rgb = this._ref_buf[i_x + i_y * this._size.w];
+ o_rgb[0] = (rgb >> 16) & 0xff;// R
+ o_rgb[1] = (rgb >> 8) & 0xff;// G
+ o_rgb[2] = rgb & 0xff;// B
+ return;
+ }
+
+ public void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] o_rgb)
+ {
+ int width = this._size.w;
+ int[] ref_buf = this._ref_buf;
+ for (int i = i_num - 1; i >= 0; i--)
+ {
+ int rgb = ref_buf[i_x[i] + i_y[i] * width];
+ o_rgb[i * 3 + 0] = (rgb >> 16) & 0xff;// R
+ o_rgb[i * 3 + 1] = (rgb >> 8) & 0xff;// G
+ o_rgb[i * 3 + 2] = rgb & 0xff;// B
+ }
+ return;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARBufferReader.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARBufferReader.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARBufferReader.cs (revision 252)
@@ -34,46 +34,95 @@

public abstract class INyARBufferReader
{
- /* ID隕冗エ・
- * 00-07(8)蝙狗分蜿キ
- * 08-15(8)繝薙ャ繝医ヵ繧ゥ繝シ繝槭ャ繝・D
- * 00:24bit/01:32bit/02:16bit
- * 16-27(8)蝙紀D
- * 00:辟。蜉ケ/01:byte[]/02:int[][]/03:short[]
- * 24-31(8)莠育エ・
+ public const int BYTE1D = 0x00010000;
+ public const int INT2D = 0x00020000;
+ public const int SHORT1D = 0x00030000;
+ public const int INT1D = 0x00040000;
+ // ID隕冗エ・
+ // 24-31(8)莠育エ・
+ // 16-27(8)蝙紀D
+ // 00:辟。蜉ケ/01:byte[]/02:int[][]/03:short[]
+ // 08-15(8)繝薙ャ繝医ヵ繧ゥ繝シ繝槭ャ繝・D
+ // 00:24bit/01:32bit/02:16bit
+ // 00-07(8)蝙狗分蜿キ
+ //
+ /**
+ * RGB24繝輔か繝シ繝槭ャ繝医〒縲∝・縺ヲ縺ョ逕サ邏縺・
*/
+ public const int BUFFERFORMAT_NULL_ALLZERO = 0x00000001;

/**
- * RGB24繝輔か繝シ繝槭ャ繝医〒縲∝・縺ヲ縺ョ逕サ邏縺・
+ * byte[]縺ァ縲ヽ8G8B8縺ョ24繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
*/
- public const int BUFFERFORMAT_NULL_ALLZERO = 0x00000001;
- /* ----------
- * byte[]蝙・
+ public const int BUFFERFORMAT_BYTE1D_R8G8B8_24 = BYTE1D | 0x0001;
+ /**
+ * byte[]縺ァ縲。8G8R8縺ョ24繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
*/
+ public const int BUFFERFORMAT_BYTE1D_B8G8R8_24 = BYTE1D | 0x0002;
+ /**
+ * byte[]縺ァ縲ヽ8G8B8X8縺ョ32繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
+ */
+ public const int BUFFERFORMAT_BYTE1D_B8G8R8X8_32 = BYTE1D | 0x0101;

- //byte[]縺ァ縲ヽ8G8B8縺ョ24繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
- public const int BUFFERFORMAT_BYTE1D_R8G8B8_24 = 0x00010001;
+ /**
+ * byte[]縺ァ縲ヽGB565縺ョ16繝薙ャ繝・little/big endian)縺ァ逕サ邏縺梧シ邏阪&繧後※縺・k縲・
+ */
+ public const int BUFFERFORMAT_BYTE1D_R5G6B5_16LE = BYTE1D | 0x0201;
+ public const int BUFFERFORMAT_BYTE1D_R5G6B5_16BE = BYTE1D | 0x0202;
+ /**
+ * short[]縺ァ縲ヽGB565縺ョ16繝薙ャ繝・little/big endian)縺ァ逕サ邏縺梧シ邏阪&繧後※縺・k縲・
+ */
+ public const int BUFFERFORMAT_WORD1D_R5G6B5_16LE = SHORT1D | 0x0201;
+ public const int BUFFERFORMAT_WORD1D_R5G6B5_16BE = SHORT1D | 0x0202;

- //byte[]縺ァ縲。8G8R8縺ョ24繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
- public const int BUFFERFORMAT_BYTE1D_B8G8R8_24 = 0x00010002;

- //byte[]縺ァ縲ヽ8G8B8X8縺ョ32繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
- public const int BUFFERFORMAT_BYTE1D_B8G8R8X8_32 = 0x00010101;
- //byte[]縺ァ縲ヽGB565縺ョ16繝薙ャ繝・LittleEndian)縺ァ逕サ邏縺梧シ邏阪&繧後※縺・k縲・
- public const int BUFFERFORMAT_BYTE1D_R5G6B5_16LE = 0x00010201;
- public const int BUFFERFORMAT_BYTE1D_R5G6B5_16BE = 0x00010202;
- //short[]縺ァ縲ヽGB565縺ョ16繝薙ャ繝・LittleEndian)縺ァ逕サ邏縺梧シ邏阪&繧後※縺・k縲・
- public const int BUFFERFORMAT_WORD1D_R5G6B5_16LE = 0x00030201;
- public const int BUFFERFORMAT_WORD1D_R5G6B5_16BE = 0x00030202;
- //int[][]縺ァ迚ケ縺ォ蛟、遽・峇繧貞ョ壹a縺ェ縺・
- public const int BUFFERFORMAT_INT2D = 0x00020000;
- //int[][]縺ァ0-255縺ョ繧ー繝ャ繧、繧ケ繧ア繝シ繝ォ逕サ蜒・
- public const int BUFFERFORMAT_INT2D_GLAY_8 = 0x00020001;
- //int[][]縺ァ0/1縺ョ2蛟、逕サ蜒・
- public const int BUFFERFORMAT_INT2D_BIN_8 = 0x00020002;
+ /**
+ * int[][]縺ァ迚ケ縺ォ蛟、遽・峇繧貞ョ壹a縺ェ縺・
+ */
+ public const int BUFFERFORMAT_INT2D = INT2D | 0x0000;
+ /**
+ * int[][]縺ァ0-255縺ョ繧ー繝ャ繧、繧ケ繧ア繝シ繝ォ逕サ蜒・
+ */
+ public const int BUFFERFORMAT_INT2D_GLAY_8 = INT2D | 0x0001;
+ /**
+ * int[][]縺ァ0/1縺ョ2蛟、逕サ蜒・
+ */
+ public const int BUFFERFORMAT_INT2D_BIN_8 = INT2D | 0x0002;

+ /**
+ * int[]縺ァ迚ケ縺ォ蛟、遽・峇繧貞ョ壹a縺ェ縺・
+ */
+ public const int BUFFERFORMAT_INT1D = INT1D | 0x0000;
+ /**
+ * int[]縺ァ0-255縺ョ繧ー繝ャ繧、繧ケ繧ア繝シ繝ォ逕サ蜒・
+ */
+ public const int BUFFERFORMAT_INT1D_GLAY_8 = INT1D | 0x0001;
+ /**
+ * int[]縺ァ0/1縺ョ2蛟、逕サ蜒・
+ */
+ public const int BUFFERFORMAT_INT1D_BIN_8 = INT1D | 0x0002;
+ /**
+ * int[]縺ァ縲々RGB32縺ョ32繝薙ャ繝医〒逕サ邏縺梧シ邏阪&繧後※縺・k縲・
+ */
+ public const int BUFFERFORMAT_INT1D_X8R8G8B8_32 = INT1D | 0x0102;
+
+
+ /**
+ * 繝舌ャ繝輔ぃ繧ェ繝悶ず繧ァ繧ッ繝医r霑斐@縺セ縺吶€・
+ * @return
+ */
public abstract object getBuffer();
+ /**
+ * 繝舌ャ繝輔ぃ繧ェ繝悶ず繧ァ繧ッ繝医・蠖「蠑上r霑斐@縺セ縺吶€・
+ * @return
+ */
public abstract int getBufferType();
+ /**
+ * 繝舌ャ繝輔ぃ繧ェ繝悶ず繧ァ繧ッ繝医・蠖「蠑上′縲(_type_value縺ォ縺御ク€閾エ縺吶k縺玖ソ斐@縺セ縺吶€・
+ * @param i_type_value
+ * @return
+ */
public abstract bool isEqualBufferType(int i_type_value);
+
}
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARRgbPixelReader.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARRgbPixelReader.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARRgbPixelReader.cs (revision 252)
@@ -32,9 +32,9 @@
namespace jp.nyatla.nyartoolkit.cs.core
{
/**
- * R8G8B8縺ァ繝斐け繧サ繝ォ繧定ェュ縺ソ蜃コ縺吶う繝ウ繧ソ繝輔ぉ繧、繧ケ
- *
- */
+ * R8G8B8縺ァ繝斐け繧サ繝ォ繧定ェュ縺ソ蜃コ縺吶う繝ウ繧ソ繝輔ぉ繧、繧ケ
+ *
+ */
public interface INyARRgbPixelReader
{
/**
@@ -47,17 +47,15 @@
void getPixel(int i_x, int i_y, int[] i_rgb);

/**
- * 隍・焚縺ョ繝斐け繧サ繝ォ蛟、繧段_rgb縺ク霑斐@縺セ縺吶€・
+ * 隍・焚縺ョ繝斐け繧サ繝ォ蛟、繧段nt驟榊・縺ォ霑斐@縺セ縺吶€・
+ * 驟榊・縺ォ縺ッ縲ーR1][G1][B1][R2][G2][B2]縺ョ鬆・〒繝斐け繧サ繝ォ蛟、縺梧シ邏阪&繧後∪縺吶€・
*
* @param i_x
* x縺ョ繧、繝ウ繝・ャ繧ッ繧ケ驟榊・
* @param i_y
* y縺ョ繧、繝ウ繝・ャ繧ッ繧ケ驟榊・
- * @param i_num
- * 霑斐☆繝斐け繧サ繝ォ蛟、縺ョ謨ー
- * @param i_rgb
- * 繝斐け繧サ繝ォ蛟、繧定ソ斐☆繝舌ャ繝輔ぃ
*/
- void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] i_rgb);
+ void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] i_intrgb);
}
+
}
Index: forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARBufferReader.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARBufferReader.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARBufferReader.cs (revision 252)
@@ -34,24 +34,30 @@

public class NyARBufferReader : INyARBufferReader
{
- protected object _buffer;
- protected int _buffer_type;
+ private object _buffer;
+ private int _buffer_type;
+ private NyARBufferReader()
+ {
+ return;
+ }
public NyARBufferReader(object i_buffer, int i_buffer_type)
{
this._buffer = i_buffer;
this._buffer_type = i_buffer_type;
+ return;
}
- override public object getBuffer()
+ public override object getBuffer()
{
return this._buffer;
}
- override public int getBufferType()
+ public override int getBufferType()
{
return _buffer_type;
}
- override public bool isEqualBufferType(int i_type_value)
+ public override bool isEqualBufferType(int i_type_value)
{
return this._buffer_type == i_type_value;
}
}
+
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_RGB24.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_RGB24.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_RGB24.cs (revision 252)
@@ -31,7 +31,6 @@
*/
namespace jp.nyatla.nyartoolkit.cs.core
{
-
/**
* byte[]驟榊・縺ォ縲√ヱ繝・ぅ繝ウ繧ー辟。縺励・8bit逕サ邏蛟、縺後€ヽGBRGB縺ョ鬆・〒荳ヲ繧薙〒縺・k
* 繝舌ャ繝輔ぃ縺ォ菴ソ逕ィ縺ァ縺阪k繝斐け繧サ繝ォ繝ェ繝シ繝€繝シ
@@ -53,24 +52,25 @@
{
byte[] ref_buf = this._ref_buf;
int bp = (i_x + i_y * this._size.w) * 3;
- o_rgb[0] = ref_buf[bp + 0];// R
- o_rgb[1] = ref_buf[bp + 1];// G
- o_rgb[2] = ref_buf[bp + 2];// B
+ o_rgb[0] = (ref_buf[bp + 0] & 0xff);// R
+ o_rgb[1] = (ref_buf[bp + 1] & 0xff);// G
+ o_rgb[2] = (ref_buf[bp + 2] & 0xff);// B
return;
}

public void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] o_rgb)
{
+ int bp;
int width = this._size.w;
byte[] ref_buf = this._ref_buf;
- int bp;
for (int i = i_num - 1; i >= 0; i--)
{
bp = (i_x[i] + i_y[i] * width) * 3;
- o_rgb[i * 3 + 0] = ref_buf[bp + 0];// R
- o_rgb[i * 3 + 1] = ref_buf[bp + 1];// G
- o_rgb[i * 3 + 2] = ref_buf[bp + 2];// B
+ o_rgb[i * 3 + 0] = (ref_buf[bp + 0] & 0xff);// R
+ o_rgb[i * 3 + 1] = (ref_buf[bp + 1] & 0xff);// G
+ o_rgb[i * 3 + 2] = (ref_buf[bp + 2] & 0xff);// B
}
+ return;
}
}
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/NyARSquareDetector.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/NyARSquareDetector.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/NyARSquareDetector.cs (revision 252)
@@ -411,7 +411,7 @@
}

NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
- NyARIntPoint[] l_imvertex = o_square.imvertex;
+ NyARIntPoint2d[] l_imvertex = o_square.imvertex;
for (int i = 0; i < 4; i++)
{
NyARLinear l_line_i = l_line[i];
Index: forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs (revision 252)
@@ -31,206 +31,203 @@
*/
namespace jp.nyatla.nyartoolkit.cs.core
{
+/**
+ * This class calculates ARMatrix from square information and holds it. --
+ * 螟画鋤陦悟・繧定ィ育ョ励@縺ヲ縲∫オ先棡繧剃ソ晄戟縺吶k繧ッ繝ゥ繧ケ縲・
+ *
+ */
+public class NyARTransMat : INyARTransMat
+{
+ private const double AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR = 1.0;

+ private NyARDoublePoint2d _center=new NyARDoublePoint2d(0,0);
+ private NyARTransOffset _offset=new NyARTransOffset();
+ protected NyARRotMatrix _rotmatrix;
+ protected NyARFitVecCalculator _calculator;
+ protected INyARRotTransOptimize _mat_optimize;

- public class NyARTransMat : INyARTransMat
- {
- private static double AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR = 1.0;
+ /**
+ * 豢セ逕溘け繝ゥ繧ケ縺ァ閾ェ蛻・〒繝。繝ウ繝舌が繝悶ず繧ァ繧ッ繝医r謖・ョ壹@縺溘>蝣エ蜷医・縺薙■繧峨r菴ソ縺・€・
+ *
+ */
+ protected NyARTransMat()
+ {
+ //_calculator,_rotmatrix,_mat_optimize繧偵さ繝ウ繧ケ繝医Λ繧ッ繧ソ縺ョ邨ゆコ・セ後↓
+ //菴懈・縺励※蜑イ繧雁ス薙※縺ヲ縺上□縺輔>縲・
+ return;
+ }
+ public NyARTransMat(NyARParam i_param)
+ {
+ NyARCameraDistortionFactor dist=i_param.getDistortionFactor();
+ NyARPerspectiveProjectionMatrix pmat=i_param.getPerspectiveProjectionMatrix();
+ this._calculator=new NyARFitVecCalculator(pmat,dist);
+ //莠呈鋤諤ァ縺碁㍾隕√↑譎ゅ・縲¨yARRotMatrix_ARToolKit繧剃スソ縺・%縺ィ縲・
+ //逅・ア医・NyARRotMatrix_NyARToolKit繧・yARRotMatrix_ARToolKit繧ょ酔縺倥□縺代←縲∝ー代@縺縺大€、縺後★繧後k縲・
+ this._rotmatrix = new NyARRotMatrix_NyARToolKit(pmat);
+// this._rotmatrix = new NyARRotMatrix_ARToolKit(pmat);
+ this._mat_optimize=new NyARRotTransOptimize_O2(pmat);
+ }

- private NyARDoublePoint2d _center = new NyARDoublePoint2d(0, 0);
- private NyARTransOffset _offset = new NyARTransOffset();
- protected NyARRotMatrix _rotmatrix;
- protected NyARFitVecCalculator _calculator;
- protected INyARRotTransOptimize _mat_optimize;
+ public void setCenter(double i_x, double i_y)
+ {
+ this._center.x= i_x;
+ this._center.y= i_y;
+ }

- /**
- * 豢セ逕溘け繝ゥ繧ケ縺ァ閾ェ蛻・〒繝。繝ウ繝舌が繝悶ず繧ァ繧ッ繝医r謖・ョ壹@縺溘>蝣エ蜷医・縺薙■繧峨r菴ソ縺・€・
- *
- */
- protected NyARTransMat()
- {
- //_calculator,_rotmatrix,_mat_optimize繧偵さ繝ウ繧ケ繝医Λ繧ッ繧ソ縺ョ邨ゆコ・セ後↓
- //菴懈・縺励※蜑イ繧雁ス薙※縺ヲ縺上□縺輔>縲・
- return;
- }
- public NyARTransMat(NyARParam i_param)
- {
- NyARCameraDistortionFactor dist = i_param.getDistortionFactor();
- NyARPerspectiveProjectionMatrix pmat = i_param.getPerspectiveProjectionMatrix();
- this._calculator = new NyARFitVecCalculator(pmat, dist);
- //莠呈鋤諤ァ縺碁㍾隕√↑譎ゅ・縲¨yARRotMatrix_ARToolKit繧剃スソ縺・%縺ィ縲・
- //逅・ア医・NyARRotMatrix_NyARToolKit繧・yARRotMatrix_ARToolKit繧ょ酔縺倥□縺代←縲∝ー代@縺縺大€、縺後★繧後k縲・
- this._rotmatrix = new NyARRotMatrix_NyARToolKit(pmat);
- // this._rotmatrix = new NyARRotMatrix_ARToolKit(pmat);
- this._mat_optimize = new NyARRotTransOptimize_O2(pmat);
- }

- public void setCenter(double i_x, double i_y)
- {
- this._center.x = i_x;
- this._center.y = i_y;
- }


+ /**
+ * 鬆らせ鬆・コ上ri_direction縺ォ蟇セ蠢懊@縺ヲ荳ヲ縺ケ譖ソ縺医∪縺吶€・
+ * @param i_square
+ * @param i_direction
+ * @param o_sqvertex_ref
+ * @param o_liner_ref
+ */
+ private void initVertexOrder(NyARSquare i_square, int i_direction, NyARDoublePoint2d[] o_sqvertex_ref, NyARLinear[] o_liner_ref)
+ {
+ //鬆らせ鬆・コ上r閠・・縺励◆遏ゥ蠖「縺ョ鬆らせ諠・ア
+ o_sqvertex_ref[0]= i_square.sqvertex[(4 - i_direction) % 4];
+ o_sqvertex_ref[1]= i_square.sqvertex[(5 - i_direction) % 4];
+ o_sqvertex_ref[2]= i_square.sqvertex[(6 - i_direction) % 4];
+ o_sqvertex_ref[3]= i_square.sqvertex[(7 - i_direction) % 4];
+ o_liner_ref[0]=i_square.line[(4 - i_direction) % 4];
+ o_liner_ref[1]=i_square.line[(5 - i_direction) % 4];
+ o_liner_ref[2]=i_square.line[(6 - i_direction) % 4];
+ o_liner_ref[3]=i_square.line[(7 - i_direction) % 4];
+ return;
+ }


- /**
- * 鬆らせ鬆・コ上ri_direction縺ォ蟇セ蠢懊@縺ヲ荳ヲ縺ケ譖ソ縺医∪縺吶€・
- * @param i_square
- * @param i_direction
- * @param o_sqvertex_ref
- * @param o_liner_ref
- */
- private void initVertexOrder(NyARSquare i_square, int i_direction, NyARDoublePoint2d[] o_sqvertex_ref, NyARLinear[] o_liner_ref)
- {
- //鬆らせ鬆・コ上r閠・・縺励◆遏ゥ蠖「縺ョ鬆らせ諠・ア
- o_sqvertex_ref[0] = i_square.sqvertex[(4 - i_direction) % 4];
- o_sqvertex_ref[1] = i_square.sqvertex[(5 - i_direction) % 4];
- o_sqvertex_ref[2] = i_square.sqvertex[(6 - i_direction) % 4];
- o_sqvertex_ref[3] = i_square.sqvertex[(7 - i_direction) % 4];
- o_liner_ref[0] = i_square.line[(4 - i_direction) % 4];
- o_liner_ref[1] = i_square.line[(5 - i_direction) % 4];
- o_liner_ref[2] = i_square.line[(6 - i_direction) % 4];
- o_liner_ref[3] = i_square.line[(7 - i_direction) % 4];
- return;
- }
+ private NyARDoublePoint2d[] __transMat_sqvertex_ref = new NyARDoublePoint2d[4];
+ private NyARLinear[] __transMat_linear_ref=new NyARLinear[4];
+ private NyARDoublePoint3d __transMat_trans=new NyARDoublePoint3d();
+ /**
+ * double arGetTransMat( ARMarkerInfo *marker_info,double center[2], double width, double conv[3][4] )
+ *
+ * @param i_square
+ * 險育ョ怜ッセ雎。縺ョNyARSquare繧ェ繝悶ず繧ァ繧ッ繝・
+ * @param i_direction
+ * @param i_width
+ * @return
+ * @throws NyARException
+ */
+ public void transMat(NyARSquare i_square, int i_direction, double i_width, NyARTransMatResult o_result_conv)
+ {
+ NyARDoublePoint2d[] sqvertex_ref = __transMat_sqvertex_ref;
+ NyARLinear[] linear_ref=__transMat_linear_ref;
+ NyARDoublePoint3d trans=this.__transMat_trans;
+
+ //險育ョ礼畑縺ォ鬆らせ諠・ア繧貞・譛溷喧・磯・分隱ソ謨エ・・
+ initVertexOrder(i_square, i_direction, sqvertex_ref,linear_ref);
+
+ //蝓コ貅也洸蠖「繧定ィュ螳・
+ this._offset.setSquare(i_width,this._center);

+ // rotation繧堤洸蠖「諠・ア縺九i險育ョ・
+ this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);

- private NyARDoublePoint2d[] __transMat_sqvertex_ref = new NyARDoublePoint2d[4];
- private NyARLinear[] __transMat_linear_ref = new NyARLinear[4];
- private NyARDoublePoint3d __transMat_trans = new NyARDoublePoint3d();
- /**
- * double arGetTransMat( ARMarkerInfo *marker_info,double center[2], double width, double conv[3][4] )
- *
- * @param i_square
- * 險育ョ怜ッセ雎。縺ョNyARSquare繧ェ繝悶ず繧ァ繧ッ繝・
- * @param i_direction
- * @param i_width
- * @return
- * @throws NyARException
- */
- public void transMat(NyARSquare i_square, int i_direction, double i_width, NyARTransMatResult o_result_conv)
- {
- NyARDoublePoint2d[] sqvertex_ref = __transMat_sqvertex_ref;
- NyARLinear[] linear_ref = __transMat_linear_ref;
- NyARDoublePoint3d trans = this.__transMat_trans;
+ //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓繧ェ繝輔そ繝・ヨ鬆らせ繧偵そ繝・ヨ
+ this._calculator.setOffsetSquare(this._offset);
+
+ //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓驕ゥ蠢懷・遏ゥ蠖「縺ョ諠・ア繧偵そ繝・ヨ
+ this._calculator.setFittedSquare(sqvertex_ref);

- //險育ョ礼畑縺ォ鬆らせ諠・ア繧貞・譛溷喧・磯・分隱ソ謨エ・・
- initVertexOrder(i_square, i_direction, sqvertex_ref, linear_ref);
+ //蝗櫁サ「陦悟・縺ョ蟷ウ陦檎ァサ蜍暮㍼縺ョ險育ョ・
+ this._calculator.calculateTransfer(this._rotmatrix,trans);
+
+ //險育ョ礼オ先棡縺ョ譛€驕ゥ蛹・this._rotmatrix,trans)
+ this._mat_optimize.optimize(this._rotmatrix,trans,this._calculator);
+
+ // 繝槭ヨ繝ェ繧ッ繧ケ縺ョ菫晏ュ・
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);
+ return;
+ }

- //蝓コ貅也洸蠖「繧定ィュ螳・
- this._offset.setSquare(i_width, this._center);
+ /*
+ * (non-Javadoc)
+ * @see jp.nyatla.nyartoolkit.core.transmat.INyARTransMat#transMatContinue(jp.nyatla.nyartoolkit.core.NyARSquare, int, double, jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult)
+ */
+ public void transMatContinue(NyARSquare i_square, int i_direction, double i_width, NyARTransMatResult io_result_conv)
+ {
+ NyARDoublePoint2d[] sqvertex_ref = __transMat_sqvertex_ref;
+ NyARLinear[] linear_ref=__transMat_linear_ref;
+ NyARDoublePoint3d trans=this.__transMat_trans;

- // rotation繧堤洸蠖「諠・ア縺九i險育ョ・
- this._rotmatrix.initRotBySquare(linear_ref, sqvertex_ref);
+ // io_result_conv縺悟・譛溷€、縺ェ繧峨€》ransMat縺ァ險育ョ励☆繧九€・
+ if (!io_result_conv.has_value) {
+ this.transMat(i_square, i_direction, i_width, io_result_conv);
+ return;
+ }

- //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓繧ェ繝輔そ繝・ヨ鬆らせ繧偵そ繝・ヨ
- this._calculator.setOffsetSquare(this._offset);
+ //險育ョ礼畑縺ォ鬆らせ諠・ア繧貞・譛溷喧・磯・分隱ソ謨エ・・
+ initVertexOrder(i_square, i_direction, sqvertex_ref,linear_ref);
+
+ //蝓コ貅也洸蠖「繧定ィュ螳・
+ this._offset.setSquare(i_width,this._center);

- //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓驕ゥ蠢懷・遏ゥ蠖「縺ョ諠・ア繧偵そ繝・ヨ
- this._calculator.setFittedSquare(sqvertex_ref);
+ // rotation繧堤洸蠖「諠・ア繧剃ク€縺、蜑阪・螟画鋤陦悟・縺ァ蛻晄悄蛹・
+ this._rotmatrix.initRotByPrevResult(io_result_conv);

- //蝗櫁サ「陦悟・縺ョ蟷ウ陦檎ァサ蜍暮㍼縺ョ險育ョ・
- this._calculator.calculateTransfer(this._rotmatrix, trans);
+ //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓縲√が繝輔そ繝・ヨ鬆らせ繧偵そ繝・ヨ
+ this._calculator.setOffsetSquare(this._offset);
+
+ //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓縲・←蠢懷・遏ゥ蠖「縺ョ諠・ア繧偵そ繝・ヨ
+ this._calculator.setFittedSquare(sqvertex_ref);
+
+ //蝗櫁サ「陦悟・縺ョ蟷ウ陦檎ァサ蜍暮㍼縺ョ險育ョ・
+ this._calculator.calculateTransfer(this._rotmatrix,trans);
+
+ //險育ョ礼オ先棡縺ョ譛€驕ゥ蛹・this._rotmatrix,trans)
+ double err=this._mat_optimize.optimize(this._rotmatrix,trans,this._calculator);
+
+ //險育ョ礼オ先棡繧剃ソ晏ュ・
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,io_result_conv);

- //險育ョ礼オ先棡縺ョ譛€驕ゥ蛹・this._rotmatrix,trans)
- this._mat_optimize.optimize(this._rotmatrix, trans, this._calculator);
+ // 繧ィ繝ゥ繝シ蛟、縺瑚ィア螳ケ遽・峇縺ァ縺ェ縺代l縺ーTransMat繧偵d繧顔峩縺・
+ if (err > AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR) {
+ // rotation繧堤洸蠖「諠・ア縺ァ蛻晄悄蛹・
+ this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);
+ //蝗櫁サ「陦悟・縺ョ蟷ウ陦檎ァサ蜍暮㍼縺ョ險育ョ・
+ this._calculator.calculateTransfer(this._rotmatrix,trans);
+ //險育ョ礼オ先棡縺ョ譛€驕ゥ蛹・this._rotmatrix,trans)
+ double err2=this._mat_optimize.optimize(this._rotmatrix,trans,this._calculator);
+ //繧ィ繝ゥ繝シ蛟、縺御ス弱°縺」縺溘i蛟、繧貞キョ謠帙∴
+ if (err2 < err) {
+ // 濶ッ縺・€、縺悟叙繧後◆繧峨€∝キョ謠帙∴
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,io_result_conv);
+ }
+ }
+ return;
+ }
+ /**
+ * 繝代Λ繝。繝シ繧ソ縺ァ螟画鋤陦悟・繧呈峩譁ー縺励∪縺吶€・
+ *
+ * @param i_rot
+ * @param i_off
+ * @param i_trans
+ */
+ public void updateMatrixValue(NyARRotMatrix i_rot, NyARDoublePoint3d i_off, NyARDoublePoint3d i_trans,NyARTransMatResult o_result)
+ {
+ o_result.m00=i_rot.m00;
+ o_result.m01=i_rot.m01;
+ o_result.m02=i_rot.m02;
+ o_result.m03=i_rot.m00 * i_off.x + i_rot.m01 * i_off.y + i_rot.m02 * i_off.z + i_trans.x;

- // 繝槭ヨ繝ェ繧ッ繧ケ縺ョ菫晏ュ・
- this.updateMatrixValue(this._rotmatrix, this._offset.point, trans, o_result_conv);
- return;
- }
- /**
- * double arGetTransMatCont( ARMarkerInfo *marker_info, double prev_conv[3][4],double center[2], double width, double conv[3][4] )
- *
- * @param i_square
- * @param i_direction
- * 繝槭・繧ォ繝シ縺ョ譁ケ菴阪r謖・ョ壹☆繧九€・
- * @param i_width
- * @param io_result_conv
- * 險育ョ怜ア・豁エ繧呈戟縺、NyARTransMatResult繧ェ繝悶ず繧ァ繧ッ繝医r謖・ョ壹☆繧九€・螻・豁エ繧呈戟縺溘↑縺・エ蜷医・縲》ransMat縺ィ蜷後§蜃ヲ逅・r陦後≧縲・
- * @return
- * @throws NyARException
- */
- public void transMatContinue(NyARSquare i_square, int i_direction, double i_width, NyARTransMatResult io_result_conv)
- {
- NyARDoublePoint2d[] sqvertex_ref = __transMat_sqvertex_ref;
- NyARLinear[] linear_ref = __transMat_linear_ref;
- NyARDoublePoint3d trans = this.__transMat_trans;
+ o_result.m10 = i_rot.m10;
+ o_result.m11 = i_rot.m11;
+ o_result.m12 = i_rot.m12;
+ o_result.m13 = i_rot.m10 * i_off.x + i_rot.m11 * i_off.y + i_rot.m12 * i_off.z + i_trans.y;

- // io_result_conv縺悟・譛溷€、縺ェ繧峨€》ransMat縺ァ險育ョ励☆繧九€・
- if (!io_result_conv.has_value)
- {
- this.transMat(i_square, i_direction, i_width, io_result_conv);
- return;
- }
+ o_result.m20 = i_rot.m20;
+ o_result.m21 = i_rot.m21;
+ o_result.m22 = i_rot.m22;
+ o_result.m23 = i_rot.m20 * i_off.x + i_rot.m21 * i_off.y + i_rot.m22 * i_off.z + i_trans.z;

- //蝓コ貅也洸蠖「繧定ィュ螳・
- this._offset.setSquare(i_width, this._center);
+ o_result.angle.setValue(i_rot.refAngle());
+ o_result.has_value = true;
+ return;
+ }
+}

- // rotation繧堤洸蠖「諠・ア繧剃ク€縺、蜑阪・螟画鋤陦悟・縺ァ蛻晄悄蛹・
- this._rotmatrix.initRotByPrevResult(io_result_conv);
-
- //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓縲√が繝輔そ繝・ヨ鬆らせ繧偵そ繝・ヨ
- this._calculator.setOffsetSquare(this._offset);
-
- //蟷ウ陦檎ァサ蜍暮㍼險育ョ玲ゥ溘↓縲・←蠢懷・遏ゥ蠖「縺ョ諠・ア繧偵そ繝・ヨ
- this._calculator.setFittedSquare(sqvertex_ref);
-
- //蝗櫁サ「陦悟・縺ョ蟷ウ陦檎ァサ蜍暮㍼縺ョ險育ョ・
- this._calculator.calculateTransfer(this._rotmatrix, trans);
-
- //險育ョ礼オ先棡縺ョ譛€驕ゥ蛹・this._rotmatrix,trans)
- double err = this._mat_optimize.optimize(this._rotmatrix, trans, this._calculator);
-
- //險育ョ礼オ先棡繧剃ソ晏ュ・
- this.updateMatrixValue(this._rotmatrix, this._offset.point, trans, io_result_conv);
-
- // 繧ィ繝ゥ繝シ蛟、縺瑚ィア螳ケ遽・峇縺ァ縺ェ縺代l縺ーTransMat繧偵d繧顔峩縺・
- if (err > AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR)
- {
- // rotation繧堤洸蠖「諠・ア縺ァ蛻晄悄蛹・
- this._rotmatrix.initRotBySquare(linear_ref, sqvertex_ref);
- //蝗櫁サ「陦悟・縺ョ蟷ウ陦檎ァサ蜍暮㍼縺ョ險育ョ・
- this._calculator.calculateTransfer(this._rotmatrix, trans);
- //險育ョ礼オ先棡縺ョ譛€驕ゥ蛹・this._rotmatrix,trans)
- double err2 = this._mat_optimize.optimize(this._rotmatrix, trans, this._calculator);
- //繧ィ繝ゥ繝シ蛟、縺御ス弱°縺」縺溘i蛟、繧貞キョ謠帙∴
- if (err2 < err)
- {
- // 濶ッ縺・€、縺悟叙繧後◆繧峨€∝キョ謠帙∴
- this.updateMatrixValue(this._rotmatrix, this._offset.point, trans, io_result_conv);
- }
- }
- return;
- }
- /**
- * 繝代Λ繝。繝シ繧ソ縺ァ螟画鋤陦悟・繧呈峩譁ー縺励∪縺吶€・
- *
- * @param i_rot
- * @param i_off
- * @param i_trans
- */
- public void updateMatrixValue(NyARRotMatrix i_rot, NyARDoublePoint3d i_off, NyARDoublePoint3d i_trans, NyARTransMatResult o_result)
- {
- o_result.m00 = i_rot.m00;
- o_result.m01 = i_rot.m01;
- o_result.m02 = i_rot.m02;
- o_result.m03 = i_rot.m00 * i_off.x + i_rot.m01 * i_off.y + i_rot.m02 * i_off.z + i_trans.x;
-
- o_result.m10 = i_rot.m10;
- o_result.m11 = i_rot.m11;
- o_result.m12 = i_rot.m12;
- o_result.m13 = i_rot.m10 * i_off.x + i_rot.m11 * i_off.y + i_rot.m12 * i_off.z + i_trans.y;
-
- o_result.m20 = i_rot.m20;
- o_result.m21 = i_rot.m21;
- o_result.m22 = i_rot.m22;
- o_result.m23 = i_rot.m20 * i_off.x + i_rot.m21 * i_off.y + i_rot.m22 * i_off.z + i_trans.z;
-
- o_result.angle.copyFrom(i_rot.refAngle());
- o_result.has_value = true;
- return;
- }
- }
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA.cs (revision 252)
@@ -57,7 +57,7 @@
input_array[i][1] = i_y[i];
}
// 荳サ謌仙・蛻・梵
- input.matrixPCA(this.__pca_evec, this.__pca_ev, this.__pca_mean);
+ input.pca(this.__pca_evec, this.__pca_ev, this.__pca_mean);
double[] mean_array = this.__pca_mean.getArray();
double[][] evec_array = this.__pca_evec.getArray();
double[] ev_array = this.__pca_ev.getArray();
Index: forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_O3.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_O3.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_O3.cs (revision 252)
@@ -38,55 +38,43 @@
*/
public class NyARColorPatt_O3 : INyARColorPatt
{
- private const int AR_PATT_SAMPLE_NUM = 64;// #define
- // AR_PATT_SAMPLE_NUM 64
+ private const int AR_PATT_SAMPLE_NUM = 64;

- private int[, ,] extpat;
+ private int[] _patdata;
+ private NyARBufferReader _buf_reader;
+ private NyARIntSize _size;
+ private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;

- private int width;
-
- private int height;
-
public NyARColorPatt_O3(int i_width, int i_height)
{
- this.width = i_width;
- this.height = i_height;
- this.extpat = new int[i_height, i_width, 3];
+ this._size = new NyARIntSize(i_width, i_height);
+ this._patdata = new int[i_height * i_width];
+ this._buf_reader = new NyARBufferReader(this._patdata, NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);
+ this._pixelreader = new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata, this._size);
}
-
- // public void setSize(int i_new_width,int i_new_height)
- // {
- // int array_w=this.extpat[0].length;
- // int array_h=this.extpat.length;
- // //蜊∝・縺ェ繧オ繧、繧コ縺ョ繝舌ャ繝輔ぃ縺後≠繧九°遒コ隱・
- // if(array_w>=i_new_width && array_h>=i_new_height){
- // //OK 蜊∝・縺竊偵し繧、繧コ隱ソ謨エ縺ョ縺ソ
- // }else{
- // //雜ウ繧翫↑縺・h竊貞叙繧顔峩縺・
- // this.extpat=new int[i_new_height][i_new_width][3];
- // }
- // this.width =i_new_width;
- // this.height=i_new_height;
- // return;
- // }
- public int[, ,] getPatArray()
- {
- return extpat;
- }
-
public int getWidth()
{
- return width;
+ return this._size.w;
}
-
public int getHeight()
{
- return height;
+ return this._size.h;
}
-
+ public NyARIntSize getSize()
+ {
+ return this._size;
+ }
+ public INyARBufferReader getBufferReader()
+ {
+ return this._buf_reader;
+ }
+ public INyARRgbPixelReader getRgbPixelReader()
+ {
+ return this._pixelreader;
+ }
private NyARMat wk_get_cpara_a = new NyARMat(8, 8);
-
private NyARMat wk_get_cpara_b = new NyARMat(8, 1);
+ private NyARMat wk_pickFromRaster_cpara = new NyARMat(8, 1);

/**
* @param world
@@ -94,9 +82,9 @@
* @param o_para
* @throws NyARException
*/
- private bool get_cpara(NyARIntPoint[] i_vertex, NyARMat o_para)
+ private bool get_cpara(NyARIntPoint2d[] i_vertex, NyARMat o_para)
{
- int[, ] world = this.wk_pickFromRaster_world;
+ int[,] world = wk_pickFromRaster_world;
NyARMat a = wk_get_cpara_a;// 谺。蜃ヲ逅・〒蛟、繧定ィュ螳壹☆繧九・縺ァ縲∝・譛溷喧荳崎ヲ・/ new NyARMat( 8, 8 );
double[][] a_array = a.getArray();
NyARMat b = wk_get_cpara_b;// 谺。蜃ヲ逅・〒蛟、繧定ィュ螳壹☆繧九・縺ァ縲∝・譛溷喧荳崎ヲ・/ new NyARMat( 8, 1 );
@@ -108,9 +96,8 @@
a_pt0 = a_array[i * 2];
a_pt1 = a_array[i * 2 + 1];

-
- a_pt0[0] = (double)world[i, 0];// a->m[i*16+0] = world[i][0];
- a_pt0[1] = (double)world[i, 1];// a->m[i*16+1] = world[i][1];
+ a_pt0[0] = (double)world[i,0];// a->m[i*16+0] = world[i][0];
+ a_pt0[1] = (double)world[i,1];// a->m[i*16+1] = world[i][1];
a_pt0[2] = 1.0;// a->m[i*16+2] = 1.0;
a_pt0[3] = 0.0;// a->m[i*16+3] = 0.0;
a_pt0[4] = 0.0;// a->m[i*16+4] = 0.0;
@@ -120,11 +107,11 @@
a_pt1[0] = 0.0;// a->m[i*16+8] = 0.0;
a_pt1[1] = 0.0;// a->m[i*16+9] = 0.0;
a_pt1[2] = 0.0;// a->m[i*16+10] = 0.0;
- a_pt1[3] = (double)world[i, 0];// a->m[i*16+11] = world[i][0];
- a_pt1[4] = (double)world[i, 1];// a->m[i*16+12] = world[i][1];
+ a_pt1[3] = (double)world[i,0];// a->m[i*16+11] = world[i][0];
+ a_pt1[4] = (double)world[i,1];// a->m[i*16+12] = world[i][1];
a_pt1[5] = 1.0;// a->m[i*16+13] = 1.0;
- a_pt1[6] = (double)(-world[i, 0] * i_vertex[i].y);// a->m[i*16+14]=-world[i][0]*vertex[i][1];
- a_pt1[7] = (double)(-world[i, 1] * i_vertex[i].y);// a->m[i*16+15]=-world[i][1]*vertex[i][1];
+ a_pt1[6] = (double)(-world[i,0] * i_vertex[i].y);// a->m[i*16+14]=-world[i][0]*vertex[i][1];
+ a_pt1[7] = (double)(-world[i,1] * i_vertex[i].y);// a->m[i*16+15]=-world[i][1]*vertex[i][1];
b_array[i * 2 + 0][0] = (double)i_vertex[i].x;// b->m[i*2+0] =vertex[i][0];
b_array[i * 2 + 1][0] = (double)i_vertex[i].y;// b->m[i*2+1] =vertex[i][1];
}
@@ -138,28 +125,10 @@
}

// private final double[] wk_pickFromRaster_para=new double[9];//[3][3];
- private int[, ] wk_pickFromRaster_world = {// double world[4][2];
+ private static int[,] wk_pickFromRaster_world = {// double world[4][2];
{ 100, 100 }, { 100 + 10, 100 }, { 100 + 10, 100 + 10 }, { 100, 100 + 10 } };

- /**
- * pickFromRaster髢「謨ー縺九i菴ソ縺・、画焚縺ァ縺吶€・
- *
- */
- private static void initValue_wk_pickFromRaster_ext_pat2(int[,,] i_ext_pat2, int i_width, int i_height)
- {
- int i, i2;
- for (i = i_height - 1; i >= 0; i--)
- {
- for (i2 = i_width - 1; i2 >= 0; i2--)
- {
- i_ext_pat2[i, i2, 0] = 0;
- i_ext_pat2[i, i2, 1] = 0;
- i_ext_pat2[i, i2, 2] = 0;
- }
- }
- }

- private NyARMat wk_pickFromRaster_cpara = new NyARMat(8, 1);

/**
* image縺九i縲(_marker縺ョ菴咲スョ縺ォ縺ゅk繝代ち繝シ繝ウ繧貞・繧雁・縺励※縲∽ソ晄戟縺励∪縺吶€・Optimize:STEP[769->750]
@@ -171,20 +140,11 @@
public bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square)
{
NyARMat cpara = this.wk_pickFromRaster_cpara;
- NyARIntPoint[] local = i_square.imvertex;
- // //local縺ョ險育ョ・
- // int[] local_0=wk_pickFromRaster_local[0];//double local[4][2];
- // int[] local_1=wk_pickFromRaster_local[1];//double local[4][2];
- // //
- // for(int i = 0; i < 4; i++ ) {
- // local_0[i] = i_square.imvertex[i][0];
- // local_1[i] = i_square.imvertex[i][1];
- // }
+ NyARIntPoint2d[] local = i_square.imvertex;
// xdiv2,ydiv2縺ョ險育ョ・
int xdiv2, ydiv2;
int l1, l2;
int w1, w2;
-
// x險育ョ・
w1 = local[0].x - local[1].x;
w2 = local[0].y - local[1].y;
@@ -197,7 +157,7 @@
l1 = l2;
}
l1 = l1 / 4;
- xdiv2 = this.width;
+ xdiv2 = this._size.w;
while (xdiv2 * xdiv2 < l1)
{
xdiv2 *= 2;
@@ -218,7 +178,7 @@
{
l1 = l2;
}
- ydiv2 = this.height;
+ ydiv2 = this._size.h;
l1 = l1 / 4;
while (ydiv2 * ydiv2 < l1)
{
@@ -238,166 +198,117 @@

return true;
}
-
- // 縺九↑繧雁、ァ縺阪>繝ッ繝シ繧ッ繝舌ャ繝輔ぃ繧貞叙繧九↑窶ヲ縲・
- private double[] wk_updateExtpat_para00_xw;
-
- private double[] wk_updateExtpat_para10_xw;
-
- private double[] wk_updateExtpat_para20_xw;
-
- private int[] wk_updateExtpat_rgb_buf;
-
- private int[] wk_updateExtpat_x_rgb_index;
-
- private int[] wk_updateExtpat_y_rgb_index;
-
- private int[] wk_updateExtpat_i_rgb_index;
-
- private int wk_updateExtpat_buffer_size = 0;
-
- /**
- * 繝ッ繝シ繧ッ繝舌ャ繝輔ぃ繧剃コ育エ・☆繧・
- *
- * @param i_xdiv2
- */
- private void reservWorkBuffers(int i_xdiv2)
+ private int[] __updateExtpat_rgbset;
+ private int[] __updateExtpat_xc;
+ private int[] __updateExtpat_yc;
+ private double[] __updateExtpat_xw;
+ private double[] __updateExtpat_yw;
+ private int _last_pix_resolution_x = 0;
+ private int _last_pix_resolution_y = 0;
+ private void reservWorkBuffers(int i_xdiv, int i_ydiv)
{
- if (this.wk_updateExtpat_buffer_size < i_xdiv2)
+ if (this._last_pix_resolution_x < i_xdiv || this._last_pix_resolution_y < i_ydiv)
{
- wk_updateExtpat_para00_xw = new double[i_xdiv2];
- wk_updateExtpat_para10_xw = new double[i_xdiv2];
- wk_updateExtpat_para20_xw = new double[i_xdiv2];
- wk_updateExtpat_rgb_buf = new int[i_xdiv2 * 3];
- wk_updateExtpat_x_rgb_index = new int[i_xdiv2];
- wk_updateExtpat_y_rgb_index = new int[i_xdiv2];
- wk_updateExtpat_i_rgb_index = new int[i_xdiv2];
- this.wk_updateExtpat_buffer_size = i_xdiv2;
+ this.__updateExtpat_xc = new int[i_xdiv * i_ydiv];
+ this.__updateExtpat_yc = new int[i_xdiv * i_ydiv];
+ this.__updateExtpat_xw = new double[i_xdiv];
+ this.__updateExtpat_yw = new double[i_ydiv];
+ this.__updateExtpat_rgbset = new int[i_xdiv * i_ydiv * 3];
}
- // 蜊∝・縺ェ繧我ス輔b縺励↑縺・€・
return;
}
+ private const double LT_POS = 102.5;
+ private const double SQ_SIZE = 5.0;

+ //蛻・牡謨ー16譛ェ貅€縺ォ縺ェ繧九→蟆代@驕・¥縺ェ繧九°繧ゅ€・
private void updateExtpat(INyARRgbRaster image, NyARMat i_cpara, int i_xdiv2, int i_ydiv2)
{
- int img_x = image.getWidth();
- int img_y = image.getHeight();
- int[,,] L_extpat = this.extpat;
- int L_WIDTH = this.width;
- int L_HEIGHT = this.height;
- /* wk_pickFromRaster_ext_pat2繝ッ繝シ繧ッ螟画焚繧貞・譛溷喧縺吶k縲・*/
- // int[][][] ext_pat2=wk_pickFromRaster_ext_pat2;//ARUint32
- // ext_pat2[AR_PATT_SIZE_Y][AR_PATT_SIZE_X][3];
-// int[][] extpat_j;
-// int[] extpat_j_i;
- // int ext_pat2_j[][],ext_pat2_j_i[];

- initValue_wk_pickFromRaster_ext_pat2(L_extpat, L_WIDTH, L_HEIGHT);
-
- double[][] cpara_array = i_cpara.getArray();
- double para21_x_yw, para01_x_yw, para11_x_yw;
- double para00, para01, para02, para10, para11, para12, para20, para21;
- para00 = cpara_array[0 * 3 + 0][0];// para[i][0] = c->m[i*3+0];
- para01 = cpara_array[0 * 3 + 1][0];// para[i][1] = c->m[i*3+1];
- para02 = cpara_array[0 * 3 + 2][0];// para[i][2] = c->m[i*3+2];
- para10 = cpara_array[1 * 3 + 0][0];// para[i][0] = c->m[i*3+0];
- para11 = cpara_array[1 * 3 + 1][0];// para[i][1] = c->m[i*3+1];
- para12 = cpara_array[1 * 3 + 2][0];// para[i][2] = c->m[i*3+2];
- para20 = cpara_array[2 * 3 + 0][0];// para[2][0] = c->m[2*3+0];
- para21 = cpara_array[2 * 3 + 1][0];// para[2][1] = c->m[2*3+1];
-
- double d, yw;
- int xc, yc;
int i, j;
- // arGetCode_put_zero(ext_pat2);//put_zero( (ARUint8 *)ext_pat2,
- // AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3*sizeof(ARUint32) );
- int xdiv = i_xdiv2 / L_WIDTH;// xdiv = xdiv2/Config.AR_PATT_SIZE_X;
- int ydiv = i_ydiv2 / L_HEIGHT;// ydiv = ydiv2/Config.AR_PATT_SIZE_Y;
-
- // 險育ョ励ヰ繝・ヵ繧。繧剃コ育エ・☆繧・
- this.reservWorkBuffers(i_xdiv2);
- double[] para00_xw = this.wk_updateExtpat_para00_xw;
- double[] para10_xw = this.wk_updateExtpat_para10_xw;
- double[] para20_xw = this.wk_updateExtpat_para20_xw;
- int[] x_rgb_index = this.wk_updateExtpat_x_rgb_index;
- int[] y_rgb_index = this.wk_updateExtpat_y_rgb_index;
- int[] i_rgb_index = this.wk_updateExtpat_i_rgb_index;
- int[] rgb_buf = this.wk_updateExtpat_rgb_buf;
- double xw;
- for (i = 0; i < i_xdiv2; i++)
- {
- xw = 102.5 + 5.0 * ((double)i + 0.5) / i_xdiv2;
- para20_xw[i] = para20 * xw;
- para00_xw[i] = para00 * xw;
- para10_xw[i] = para10 * xw;
- }
-
- int index_num;
- int extpat_j_pt, extpat_i_pt;
+ int r, g, b;
//繝斐け繧サ繝ォ繝ェ繝シ繝€繝シ繧貞叙蠕・
+ int pat_size_w = this._size.w;
+ int xdiv = i_xdiv2 / pat_size_w;// xdiv = xdiv2/Config.AR_PATT_SIZE_X;
+ int ydiv = i_ydiv2 / this._size.h;// ydiv = ydiv2/Config.AR_PATT_SIZE_Y;
+ int xdiv_x_ydiv = xdiv * ydiv;
+ double reciprocal;
+ double[][] para = i_cpara.getArray();
+ double para00 = para[0 * 3 + 0][0];
+ double para01 = para[0 * 3 + 1][0];
+ double para02 = para[0 * 3 + 2][0];
+ double para10 = para[1 * 3 + 0][0];
+ double para11 = para[1 * 3 + 1][0];
+ double para12 = para[1 * 3 + 2][0];
+ double para20 = para[2 * 3 + 0][0];
+ double para21 = para[2 * 3 + 1][0];
+
INyARRgbPixelReader reader = image.getRgbPixelReader();
+ int img_width = image.getWidth();
+ int img_height = image.getHeight();

- for (j = 0; j < i_ydiv2; j++)
+ //繝ッ繝シ繧ッ繝舌ャ繝輔ぃ縺ョ貅門y
+ reservWorkBuffers(xdiv, ydiv);
+ double[] xw = this.__updateExtpat_xw;
+ double[] yw = this.__updateExtpat_yw;
+ int[] xc = this.__updateExtpat_xc;
+ int[] yc = this.__updateExtpat_yc;
+ int[] rgb_set = this.__updateExtpat_rgbset;
+
+
+ for (int iy = this._size.h - 1; iy >= 0; iy--)
{
- yw = 102.5 + 5.0 * ((double)j + 0.5) / i_ydiv2;
- para21_x_yw = para21 * yw + 1.0;
- para11_x_yw = para11 * yw + para12;
- para01_x_yw = para01 * yw + para02;
-// extpat_j = L_extpat[j / ydiv];
- extpat_j_pt = j / ydiv;
- index_num = 0;
- // 繧ケ繝・ャ繝暦シ托シ山GB蜿門セ礼畑縺ョ繝槭ャ繝励r菴懈・
- for (i = 0; i < i_xdiv2; i++)
+ for (int ix = pat_size_w - 1; ix >= 0; ix--)
{
- d = para20_xw[i] + para21_x_yw;
- if (d == 0)
+ //xw,yw繝槭ャ繝励r菴懈・
+ reciprocal = 1.0 / i_xdiv2;
+ for (i = xdiv - 1; i >= 0; i--)
{
- throw new NyARException();
+ xw[i] = LT_POS + SQ_SIZE * (ix * xdiv + i + 0.5) * reciprocal;
}
- xc = (int)((para00_xw[i] + para01_x_yw) / d);
- yc = (int)((para10_xw[i] + para11_x_yw) / d);
- // 遽・峇螟悶・辟。隕・
- if (xc < 0 || xc >= img_x || yc < 0 || yc >= img_y)
+ reciprocal = 1.0 / i_ydiv2;
+ for (i = ydiv - 1; i >= 0; i--)
{
- continue;
+ yw[i] = LT_POS + SQ_SIZE * (iy * ydiv + i + 0.5) * reciprocal;
}
- // 繝斐け繧サ繝ォ蛟、縺ョ險育ョ・
- // image.getPixel(xc,yc,rgb_buf);
- // ext_pat2_j_i=ext_pat2_j[i/xdiv];
- // ext_pat2_j_i[0] += rgb_buf[0];//R
- // ext_pat2_j_i[1] += rgb_buf[1];//G
- // ext_pat2_j_i[2] += rgb_buf[2];//B
+ //1繝斐け繧サ繝ォ繧呈ァ区・縺吶k繝斐け繧サ繝ォ蠎ァ讓吶・髮・粋繧遅c,yc驟榊・縺ォ蜿門セ・
+ int number_of_pix = 0;
+ for (i = ydiv - 1; i >= 0; i--)
+ {
+ double para01_x_yw_para02 = para01 * yw[i] + para02;
+ double para11_x_yw_para12 = para11 * yw[i] + para12;
+ double para12_x_yw_para22 = para21 * yw[i] + 1.0;
+ for (j = xdiv - 1; j >= 0; j--)
+ {

- x_rgb_index[index_num] = xc;
- y_rgb_index[index_num] = yc;
- i_rgb_index[index_num] = i / xdiv;
- index_num++;
+ double d = para20 * xw[j] + para12_x_yw_para22;
+ if (d == 0)
+ {
+ throw new NyARException();
+ }
+ int xcw = (int)((para00 * xw[j] + para01_x_yw_para02) / d);
+ int ycw = (int)((para10 * xw[j] + para11_x_yw_para12) / d);
+ if (xcw < 0 || xcw >= img_width || ycw < 0 || ycw >= img_height)
+ {
+ continue;
+ }
+ xc[number_of_pix] = xcw;
+ yc[number_of_pix] = ycw;
+ number_of_pix++;
+ }
+ }
+ //1繝斐け繧サ繝ォ蛻・・驟榊・繧貞叙蠕・
+ reader.getPixelSet(xc, yc, number_of_pix, rgb_set);
+ r = g = b = 0;
+ for (i = number_of_pix * 3 - 1; i >= 0; i -= 3)
+ {
+ r += rgb_set[i - 2];// R
+ g += rgb_set[i - 1];// G
+ b += rgb_set[i];// B
+ }
+ //1繝斐け繧サ繝ォ遒コ螳・
+ this._patdata[iy * pat_size_w + ix] = (((r / xdiv_x_ydiv) & 0xff) << 16) | (((g / xdiv_x_ydiv) & 0xff) << 8) | (((b / xdiv_x_ydiv) & 0xff));
}
- // //繧ケ繝・ャ繝暦シ抵シ弱ヴ繧ッ繧サ繝ォ驟榊・繧貞叙蠕・
- reader.getPixelSet(x_rgb_index, y_rgb_index, index_num, rgb_buf);
- // //繝斐け繧サ繝ォ蛟、縺ョ險育ョ・
- for (i = index_num - 1; i >= 0; i--)
- {
- // extpat_j_i = extpat_j[i_rgb_index[i]];
- extpat_i_pt = i_rgb_index[i];
- extpat[extpat_j_pt, extpat_i_pt, 0] += rgb_buf[i * 3 + 0];//R
- extpat[extpat_j_pt, extpat_i_pt, 1] += rgb_buf[i * 3 + 1];//G
- extpat[extpat_j_pt, extpat_i_pt, 2] += rgb_buf[i * 3 + 2];//B
- }
}
- /* <Optimize> */
- int xdiv_x_ydiv = xdiv * ydiv;
- for (j = L_HEIGHT - 1; j >= 0; j--)
- {
- // extpat_j=L_extpat[j];
- for (i = L_WIDTH - 1; i >= 0; i--)
- { // PRL 2006-06-08.
- // extpat_j_i=extpat_j[i];
- extpat[j, i, 0] /= (xdiv_x_ydiv);//ext_pat[j][i][0] = (byte)(ext_pat2[j][i][0] / (xdiv*ydiv));
- extpat[j, i, 1] /= (xdiv_x_ydiv);//ext_pat[j][i][1] = (byte)(ext_pat2[j][i][1] / (xdiv*ydiv));
- extpat[j, i, 2] /= (xdiv_x_ydiv);//ext_pat[j][i][2] = (byte)(ext_pat2[j][i][2] / (xdiv*ydiv));
- }
- }
return;
}
}
Index: forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_PseudoAffine.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_PseudoAffine.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_PseudoAffine.cs (revision 252)
@@ -0,0 +1,171 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 逍台シシ繧「繝輔ぅ繝ウ螟画鋤繧剃スソ逕ィ縺励※縲√Λ繧ケ繧ソ荳翫・蝗幄ァ貞ス「縺九i莉サ諢剰ァ」蜒丞コヲ
+ * 縺ョ遏ゥ蠖「繝代ち繝シ繝ウ繧剃ス懈・縺励∪縺吶€・
+ *
+ */
+ public class NyARColorPatt_PseudoAffine : INyARColorPatt
+ {
+ private int[] _patdata;
+ private NyARBufferReader _buf_reader;
+ private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;
+ private NyARIntSize _size;
+
+ public int getWidth()
+ {
+ return this._size.w;
+ }
+
+ public int getHeight()
+ {
+ return this._size.h;
+ }
+
+ public NyARIntSize getSize()
+ {
+ return this._size;
+ }
+
+ public INyARBufferReader getBufferReader()
+ {
+ return this._buf_reader;
+ }
+
+ public INyARRgbPixelReader getRgbPixelReader()
+ {
+ return this._pixelreader;
+ }
+ NyARDoubleMatrix44 _invmat = new NyARDoubleMatrix44();
+ /**
+ * @param i_width
+ * @param i_height
+ */
+ public NyARColorPatt_PseudoAffine(int i_width, int i_height)
+ {
+ this._size=new NyARIntSize(i_width,i_height);
+ this._patdata = new int[i_height*i_width];
+ this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);
+ this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);
+ //逍台シシ繧「繝輔ぅ繝ウ螟画鋤縺ョ繝代Λ繝。繧ソ繝槭ヨ繝ェ繧ッ繧ケ繧定ィ育ョ励@縺セ縺吶€・
+ //髟キ譁ケ蠖「縺九i險育ョ励☆繧九→縲∵怏蜉ケ隕∫エ縺稽00,m01,m02,m03,m10,m11,m20,m23,m30縺ォ縺ェ繧翫∪縺吶€・
+ NyARDoubleMatrix44 mat=this._invmat;
+ mat.m00=0;
+ mat.m01=0;
+ mat.m02=0;
+ mat.m03=1.0;
+ mat.m10=0;
+ mat.m11=i_width-1;
+ mat.m12=0;
+ mat.m13=1.0;
+ mat.m20=(i_width-1)*(i_height-1);
+ mat.m21=i_width-1;
+ mat.m22=i_height-1;
+ mat.m23=1.0;
+ mat.m30=0;
+ mat.m31=0;
+ mat.m32=i_height-1;
+ mat.m33=1.0;
+ NyARDoubleMatrixProcessor.inverse(mat,mat);
+ return;
+ }
+
+ /**
+ * 螟画鋤陦悟・縺ィ鬆らせ蠎ァ讓吶°繧峨€√ヱ繝ゥ繝。繝シ繧ソ繧定ィ育ョ・
+ * o_param縺ョ[0..3]縺ォ縺ッX縺ョ繝代Λ繝。繧ソ縲ー4..7]縺ォ縺ッY縺ョ繝代Λ繝。繧ソ繧呈シ邏阪☆繧九€・
+ * @param i_vertex
+ * @param pa
+ * @param pb
+ */
+ private void calcPara(NyARIntPoint2d[] i_vertex, double[] o_cparam)
+ {
+ NyARDoubleMatrix44 invmat = this._invmat;
+ double v1, v2, v4;
+ //螟画鋤陦悟・縺ィ繝吶け繝医Ν縺ョ遨阪°繧峨€∝、画鋤繝代Λ繝。繧ソ繧定ィ育ョ励☆繧九€・
+ v1 = i_vertex[0].x;
+ v2 = i_vertex[1].x;
+ v4 = i_vertex[3].x;
+
+ o_cparam[0] = invmat.m00 * v1 + invmat.m01 * v2 + invmat.m02 * i_vertex[2].x + invmat.m03 * v4;
+ o_cparam[1] = invmat.m10 * v1 + invmat.m11 * v2;//m12,m13縺ッ0;
+ o_cparam[2] = invmat.m20 * v1 + invmat.m23 * v4;//m21,m22縺ッ0;
+ o_cparam[3] = v1;//m30縺ッ1.0縺ァ縲[31,m32,m33縺ッ0
+
+ v1 = i_vertex[0].y;
+ v2 = i_vertex[1].y;
+ v4 = i_vertex[3].y;
+
+ o_cparam[4] = invmat.m00 * v1 + invmat.m01 * v2 + invmat.m02 * i_vertex[2].y + invmat.m03 * v4;
+ o_cparam[5] = invmat.m10 * v1 + invmat.m11 * v2;//m12,m13縺ッ0;
+ o_cparam[6] = invmat.m20 * v1 + invmat.m23 * v4;//m21,m22縺ッ0;
+ o_cparam[7] = v1;//m30縺ッ1.0縺ァ縲[31,m32,m33縺ッ0
+ return;
+ }
+
+ /**
+ * 逍台シシ繧「繝輔ぅ繝ウ螟画鋤縺ョ螟画鋤繝代Λ繝。繧ソ
+ */
+ private double[] _convparam = new double[8];
+
+ public bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square)
+ {
+ double[] conv_param = this._convparam;
+ int rx2, ry2;
+ rx2 = this._size.w;
+ ry2 = this._size.h;
+ int[] rgb_tmp = new int[3];
+
+ INyARRgbPixelReader reader = image.getRgbPixelReader();
+ // 螟牙ス「蜈磯伜沺縺ョ鬆らせ繧貞叙蠕・
+
+ //螟画鋤陦悟・縺九i迴セ蝨ィ縺ョ蠎ァ讓咏ウサ縺ク縺ョ螟画鋤繝代Λ繝。繧ソ繧剃ス懈・
+ calcPara(i_square.imvertex, conv_param);// 螟画鋤繝代Λ繝。繝シ繧ソ繧呈アゅa繧・
+ for (int y = 0; y < ry2; y++)
+ {
+ for (int x = 0; x < rx2; x++)
+ {
+ int ttx = (int)((conv_param[0] * x * y + conv_param[1] * x + conv_param[2] * y + conv_param[3]) + 0.5);
+ int tty = (int)((conv_param[4] * x * y + conv_param[5] * x + conv_param[6] * y + conv_param[7]) + 0.5);
+ reader.getPixel((int)ttx, (int)tty, rgb_tmp);
+ this._patdata[x + y * rx2] = (rgb_tmp[0] << 16) | (rgb_tmp[1] << 8) | rgb_tmp[2];
+ }
+ }
+ return true;
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/core/pickup/INyARColorPatt.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/pickup/INyARColorPatt.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/pickup/INyARColorPatt.cs (revision 252)
@@ -31,34 +31,11 @@
*/
namespace jp.nyatla.nyartoolkit.cs.core
{
-
- public interface INyARColorPatt
+ public interface INyARColorPatt : INyARRgbRaster
{
/**
- * 繧ォ繝ゥ繝シ繝代ち繝シ繝ウ縺ョ蟷・r繝斐け繧サ繝ォ蛟、縺ァ霑斐@縺セ縺吶€・
+ * 繝ゥ繧ケ繧ソ繧、繝。繝シ繧ク縺九ii_square驛ィ蛻・・繧ォ繝ゥ繝シ繝代ち繝シ繝ウ繧呈歓蜃コ縺励※縲》his繝。繝ウ繝舌↓譬シ邏阪@縺セ縺吶€・
*
- * @return
- */
- int getWidth();
-
- /**
- * 繧ォ繝ゥ繝シ繝代ち繝シ繝ウ縺ョ鬮倥&繧偵ヴ繧ッ繧サ繝ォ蛟、縺ァ霑斐@縺セ縺吶€・
- *
- * @return
- */
- int getHeight();
- /**
- * 繧ォ繝。繝ゥ繝代ち繝シ繝ウ繧呈シ邏阪@縺滄・蛻励∈縺ョ蜿ら・蛟、繧定ソ斐@縺セ縺吶€・驟榊・縺ッ譛€菴弱〒繧・height][wight][3]縺ョ繧オ繧、繧コ繧呈戟縺。縺セ縺吶′縲・
- * 驟榊・縺ョlength縺ィwidth,height縺ョ謨ー縺ッ荳€閾エ縺励↑縺・%縺ィ縺後≠繧翫∪縺吶€・
- * setSize髢「謨ー繧貞ョ溯。後☆繧九→縲∽サ・蜑阪↓蜻シ縺ウ蜃コ縺輔l縺殀etPatArray縺瑚ソ斐@縺溷€、縺ッ荳榊ョ壹↓縺ェ繧翫∪縺吶€・
- *
- * @return
- */
- int[,,] getPatArray();
-
- /**
- * 繝ゥ繧ケ繧ソ繧、繝。繝シ繧ク縺九ii_square驛ィ蛻・・繧ォ繝ゥ繝シ繝代ち繝シ繝ウ繧呈歓蜃コ縺励※縲∽ソ晄戟縺励∪縺吶€・
- *
* @param image
* @param i_square
* @return 繝ゥ繧ケ繧ソ繝シ縺ョ蜿門セ励↓謌仙粥縺吶k縺ィTRUE/螟ア謨励☆繧九→FALSE
Index: forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective.cs (revision 252)
@@ -0,0 +1,191 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 驕霑第ウ輔r菴ソ縺」縺溘ヱ繝シ繧ケ繝壹け繝・ぅ繝冶」懈ュ」繧偵°縺代※縲√Λ繧ケ繧ソ荳翫・蝗幄ァ貞ス「縺九i
+ * 莉サ諢剰ァ」蜒丞コヲ縺ョ遏ゥ蠖「繝代ち繝シ繝ウ繧剃ス懈・縺励∪縺吶€・
+ *
+ */
+ public class NyARColorPatt_Perspective : INyARColorPatt
+ {
+ private int[] _patdata;
+ private NyARBufferReader _buf_reader;
+ private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;
+ private NyARIntSize _size;
+ NyARPerspectiveParamGenerator_O1 _perspective_gen;
+ private const int LOCAL_LT = 1;
+ private NyARIntPoint2d _pickup_lt = new NyARIntPoint2d();
+ /**
+ * 萓九∴縺ー縲・4
+ * @param i_width
+ * 蜿門セ礼判蜒上・隗」蜒丞コヲ蟷・
+ * @param i_height
+ * 蜿門セ礼判蜒上・隗」蜒丞コヲ鬮倥&
+ */
+ public NyARColorPatt_Perspective(int i_width, int i_height)
+ {
+ //蜈・蜉帛宛髯・
+ Debug.Assert(i_width > 2 && i_height > 2);
+
+ this._size = new NyARIntSize(i_width, i_height);
+ this._patdata = new int[i_height * i_width];
+ this._buf_reader = new NyARBufferReader(this._patdata, NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);
+ this._pixelreader = new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata, this._size);
+ setEdgeSize(0, 0);
+ return;
+ }
+ /**
+ * 萓九∴縺ー縲・4
+ * @param i_width
+ * 蜿門セ礼判蜒上・隗」蜒丞コヲ蟷・
+ * @param i_height
+ * 蜿門セ礼判蜒上・隗」蜒丞コヲ鬮倥&
+ * @param i_edge_percentage
+ * 繧ィ繝・ず蟷・・蜑イ蜷・ARToolKit讓呎コ悶→蜷後§縺ェ繧峨€・5)
+ */
+ public NyARColorPatt_Perspective(int i_width, int i_height, int i_edge_percentage)
+ {
+ //蜈・蜉帛宛髯・
+ Debug.Assert(i_width > 2 && i_height > 2);
+
+ this._size = new NyARIntSize(i_width, i_height);
+ this._patdata = new int[i_height * i_width];
+ this._buf_reader = new NyARBufferReader(this._patdata, NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);
+ this._pixelreader = new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata, this._size);
+ setEdgeSizeByPercent(i_edge_percentage, i_edge_percentage);
+ return;
+ }
+ /**
+ * 遏ゥ蠖「鬆伜沺縺ョ繧ィ繝・ず繧オ繧、繧コ繧呈欠螳壹@縺セ縺吶€・
+ * 繧ィ繝・ず縺ョ險育ョ玲婿豕輔・莉・荳九・騾壹j縺ァ縺吶€・
+ * 1.繝槭・繧ォ蜈ィ菴薙r(i_x_edge*2+width)x(i_y_edge*2+height)縺ョ隗」蜒丞コヲ縺ァ繝代Λ繝。繧ソ繧定ィ育ョ励@縺セ縺吶€・
+ * 2.繝斐け繧サ繝ォ縺ョ蜿門セ鈴幕蟋倶ス咲スョ繧・i_x_edge/2,i_y_edge/2)縺ク遘サ蜍輔@縺セ縺吶€・
+ * 3.髢句ァ倶ス咲スョ縺九i縲『idth x height蛟九・繝斐け繧サ繝ォ繧貞叙蠕励@縺セ縺吶€・
+ *
+ * ARToolKit讓呎コ悶・繝シ繧ォ縺ョ蝣エ蜷医・縲『idth/2,height/2繧呈欠螳壹@縺ヲ縺上□縺輔>縲・
+ * @param i_x_edge
+ * @param i_y_edge
+ */
+ public void setEdgeSize(int i_x_edge, int i_y_edge)
+ {
+ Debug.Assert(i_x_edge >= 0);
+ Debug.Assert(i_y_edge >= 0);
+ //Perspective繝代Λ繝。繧ソ險育ョ怜勣繧剃ス懈・
+ this._perspective_gen = new NyARPerspectiveParamGenerator_O1(LOCAL_LT, LOCAL_LT, i_x_edge * 2 + this._size.w, i_y_edge * 2 + this._size.h);
+ //繝斐ャ繧ッ繧「繝・・髢句ァ倶ス咲スョ繧定ィ育ョ・
+ this._pickup_lt.x = i_x_edge + LOCAL_LT;
+ this._pickup_lt.y = i_y_edge + LOCAL_LT;
+ return;
+ }
+ public void setEdgeSizeByPercent(int i_x_percent, int i_y_percent)
+ {
+ Debug.Assert(i_x_percent >= 0);
+ Debug.Assert(i_y_percent >= 0);
+ setEdgeSize(this._size.w * i_x_percent / 50, this._size.h * i_y_percent / 50);
+ return;
+ }
+
+
+ public int getWidth()
+ {
+ return this._size.w;
+ }
+ public int getHeight()
+ {
+ return this._size.h;
+ }
+ public NyARIntSize getSize()
+ {
+ return this._size;
+ }
+ public INyARBufferReader getBufferReader()
+ {
+ return this._buf_reader;
+ }
+ public INyARRgbPixelReader getRgbPixelReader()
+ {
+ return this._pixelreader;
+ }
+ private int[] __pickFromRaster_rgb_tmp = new int[3];
+ /**
+ *
+ * @param image
+ * @param i_marker
+ * @return 蛻・j蜃コ縺励↓螟ア謨励@縺・
+ * @throws Exception
+ */
+ public bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square)
+ {
+ //驕霑第ウ輔・繝代Λ繝。繝シ繧ソ繧定ィ育ョ・
+ double[] cpara = new double[8];
+ if (!this._perspective_gen.getParam(i_square.imvertex, cpara))
+ {
+ return false;
+ }
+
+ int img_x = image.getWidth();
+ int img_y = image.getHeight();
+
+ int[] rgb_tmp = __pickFromRaster_rgb_tmp;
+
+ //繝斐け繧サ繝ォ繝ェ繝シ繝€繝シ繧貞叙蠕・
+ INyARRgbPixelReader reader = image.getRgbPixelReader();
+
+ for (int iy = 0; iy < this._size.h; iy++)
+ {
+ for (int ix = 0; ix < this._size.w; ix++)
+ {
+ //1繝斐け繧サ繝ォ繧剃ス懈・
+ int cx = this._pickup_lt.x + ix;
+ int cy = this._pickup_lt.y + iy;
+ double d = cpara[6] * cx + cpara[7] * cy + 1.0;
+ int x = (int)((cpara[0] * cx + cpara[1] * cy + cpara[2]) / d);
+ int y = (int)((cpara[3] * cx + cpara[4] * cy + cpara[5]) / d);
+ if (x >= 0 && x < img_x && y >= 0 && y < img_y)
+ {
+ reader.getPixel(x, y, rgb_tmp);
+ this._patdata[iy * this._size.w + ix] = (((rgb_tmp[0]) & 0xff) << 16) | (((rgb_tmp[1]) & 0xff) << 8) | (((rgb_tmp[2]) & 0xff));
+ }
+ }
+ //繝斐け繧サ繝ォ蝠上>蜷医o縺・
+ //繝斐け繧サ繝ォ繧サ繝・ヨ
+ }
+ return true;
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationColorData.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationColorData.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationColorData.cs (revision 252)
@@ -0,0 +1,164 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * INyARMatchPatt縺ョRGBColor蟾ョ蛻・ョ繝シ繧ソ繧呈シ邏阪☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ *
+ */
+ public class NyARMatchPattDeviationColorData
+ {
+ private int[] _data;
+ private double _pow;
+ //
+ private int _number_of_pixels;
+ private int _optimize_for_mod;
+ public int[] refData()
+ {
+ return this._data;
+ }
+ public double getPow()
+ {
+ return this._pow;
+ }
+
+ public NyARMatchPattDeviationColorData(int i_width, int i_height)
+ {
+ this._number_of_pixels = i_height * i_width;
+ this._data = new int[this._number_of_pixels * 3];
+ this._optimize_for_mod = this._number_of_pixels - (this._number_of_pixels % 8);
+ return;
+ }
+
+
+ /**
+ * NyARRaster縺九i繝代ち繝シ繝ウ繝・・繧ソ繧偵そ繝・ヨ縺励∪縺吶€・
+ * 縺薙・髢「謨ー縺ッ縲√ョ繝シ繧ソ繧貞・縺ォ謇€譛峨☆繧九ョ繝シ繧ソ鬆伜沺繧呈峩譁ー縺励∪縺吶€・
+ * @param i_buffer
+ */
+ public void setRaster(INyARRaster i_raster)
+ {
+ //逕サ邏繝輔か繝シ繝槭ャ繝医€√し繧、繧コ蛻カ髯・
+ Debug.Assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32));
+ Debug.Assert(i_raster.getSize().isEqualSize(i_raster.getSize()));
+
+ int[] buf = (int[])i_raster.getBufferReader().getBuffer();
+ //i_buffer[XRGB]竊貞キョ蛻・R,G,B]螟画鋤
+ int i;
+ int ave;//<PV/>
+ int rgb;//<PV/>
+ int[] linput = this._data;//<PV/>
+
+ // input驟榊・縺ョ繧オ繧、繧コ縺ィwh繧よ峩譁ー// input=new int[height][width][3];
+ int number_of_pixels = this._number_of_pixels;
+ int for_mod = this._optimize_for_mod;
+
+ //<蟷ウ蝮・€、險育ョ・FOR縺ョ1/8螻暮幕)>
+ ave = 0;
+ for (i = number_of_pixels - 1; i >= for_mod; i--)
+ {
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);
+ }
+ for (; i >= 0; )
+ {
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ rgb = buf[i]; ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff); i--;
+ }
+ //<蟷ウ蝮・€、險育ョ・FOR縺ョ1/8螻暮幕)/>
+ ave = number_of_pixels * 255 * 3 - ave;
+ ave = 255 - (ave / (number_of_pixels * 3));//(255-R)-ave 繧貞・隗」縺吶k縺溘a縺ョ莠句燕險育ョ・
+
+ int sum = 0, w_sum;
+ int input_ptr = number_of_pixels * 3 - 1;
+ //<蟾ョ蛻・€、險育ョ・FOR縺ョ1/8螻暮幕)>
+ for (i = number_of_pixels - 1; i >= for_mod; i--)
+ {
+ rgb = buf[i];
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ }
+ for (; i >= 0; )
+ {
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ rgb = buf[i]; i--;
+ w_sum = (ave - (rgb & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//B
+ w_sum = (ave - ((rgb >> 8) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//G
+ w_sum = (ave - ((rgb >> 16) & 0xff)); linput[input_ptr--] = w_sum; sum += w_sum * w_sum;//R
+ }
+ //<蟾ョ蛻・€、險育ョ・FOR縺ョ1/8螻暮幕)/>
+ double p = Math.Sqrt((double)sum);
+ this._pow = p != 0.0 ? p : 0.0000001;
+ return;
+ }
+ }
+}
+
+
Index: forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_BlackWhite.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_BlackWhite.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_BlackWhite.cs (revision 252)
@@ -0,0 +1,79 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * AR_TEMPLATE_MATCHING_BW縺ィ蜷檎ュ峨・繝ォ繝シ繝ォ縺ァ 繝槭・繧ォ繧定ゥ穂セ。縺励∪縺吶€・
+ *
+ */
+ public class NyARMatchPatt_BlackWhite : INyARMatchPatt
+ {
+ protected NyARCode _code_patt;
+ protected int _pixels;
+
+ public NyARMatchPatt_BlackWhite(int i_width, int i_height)
+ {
+ //譛€驕ゥ蛹門ョ壽焚縺ョ險育ョ・
+ this._pixels = i_height * i_width;
+ return;
+ }
+ public NyARMatchPatt_BlackWhite(NyARCode i_code_ref)
+ {
+ //譛€驕ゥ蛹門ョ壽焚縺ョ險育ョ・
+ this._pixels = i_code_ref.getWidth() * i_code_ref.getHeight();
+ this._code_patt = i_code_ref;
+ return;
+ }
+ /**
+ * 豈碑シ・ッセ雎。縺ョARCode繧偵そ繝・ヨ縺励∪縺吶€・
+ * @throws NyARException
+ */
+ public void setARCode(NyARCode i_code_ref)
+ {
+ this._code_patt = i_code_ref;
+ return;
+ }
+ /**
+ * 迴セ蝨ィ繧サ繝・ヨ縺輔l縺ヲ縺・k繧ウ繝シ繝峨→繝代ち繝シ繝ウ繧呈ッ碑シ・@縺ヲ縲∫オ先棡蛟、o_result繧呈峩譁ー縺励∪縺吶€・
+ * 豈碑シ・Κ蛻・・For譁・r16蛟榊ア暮幕縺励※縺ゅj縺セ縺吶€・
+ */
+ public bool evaluate(NyARMatchPattDeviationBlackWhiteData i_patt, NyARMatchPattResult o_result)
+ {
+ Debug.Assert(this._code_patt != null);
+
+ int[] linput = i_patt.refData();
+ int sum;
+ double max = 0.0;
+ int res = NyARSquare.DIRECTION_UNKNOWN;
+
+
+ for (int j = 0; j < 4; j++)
+ {
+ //蜷郁ィ亥€、蛻晄悄蛹・
+ sum = 0;
+ NyARMatchPattDeviationBlackWhiteData code_patt = this._code_patt.getBlackWhiteData(j);
+ int[] pat_j = code_patt.refData();
+ //<蜈ィ逕サ邏縺ォ縺、縺・※縲∵ッ碑シ・FOR縺ョ1/16螻暮幕)/>
+ int i;
+ for (i = this._pixels - 1; i >= 0; i--)
+ {
+ sum += linput[i] * pat_j[i];
+ }
+ //0.7776737688877927縺後〒繧後・OK
+ double sum2 = sum / code_patt.getPow() / i_patt.getPow();// sum2 = sum / patpow[k][j]/ datapow;
+ if (sum2 > max)
+ {
+ max = sum2;
+ res = j;
+ }
+ }
+ o_result.direction = res;
+ o_result.confidence = max;
+ return true;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattResult.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattResult.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattResult.cs (revision 252)
@@ -0,0 +1,47 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * [[Strage class]]
+ *
+ */
+ public class NyARMatchPattResult
+ {
+ public double confidence;
+ public int direction;
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_Color_WITHOUT_PCA.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_Color_WITHOUT_PCA.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_Color_WITHOUT_PCA.cs (revision 252)
@@ -30,6 +30,7 @@
*
*/
using System;
+using System.Diagnostics;
namespace jp.nyatla.nyartoolkit.cs.core
{

@@ -39,165 +40,90 @@
*/
public class NyARMatchPatt_Color_WITHOUT_PCA : INyARMatchPatt
{
- private int[, ,] input = new int[1, 1, 3];
+ protected NyARCode _code_patt;

- private double datapow;
-
- private int width = 1;
-
- private int height = 1;
-
- private double cf = 0;
-
- private int dir = 0;
-
- public double getConfidence()
+ protected int _optimize_for_mod;
+ protected int _rgbpixels;
+ public NyARMatchPatt_Color_WITHOUT_PCA(NyARCode i_code_ref)
{
- return cf;
+ int w = i_code_ref.getWidth();
+ int h = i_code_ref.getHeight();
+ //譛€驕ゥ蛹門ョ壽焚縺ョ險育ョ・
+ this._rgbpixels = w * h * 3;
+ this._optimize_for_mod = this._rgbpixels - (this._rgbpixels % 16);
+ this.setARCode(i_code_ref);
+ return;
}
-
- public int getDirection()
+ public NyARMatchPatt_Color_WITHOUT_PCA(int i_width, int i_height)
{
- return dir;
+ //譛€驕ゥ蛹門ョ壽焚縺ョ險育ョ・
+ this._rgbpixels = i_height * i_width * 3;
+ this._optimize_for_mod = this._rgbpixels - (this._rgbpixels % 16);
+ return;
}
-
/**
- * input驟榊・繧オ繧、繧コ繧貞ソ・ヲ√↓蠢懊§縺ヲ蜀阪い繝ュ繧ア繝シ繝医☆繧九€・
- *
- * @param i_width
- * @param i_height
+ * 豈碑シ・ッセ雎。縺ョARCode繧偵そ繝・ヨ縺励∪縺吶€・
+ * @throws NyARException
*/
- private void reallocInputArray(int i_width, int i_height)
+ public void setARCode(NyARCode i_code_ref)
{
- if(this.input.Length<i_height*i_width*3)
- {
- // 驟榊・縺悟香蛻・↑繧オ繧、繧コ縺ァ縺ェ縺代l縺ー蜿悶j逶エ縺・
- this.input = new int[i_height, i_width, 3];
- }
- this.height = i_height;
- this.width = i_width;
+ this._code_patt = i_code_ref;
+ return;
}
-
- public bool setPatt(INyARColorPatt i_target_patt)
- {
- int i, k;
- int[, ,] data, linput;
-
- // input驟榊・縺ョ繧オ繧、繧コ縺ィwh繧よ峩譁ー// input=new int[height][width][3];
- reallocInputArray(i_target_patt.getWidth(), i_target_patt.getHeight());
- int lwidth = this.width;
- int lheight = this.height;
- linput = this.input;
- data = i_target_patt.getPatArray();
-
- int sum = 0, l_ave = 0, w_sum;
-// int[][] data_i, input_i;
-// int[] data_i_k, input_i_k;
- for (i = lheight - 1; i >= 0; i--)
- {// <Optimize/>for(int i=0;i<height;i++) {
- //for(int i=0;i<Config.AR_PATT_SIZE_Y;i++){
-// data_i = data[i];
- for (k = lwidth - 1; k >= 0; k--)
- {// <Optimize/>for(int
- // i2=0;i2<Config.AR_PATT_SIZE_X;i2++){
- // <Optimize/>l_ave +=(255-data[i][i2][0])+(255-data[i][i2][1])+(255-data[i][i2][2]);
-// data_i_k=data_i[k];
-// l_ave += 255 * 3 - data_i_k[0] - data_i_k[1] - data_i_k[2];
- l_ave += 255 * 3 - data[i, k, 0] - data[i, k, 1] - data[i, k, 2];
-
- }
- }
- l_ave /= (lheight * lwidth * 3);
- for (i = lheight - 1; i >= 0; i--)
- {// for(i=0;i<height;i++){//for(int i=0;i<Config.AR_PATT_SIZE_Y;i++){
-// input_i = linput[i];
-// data_i = data[i];
- for (k = lwidth - 1; k >= 0; k--)
- {// for(i2=0;i2<width;i2++){//for(int i2=0;i2<Config.AR_PATT_SIZE_X;i2++){
- // <Optimize>
- // for(int i3=0;i3<3;i3++){
- // input[i][i2][i3] = (255-data[i][i2][i3]) - l_ave;
- // sum += input[i][i2][i3]*input[i][i2][i3];
- // }
-// data_i_k =data_i[k];
-// input_i_k=linput[k];
- w_sum = (255 - data[i, k, 0]) - l_ave;
-// input_i_k[0]=w_sum;
- linput[i, k, 0] = w_sum;
- sum += w_sum * w_sum;
-
- w_sum = (255 - data[i, k, 1]) - l_ave;
-// input_i_k[1] = w_sum;
- linput[i, k, 1] = w_sum;
- sum += w_sum * w_sum;
-
- w_sum = (255 - data[i, k, 2]) - l_ave;
-// input_i_k[2] = w_sum;
- linput[i, k, 2] = w_sum;
- sum += w_sum * w_sum;
- // </Optimize>
- }
- }
- datapow = Math.Sqrt((double)sum);
- if (datapow == 0.0)
- {
- return false;// throw new NyARException();
- // dir.set(0);//*dir = 0;
- // cf.set(-1.0);//*cf = -1.0;
- // return -1;
- }
- return true;
- }
-
/**
- * public int pattern_match(short[][][] data,IntPointer dir,DoublePointer
- * cf)
- *
+ * 迴セ蝨ィ繧サ繝・ヨ縺輔l縺ヲ縺・kAR繧ウ繝シ繝峨→i_patt繧呈ッ碑シ・@縺セ縺吶€・
*/
- public void evaluate(NyARCode i_code)
+ public bool evaluate(NyARMatchPattDeviationColorData i_patt, NyARMatchPattResult o_result)
{
- int[,,,] pat = i_code.getPat();
- double[] patpow = i_code.getPatPow();
- int res = -1;
- double max = 0.0;
-// int[][][] pat_j, linput;
- int[, ,] linput;
-// int[][] pat_j_i, input_i;
-// int[] pat_j_i_k, input_i_k;
- int l_width = this.width;
- int l_height = this.height;
- linput = this.input;
+ Debug.Assert(this._code_patt != null);
+ //
+ int[] linput = i_patt.refData();
int sum;
- int i, k;
- double sum2;
+ double max = 0.0;
+ int res = NyARSquare.DIRECTION_UNKNOWN;
+ int for_mod = this._optimize_for_mod;
for (int j = 0; j < 4; j++)
{
+ //蜷郁ィ亥€、蛻晄悄蛹・
sum = 0;
-// pat_j = pat[j];
- for (i = l_height - 1; i >= 0; i--)
- {// for(int i=0;i<Config.AR_PATT_SIZE_Y;i++){
-// input_i = linput[i];
-// pat_j_i = pat_j[i];
- for (k = l_width - 1; k >= 0; k--)
- {
-// pat_j_i_k = pat_j_i[k];
-// input_i_k = input_i[k];
- // for(int i3=0;i3<3;i3++){
- sum += linput[i, k, 0] * pat[j, i, k, 0];//sum += input[i][i2][i3]*pat[k][j][i][i2][i3];
- sum += linput[i, k, 1] * pat[j, i, k, 1];//sum += input[i][i2][i3]*pat[k][j][i][i2][i3];
- sum += linput[i, k, 2] * pat[j, i, k, 2];//sum += input[i][i2][i3]*pat[k][j][i][i2][i3];
- // }
- }
+ NyARMatchPattDeviationColorData code_patt = this._code_patt.getColorData(j);
+ int[] pat_j = code_patt.refData();
+ //<蜈ィ逕サ邏縺ォ縺、縺・※縲∵ッ碑シ・FOR縺ョ1/16螻暮幕)>
+ int i;
+ for (i = this._rgbpixels - 1; i >= for_mod; i--)
+ {
+ sum += linput[i] * pat_j[i];
}
- sum2 = sum / patpow[j] / datapow;// sum2 = sum / patpow[k][j]/ datapow;
+ for (; i >= 0; )
+ {
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ sum += linput[i] * pat_j[i]; i--;
+ }
+ //<蜈ィ逕サ邏縺ォ縺、縺・※縲∵ッ碑シ・FOR縺ョ1/16螻暮幕)/>
+ double sum2 = sum / code_patt.getPow();// sum2 = sum / patpow[k][j]/ datapow;
if (sum2 > max)
{
max = sum2;
res = j;
}
}
- dir = res;
- cf = max;
+ o_result.direction = res;
+ o_result.confidence = max / i_patt.getPow();
+ return true;
}
}
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/match/INyARMatchPatt.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/match/INyARMatchPatt.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/match/INyARMatchPatt.cs (revision 252)
@@ -33,18 +33,11 @@
{

/**
- * ARColorPatt縺ョ繝槭ャ繝√Φ繧ー險育ョ励r縺吶k繧、繝ウ繧ソ繝輔ぉ繧、繧ケ縺ァ縺吶€・蝓コ貅鳳at縺ォ蟇セ縺励※縲∬ィ育ョ玲ク医∩縺ョARCode繝・・繧ソ縺ィ縺ョ髢薙〒豈碑シ・シ皮ョ励r縺励∪縺吶€・
- * pattern_match髢「謨ー繧貞・隗」縺励◆・鍋ィョ鬘槭・繝代ち繝シ繝ウ讀懷・繧ッ繝ゥ繧ケ繧貞ョ夂セゥ縺励∪縺吶€・
- *
+ * ARCode縺ィINyARColorPatt縺ョ髢薙〒荳€閾エ險育ョ励r縺吶k繧、繝ウ繧ソ繝輔ぉ繧、繧ケ縺ァ縺吶€・
*/
public interface INyARMatchPatt
{
- double getConfidence();
-
- int getDirection();
-
- void evaluate(NyARCode i_code);
-
- bool setPatt(INyARColorPatt i_target_patt);
+ void setARCode(NyARCode i_code);
}
+
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationBlackWhiteData.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationBlackWhiteData.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationBlackWhiteData.cs (revision 252)
@@ -0,0 +1,73 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * INyARMatchPatt縺ョColor蟾ョ蛻・Λ繧ケ繧ソ繧呈シ邏阪☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ *
+ */
+ public class NyARMatchPattDeviationBlackWhiteData
+ {
+ private int[] _data;
+ private double _pow;
+ //
+ private int _number_of_pixels;
+ public int[] refData()
+ {
+ return this._data;
+ }
+ public double getPow()
+ {
+ return this._pow;
+ }
+
+ public NyARMatchPattDeviationBlackWhiteData(int i_width, int i_height)
+ {
+ this._number_of_pixels = i_height * i_width;
+ this._data = new int[this._number_of_pixels];
+ return;
+ }
+ /**
+ * XRGB[width*height]縺ョ驟榊・縺九i縲√ヱ繧ソ繝シ繝ウ繝・・繧ソ繧呈ァ狗ッ峨€・
+ * @param i_buffer
+ */
+ public void setRaster(INyARRaster i_raster)
+ {
+ //i_buffer[XRGB]竊貞キョ蛻・BW]螟画鋤
+ int i;
+ int ave;//<PV/>
+ int rgb;//<PV/>
+ int[] linput = this._data;//<PV/>
+ int[] buf = (int[])i_raster.getBufferReader().getBuffer();
+
+ // input驟榊・縺ョ繧オ繧、繧コ縺ィwh繧よ峩譁ー// input=new int[height][width][3];
+ int number_of_pixels = this._number_of_pixels;
+
+ //<蟷ウ蝮・€、險育ョ・FOR縺ョ1/8螻暮幕)/>
+ ave = 0;
+ for (i = number_of_pixels - 1; i >= 0; i--)
+ {
+ rgb = buf[i];
+ ave += ((rgb >> 16) & 0xff) + ((rgb >> 8) & 0xff) + (rgb & 0xff);
+ }
+ ave = (number_of_pixels * 255 * 3 - ave) / (3 * number_of_pixels);
+ //
+ int sum = 0, w_sum;
+
+ //<蟾ョ蛻・€、險育ョ・>
+ for (i = number_of_pixels - 1; i >= 0; i--)
+ {
+ rgb = buf[i];
+ w_sum = ((255 * 3 - (rgb & 0xff) - ((rgb >> 8) & 0xff) - ((rgb >> 16) & 0xff)) / 3) - ave;
+ linput[i] = w_sum;
+ sum += w_sum * w_sum;
+ }
+ double p = Math.Sqrt((double)sum);
+ this._pow = p != 0.0 ? p : 0.0000001;
+ return;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/NyARSquare.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/NyARSquare.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/NyARSquare.cs (revision 252)
@@ -38,15 +38,15 @@
*/
public class NyARSquare
{
- public NyARLinear[] line = new NyARLinear[4];
- public NyARDoublePoint2d[] sqvertex = new NyARDoublePoint2d[4];
- public NyARIntPoint[] imvertex = new NyARIntPoint[4];
+ public const int DIRECTION_UNKNOWN=-1;
+ public int direction;
+ public NyARLinear[] line = NyARLinear.createArray(4);
+ public NyARDoublePoint2d[] sqvertex = NyARDoublePoint2d.createArray(4);
+ public NyARIntPoint2d[] imvertex = NyARIntPoint2d.createArray(4);
public NyARSquare()
{
for (int i = 0; i < 4; i++)
{
- this.sqvertex[i] = new NyARDoublePoint2d();
- this.imvertex[i] = new NyARIntPoint();
this.line[i] = new NyARLinear();
}
}
Index: forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator.cs (revision 252)
@@ -0,0 +1,76 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 驕霑第ウ輔r逕ィ縺・◆Perspective繝代Λ繝。繝シ繧ソ繧定ィ育ョ励☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ *
+ */
+ public class NyARPerspectiveParamGenerator
+ {
+ protected int _local_x;
+ protected int _local_y;
+ protected int _width;
+ protected int _height;
+ public NyARPerspectiveParamGenerator(int i_local_x, int i_local_y, int i_width, int i_height)
+ {
+ this._height = i_height;
+ this._width = i_width;
+ this._local_x = i_local_x;
+ this._local_y = i_local_y;
+ return;
+ }
+ public virtual bool getParam(NyARIntPoint2d[] i_vertex, double[] o_param)
+ {
+ double[][] la1, la2;
+ double[] ra1, ra2;
+ double ltx = this._local_x;
+ double lty = this._local_y;
+ double rbx = ltx + this._width;
+ double rby = lty + this._height;
+ la1 = ArrayUtils.newDouble2dArray(4, 5);//new double[4][5];
+ la2 = ArrayUtils.newDouble2dArray(4, 5);//new double[4][5];
+ ra1 = new double[4];
+ ra2 = new double[4];
+ //A,B,C,(GH)縺ョ譁ケ遞句シ・
+ la1[0][0] = ltx; la1[0][1] = lty; la1[0][2] = 1; la1[0][3] = -ltx * i_vertex[0].x; la1[0][4] = -lty * i_vertex[0].x;
+ la1[1][0] = rbx; la1[1][1] = lty; la1[1][2] = 1; la1[1][3] = -rbx * i_vertex[1].x; la1[1][4] = -lty * i_vertex[1].x;
+ la1[2][0] = rbx; la1[2][1] = rby; la1[2][2] = 1; la1[2][3] = -rbx * i_vertex[2].x; la1[2][4] = -rby * i_vertex[2].x;
+ la1[3][0] = ltx; la1[3][1] = rby; la1[3][2] = 1; la1[3][3] = -ltx * i_vertex[3].x; la1[3][4] = -rby * i_vertex[3].x;
+ ra1[0] = i_vertex[0].x; ra1[1] = i_vertex[1].x; ra1[2] = i_vertex[2].x; ra1[3] = i_vertex[3].x;
+ NyARSystemOfLinearEquationsProcessor.doGaussianElimination(la1, ra1, 5, 4);
+
+ //D,E,F,(GH)縺ョ譁ケ遞句シ・
+ la2[0][0] = ltx; la2[0][1] = lty; la2[0][2] = 1; la2[0][3] = -ltx * i_vertex[0].y; la2[0][4] = -lty * i_vertex[0].y;
+ la2[1][0] = rbx; la2[1][1] = lty; la2[1][2] = 1; la2[1][3] = -rbx * i_vertex[1].y; la2[1][4] = -lty * i_vertex[1].y;
+ la2[2][0] = rbx; la2[2][1] = rby; la2[2][2] = 1; la2[2][3] = -rbx * i_vertex[2].y; la2[2][4] = -rby * i_vertex[2].y;
+ la2[3][0] = ltx; la2[3][1] = rby; la2[3][2] = 1; la2[3][3] = -ltx * i_vertex[3].y; la2[3][4] = -rby * i_vertex[3].y;
+ ra2[0] = i_vertex[0].y; ra2[1] = i_vertex[1].y; ra2[2] = i_vertex[2].y; ra2[3] = i_vertex[3].y;
+ NyARSystemOfLinearEquationsProcessor.doGaussianElimination(la2, ra2, 5, 4);
+ //GH繧定ィ育ョ・
+ double A, B, C, D, E, F, G, H;
+ H = (ra2[3] - ra1[3]) / (la2[3][4] - la1[3][4]);
+ G = ra2[3] - la2[3][4] * H;
+ //谿九j繧定ィ育ョ・
+ F = ra2[2] - H * la2[2][4] - G * la2[2][3];
+ E = ra2[1] - H * la2[1][4] - G * la2[1][3] - F * la2[1][2];
+ D = ra2[0] - H * la2[0][4] - G * la2[0][3] - F * la2[0][2] - E * la2[0][1];
+ C = ra1[2] - H * la1[2][4] - G * la1[2][3];
+ B = ra1[1] - H * la1[1][4] - G * la1[1][3] - C * la1[1][2];
+ A = ra1[0] - H * la1[0][4] - G * la1[0][3] - C * la1[0][2] - B * la1[0][1];
+ o_param[0] = A;
+ o_param[1] = B;
+ o_param[2] = C;
+ o_param[3] = D;
+ o_param[4] = E;
+ o_param[5] = F;
+ o_param[6] = G;
+ o_param[7] = H;
+ return true;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/utils/NyARSystemOfLinearEquationsProcessor.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/utils/NyARSystemOfLinearEquationsProcessor.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/utils/NyARSystemOfLinearEquationsProcessor.cs (revision 252)
@@ -0,0 +1,169 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 騾」遶区婿遞句シ上r隗」縺上◆繧√・繝励Ο繧サ繝・し繧ッ繝ゥ繧ケ縺ァ縺吶€・
+ *
+ */
+ public class NyARSystemOfLinearEquationsProcessor
+ {
+ /**
+ * i_reft縺ィi_right縺ョ謨エ蜷域€ァ繧堤「コ隱阪@縺セ縺吶€・
+ * @param i_left
+ * @param i_right
+ * @return
+ */
+ private static bool isValid2dArray(double[][] i_left, double[] i_right)
+ {
+ int sm = i_left.Length;
+ int sn = i_left[0].Length;
+ if (i_left.Length != sm)
+ {
+ return false;
+ }
+ if (i_right.Length != sm)
+ {
+ return false;
+ }
+ for (int i = 1; i < sm; i++)
+ {
+ if (i_left[i].Length != sn)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * [i_left_src]=[i_right_src]縺ョ蠑上↓繧ャ繧ヲ繧ケ縺ョ豸亥悉豕輔r螳溯。後@縺ヲ縲ーx][x]縺ョ隕∫エ縺・縺ォ縺ェ繧九h縺・↓蝓コ譛ャ螟牙ス「縺励∪縺吶€・
+ * i_m縺ィi_n縺檎ュ峨@縺上↑縺・凾縺ッ縲∵怙邨り。後∪縺ァ縺ョ[x][x]隕∫エ縺セ縺ァ繧・縺ォ縺ェ繧九h縺・↓螟牙ス「縺励∪縺吶€・
+ * @param i_left
+ * 騾」遶区婿遞句シ上・蟾ヲ霎コ蛟、繧呈欠螳壹@縺セ縺吶€・i_m][i_n]縺ョ驟榊・繧呈欠螳壹@縺ヲ縺上□縺輔>縲・
+ * @param i_right
+ * 騾」遶区婿遞句シ上・蜿ウ霎コ蛟、繧呈欠螳壹@縺セ縺吶€・i_m][i_n]縺ョ驟榊・繧呈欠螳壹@縺ヲ縺上□縺輔>縲・
+ * @param i_n
+ * 騾」遶区婿遞句シ上・菫よ焚縺ョ謨ー繧呈欠螳壹@縺セ縺吶€・
+ * @param i_m
+ * 騾」遶区婿遞句シ上・謨ー繧呈欠螳壹@縺セ縺吶€・
+ * @return
+ * 譛€邨り。後∪縺ァ蝓コ譛ャ螟牙ス「縺後〒縺阪※縺ーtrue繧定ソ斐@縺セ縺吶€・
+ */
+ public static bool doGaussianElimination(double[][] i_left, double[] i_right, int i_n, int i_m)
+ {
+ //謨エ蜷域€ァ繧堤「コ隱阪☆繧・
+ Debug.Assert(isValid2dArray(i_left, i_right));
+
+
+ //1陦檎岼莉・髯・
+ for (int solve_row = 0; solve_row < i_m; solve_row++)
+ {
+ {//繝斐・繝・ヨ謫堺ス・
+ int pivod = solve_row;
+ double pivod_value = Math.Abs(i_left[pivod][pivod]);
+ for (int i = solve_row + 1; i < i_m; i++)
+ {
+ double pivod_2 = Math.Abs(i_left[i][pivod]);
+ if (pivod_value < Math.Abs(pivod_2))
+ {
+ pivod = i;
+ pivod_value = pivod_2;
+ }
+ }
+ if (solve_row != pivod)
+ {
+ //陦後・蜈・繧梧崛縺・C縺ョ譎ゅ・繝昴う繝ウ繧ソ繝・・繝悶Ν菴ソ縺」縺ヲ・・
+ double[] t = i_left[solve_row];
+ i_left[solve_row] = i_left[pivod];
+ i_left[pivod] = t;
+ double t2 = i_right[solve_row];
+ i_right[solve_row] = i_right[pivod];
+ i_right[pivod] = t2;
+ }
+ }
+ double[] dest_l_n = i_left[solve_row];
+ double dest_l_nn = i_left[solve_row][solve_row];
+ if (dest_l_nn == 0.0)
+ {
+ //驕ク謚槫セ後・蟇セ隗定ヲ∫エ縺・縺ォ縺ェ縺」縺ヲ縺励∪縺」縺溘i螟ア謨励☆繧九€・
+ return false;
+ }
+
+ //豸亥悉險育ョ・0 - solve_row-1鬆・∪縺ァ縺ョ豸亥悉)
+ for (int i = 0; i < solve_row; i++)
+ {
+ double s = dest_l_n[i];
+ for (int i2 = 0; i2 < i_n; i2++)
+ {
+ double p = i_left[i][i2] * s;
+ dest_l_n[i2] = dest_l_n[i2] - p;
+ }
+ double k = i_right[i] * s;
+ i_right[solve_row] = i_right[solve_row] - k;
+
+ }
+ //豸亥悉豕輔・螳溯。・蜑イ繧顔ョ・
+ double d = dest_l_n[solve_row];
+ for (int i2 = 0; i2 < solve_row; i2++)
+ {
+ dest_l_n[i2] = 0;
+ }
+ if (d != 1.0)
+ {
+ dest_l_n[solve_row] = 1.0;
+ for (int i = solve_row + 1; i < i_n; i++)
+ {
+ dest_l_n[i] /= d;
+ }
+ i_right[solve_row] /= d;
+ }
+ }
+ return true;
+ }
+ /**
+ * i_left縺ィi_right縺ョ騾」遶区婿遞句シ上r隗」縺・※縲(_left,i_right蜀・ョケ繧呈峩譁ー縺励∪縺吶€・
+ * i_right[n]縺ョ蜀・ョケ縺後€(_left[x][n]逡ェ逶ョ縺ョ菫よ焚縺ョ隗」縺ォ縺ェ繧翫∪縺吶€・
+ * @return
+ * 譁ケ遞句シ上′隗」縺代l縺ーtrue繧定ソ斐@縺セ縺吶€・
+ */
+ public static bool solve(double[][] i_left, double[] i_right, int i_number_of_system)
+ {
+ return doGaussianElimination(i_left, i_right, i_number_of_system, i_number_of_system);
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/utils/NyARDoubleMatrixProcessor.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/utils/NyARDoubleMatrixProcessor.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/utils/NyARDoubleMatrixProcessor.cs (revision 252)
@@ -0,0 +1,164 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARDoubleMatrixProcessor
+ {
+ /**
+ * i_src縺ョ騾・。悟・繧定ィ育ョ励@縺ヲ縲》his縺ク譬シ邏阪@縺セ縺吶€・
+ * @param i_src
+ * @return
+ */
+ public static bool inverse(NyARDoubleMatrix22 i_src, NyARDoubleMatrix22 o_dest)
+ {
+ double a11, a12, a21, a22;
+ a11 = i_src.m00;
+ a12 = i_src.m01;
+ a21 = i_src.m10;
+ a22 = i_src.m11;
+ double det = a11 * a22 - a12 * a21;
+ if (det == 0)
+ {
+ return false;
+ }
+ det = 1 / det;
+ o_dest.m00 = a22 * det;
+ o_dest.m01 = -a12 * det;
+ o_dest.m10 = a21 * det;
+ o_dest.m11 = -a11 * det;
+ return true;
+ }
+ public static bool inverse(NyARDoubleMatrix33 i_src, NyARDoubleMatrix33 o_dest)
+ {
+ /*i_src縺ョ騾・。悟・繧稚his縺ク譬シ邏阪☆繧九さ繝シ繝峨r譖ク縺上%縺ィ縲・/
+ NyARException.notImplement();
+ return false;
+ }
+ /**
+ * i_src縺ョ騾・。悟・繧定ィ育ョ励@縺ヲ縲∫オ先棡繧弛_dest縺ク繧サ繝・ヨ縺励∪縺吶€・
+ * @param i_src
+ * @return
+ */
+ public static bool inverse(NyARDoubleMatrix44 i_src, NyARDoubleMatrix44 o_dest)
+ {
+ double a11, a12, a13, a14, a21, a22, a23, a24, a31, a32, a33, a34, a41, a42, a43, a44;
+ double b11, b12, b13, b14, b21, b22, b23, b24, b31, b32, b33, b34, b41, b42, b43, b44;
+ double t1, t2, t3, t4, t5, t6;
+ a11 = i_src.m00; a12 = i_src.m01; a13 = i_src.m02; a14 = i_src.m03;
+ a21 = i_src.m10; a22 = i_src.m11; a23 = i_src.m12; a24 = i_src.m13;
+ a31 = i_src.m20; a32 = i_src.m21; a33 = i_src.m22; a34 = i_src.m23;
+ a41 = i_src.m30; a42 = i_src.m31; a43 = i_src.m32; a44 = i_src.m33;
+
+ t1 = a33 * a44 - a34 * a43;
+ t2 = a34 * a42 - a32 * a44;
+ t3 = a32 * a43 - a33 * a42;
+ t4 = a34 * a41 - a31 * a44;
+ t5 = a31 * a43 - a33 * a41;
+ t6 = a31 * a42 - a32 * a41;
+
+ b11 = a22 * t1 + a23 * t2 + a24 * t3;
+ b21 = -(a23 * t4 + a24 * t5 + a21 * t1);
+ b31 = a24 * t6 - a21 * t2 + a22 * t4;
+ b41 = -(a21 * t3 - a22 * t5 + a23 * t6);
+
+ t1 = a43 * a14 - a44 * a13;
+ t2 = a44 * a12 - a42 * a14;
+ t3 = a42 * a13 - a43 * a12;
+ t4 = a44 * a11 - a41 * a14;
+ t5 = a41 * a13 - a43 * a11;
+ t6 = a41 * a12 - a42 * a11;
+
+ b12 = -(a32 * t1 + a33 * t2 + a34 * t3);
+ b22 = a33 * t4 + a34 * t5 + a31 * t1;
+ b32 = -(a34 * t6 - a31 * t2 + a32 * t4);
+ b42 = a31 * t3 - a32 * t5 + a33 * t6;
+
+ t1 = a13 * a24 - a14 * a23;
+ t2 = a14 * a22 - a12 * a24;
+ t3 = a12 * a23 - a13 * a22;
+ t4 = a14 * a21 - a11 * a24;
+ t5 = a11 * a23 - a13 * a21;
+ t6 = a11 * a22 - a12 * a21;
+
+ b13 = a42 * t1 + a43 * t2 + a44 * t3;
+ b23 = -(a43 * t4 + a44 * t5 + a41 * t1);
+ b33 = a44 * t6 - a41 * t2 + a42 * t4;
+ b43 = -(a41 * t3 - a42 * t5 + a43 * t6);
+
+ t1 = a23 * a34 - a24 * a33;
+ t2 = a24 * a32 - a22 * a34;
+ t3 = a22 * a33 - a23 * a32;
+ t4 = a24 * a31 - a21 * a34;
+ t5 = a21 * a33 - a23 * a31;
+ t6 = a21 * a32 - a22 * a31;
+
+ b14 = -(a12 * t1 + a13 * t2 + a14 * t3);
+ b24 = a13 * t4 + a14 * t5 + a11 * t1;
+ b34 = -(a14 * t6 - a11 * t2 + a12 * t4);
+ b44 = a11 * t3 - a12 * t5 + a13 * t6;
+
+ double det_1 = (a11 * b11 + a21 * b12 + a31 * b13 + a41 * b14);
+ if (det_1 == 0)
+ {
+ return false;
+ }
+ det_1 = 1 / det_1;
+
+ o_dest.m00 = b11 * det_1;
+ o_dest.m01 = b12 * det_1;
+ o_dest.m02 = b13 * det_1;
+ o_dest.m03 = b14 * det_1;
+
+ o_dest.m10 = b21 * det_1;
+ o_dest.m11 = b22 * det_1;
+ o_dest.m12 = b23 * det_1;
+ o_dest.m13 = b24 * det_1;
+
+ o_dest.m20 = b31 * det_1;
+ o_dest.m21 = b32 * det_1;
+ o_dest.m22 = b33 * det_1;
+ o_dest.m23 = b34 * det_1;
+
+ o_dest.m30 = b41 * det_1;
+ o_dest.m31 = b42 * det_1;
+ o_dest.m32 = b43 * det_1;
+ o_dest.m33 = b44 * det_1;
+
+ return true;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator_O1.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator_O1.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator_O1.cs (revision 252)
@@ -0,0 +1,105 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * NyARPerspectiveParamGenerator繧呈怙驕ゥ蛹悶@縺溘け繝ゥ繧ケ縺ァ縺吶€・
+ */
+ public class NyARPerspectiveParamGenerator_O1 : NyARPerspectiveParamGenerator
+ {
+ public NyARPerspectiveParamGenerator_O1(int i_local_x, int i_local_y, int i_width, int i_height)
+ : base(i_local_x, i_local_y, i_width, i_height)
+ {
+ this._height = i_height;
+ this._width = i_width;
+ this._local_x = i_local_x;
+ this._local_y = i_local_y;
+ return;
+ }
+ public override bool getParam(NyARIntPoint2d[] i_vertex, double[] o_param)
+ {
+ double G, H;
+ double w1, w2, w3, w4;
+ double x0 = i_vertex[0].x;
+ double x1 = i_vertex[1].x;
+ double x2 = i_vertex[2].x;
+ double x3 = i_vertex[3].x;
+ double y0 = i_vertex[0].y;
+ double y1 = i_vertex[1].y;
+ double y2 = i_vertex[2].y;
+ double y3 = i_vertex[3].y;
+ double ltx = this._local_x;
+ double lty = this._local_y;
+ double rbx = ltx + this._width;
+ double rby = lty + this._height;
+
+
+ w1 = -y3 + y0;
+ w2 = y2 - y1;
+ double la2_33 = ltx * w1 + rbx * w2;//縺薙l縺・縺ォ縺ェ繧九・縺ッ縺セ縺壹>縲・
+ double la2_34 = (rby * (-y3 + y2) + lty * (y0 - y1)) / la2_33;
+ double ra2_3 = (-w1 - w2) / la2_33;
+
+ w1 = -x3 + x0;
+ w2 = x2 - x1;
+ double la1_33 = ltx * w1 + rbx * w2;//縺薙l縺・縺ォ縺ェ繧九・縺ッ縺セ縺壹>縲・
+
+ //GH繧定ィ育ョ・
+ H = (ra2_3 - ((-w1 - w2) / la1_33)) / (la2_34 - ((rby * (-x3 + x2) + lty * (x0 - x1)) / la1_33));
+ G = ra2_3 - la2_34 * H;
+ o_param[7] = H;
+ o_param[6] = G;
+
+ //谿九j繧定ィ育ョ・
+ w3 = rby - lty;
+ w4 = rbx - ltx;
+ w1 = (y2 - y1 - H * (-rby * y2 + lty * y1) - G * (-rbx * y2 + rbx * y1)) / w3;
+ w2 = (y1 - y0 - H * (-lty * y1 + lty * y0) - G * (-rbx * y1 + ltx * y0)) / w4;
+ o_param[5] = y0 * (1 + H * lty + G * ltx) - w1 * lty - w2 * ltx;
+ o_param[4] = w1;
+ o_param[3] = w2;
+
+
+ w1 = (x2 - x1 - H * (-rby * x2 + lty * x1) - G * (-rbx * x2 + rbx * x1)) / w3;
+ w2 = (x1 - x0 - H * (-lty * x1 + lty * x0) - G * (-rbx * x1 + ltx * x0)) / w4;
+ o_param[2] = x0 * (1 + H * lty + G * ltx) - w1 * lty - w2 * ltx;
+ o_param[1] = w1;
+ o_param[0] = w2;
+ return true;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BasicClass.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BasicClass.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BasicClass.cs (revision 252)
@@ -37,13 +37,28 @@
*
*
*/
- public abstract class NyARRgbRaster_BasicClass : NyARRaster_BasicClass,INyARRgbRaster
+ public abstract class NyARRgbRaster_BasicClass : INyARRgbRaster
{
+ protected NyARIntSize _size;
+ public int getWidth()
+ {
+ return this._size.w;
+ }
+
+ public int getHeight()
+ {
+ return this._size.h;
+ }
+
+ public NyARIntSize getSize()
+ {
+ return this._size;
+ }
protected NyARRgbRaster_BasicClass(NyARIntSize i_size)
- : base(i_size)
{
+ this._size = i_size;
}
-
public abstract INyARRgbPixelReader getRgbPixelReader();
+ public abstract INyARBufferReader getBufferReader();
}
}
Index: forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BGRA.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BGRA.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BGRA.cs (revision 252)
@@ -31,8 +31,7 @@
*/
namespace jp.nyatla.nyartoolkit.cs.core
{
-
- public class NyARRgbRaster_BGRA : NyARRgbRaster_BasicClass
+ public class NyARRgbRaster_BGRA : NyARRgbRaster_BasicClass, INyARRgbRaster
{
private class PixelReader : INyARRgbPixelReader
{
@@ -47,24 +46,25 @@
{
byte[] ref_buf = this._parent._ref_buf;
int bp = (i_x + i_y * this._parent._size.w) * 4;
- o_rgb[0] = ref_buf[bp + 2];// R
- o_rgb[1] = ref_buf[bp + 1];// G
- o_rgb[2] = ref_buf[bp + 0];// B
+ o_rgb[0] = (ref_buf[bp + 2] & 0xff);// R
+ o_rgb[1] = (ref_buf[bp + 1] & 0xff);// G
+ o_rgb[2] = (ref_buf[bp + 0] & 0xff);// B
return;
}

public void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] o_rgb)
{
+ int bp;
int width = _parent._size.w;
byte[] ref_buf = _parent._ref_buf;
- int bp;
for (int i = i_num - 1; i >= 0; i--)
{
bp = (i_x[i] + i_y[i] * width) * 4;
- o_rgb[i * 3 + 0] =ref_buf[bp + 2];// R
- o_rgb[i * 3 + 1] =ref_buf[bp + 1];// G
- o_rgb[i * 3 + 2] =ref_buf[bp + 0];// B
+ o_rgb[i * 3 + 0] = (ref_buf[bp + 2] & 0xff);// R
+ o_rgb[i * 3 + 1] = (ref_buf[bp + 1] & 0xff);// G
+ o_rgb[i * 3 + 2] = (ref_buf[bp + 0] & 0xff);// B
}
+ return;
}
}

@@ -77,7 +77,8 @@
return new NyARRgbRaster_BGRA(i_buffer, i_width, i_height);
}

- private NyARRgbRaster_BGRA(byte[] i_buffer, int i_width, int i_height): base(new NyARIntSize(i_width, i_height))
+ private NyARRgbRaster_BGRA(byte[] i_buffer, int i_width, int i_height)
+ : base(new NyARIntSize(i_width, i_height))
{
this._ref_buf = i_buffer;
this._rgb_reader = new PixelReader(this);
@@ -93,4 +94,5 @@
return this._buffer_reader;
}
}
+
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster.cs (revision 252)
@@ -0,0 +1,56 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**縺薙・繧ッ繝ゥ繧ケ縺ッ縲∝腰讖溯・縺ョNyARRaster縺ァ縺吶€・
+ * 迚ケ螳壹ち繧、繝励・繝舌ャ繝輔ぃ繧偵Λ繝・・縺吶k縲!NyARBufferReader繧、繝ウ繧ソ繝輔ぉ繧、繧ケ繧呈署萓帙@縺セ縺吶€・
+ *
+ */
+ public class NyARRaster : NyARRaster_BasicClass
+ {
+ private NyARBufferReader _reader;
+ public override INyARBufferReader getBufferReader()
+ {
+ return this._reader;
+ }
+ public NyARRaster(NyARIntSize i_size, object i_ref_buf, int i_buf_type)
+ : base(i_size)
+ {
+ this._reader=new NyARBufferReader(i_ref_buf,i_buf_type);
+ return;
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint.cs (revision 252)
@@ -31,12 +31,19 @@
*/
namespace jp.nyatla.nyartoolkit.cs.core
{
- public class NyARIntPoint
+ /**
+ * @deprecated このクラスは名称変更のため、削除されます。
+ * @see NyARIntPoint2d
+ */
+ [System.Obsolete("This class will be deleted. See NyARIntPoint2d.--このクラスは名称変更のため、削除されます。NyARIntPoint2dを使って下さい。")]
+ public class NyARIntPoint : NyARIntPoint2d
{
- public int x;
-
- public int y;
- public static NyARIntPoint[] createArray(int i_number)
+ /**
+ * 配列ファクトリ
+ * @param i_number
+ * @return
+ */
+ public new static NyARIntPoint[] createArray(int i_number)
{
NyARIntPoint[] ret = new NyARIntPoint[i_number];
for (int i = 0; i < i_number; i++)
Index: forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix44.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix44.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix44.cs (revision 252)
@@ -0,0 +1,113 @@
+・ソ/*
+ * PROJECT: NyARToolkit
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARDoubleMatrix44 : INyARDoubleMatrix
+ {
+ public double m00;
+ public double m01;
+ public double m02;
+ public double m03;
+ public double m10;
+ public double m11;
+ public double m12;
+ public double m13;
+ public double m20;
+ public double m21;
+ public double m22;
+ public double m23;
+ public double m30;
+ public double m31;
+ public double m32;
+ public double m33;
+ public static NyARDoubleMatrix44[] createArray(int i_number)
+ {
+ NyARDoubleMatrix44[] ret = new NyARDoubleMatrix44[i_number];
+ for (int i = 0; i < i_number; i++)
+ {
+ ret[i] = new NyARDoubleMatrix44();
+ }
+ return ret;
+ }
+ /**
+ * 驕・>縺九i縺ゅs縺セ繧贋スソ繧上↑縺・〒縺ュ縲・
+ */
+ public void setValue(double[] i_value)
+ {
+ this.m00 = i_value[0];
+ this.m01 = i_value[1];
+ this.m02 = i_value[2];
+ this.m03 = i_value[3];
+ this.m10 = i_value[4];
+ this.m11 = i_value[5];
+ this.m12 = i_value[6];
+ this.m13 = i_value[7];
+ this.m20 = i_value[8];
+ this.m21 = i_value[9];
+ this.m22 = i_value[10];
+ this.m23 = i_value[11];
+ this.m30 = i_value[12];
+ this.m31 = i_value[13];
+ this.m32 = i_value[14];
+ this.m33 = i_value[15];
+ return;
+ }
+ /**
+ * 驕・>縺九i縺ゅs縺セ繧贋スソ繧上↑縺・〒縺ュ縲・
+ */
+ public void getValue(double[] o_value)
+ {
+ o_value[0] = this.m00;
+ o_value[1] = this.m01;
+ o_value[2] = this.m02;
+ o_value[3] = this.m03;
+ o_value[4] = this.m10;
+ o_value[5] = this.m11;
+ o_value[6] = this.m12;
+ o_value[7] = this.m13;
+ o_value[8] = this.m20;
+ o_value[9] = this.m21;
+ o_value[10] = this.m22;
+ o_value[11] = this.m23;
+ o_value[12] = this.m30;
+ o_value[13] = this.m31;
+ o_value[14] = this.m32;
+ o_value[15] = this.m33;
+ return;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntPointStack.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntPointStack.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntPointStack.cs (revision 252)
@@ -35,7 +35,7 @@

public class NyARIntPointStack : NyObjectStack
{
- public NyARIntPointStack(int i_length): base(new NyARIntPoint[i_length])
+ public NyARIntPointStack(int i_length): base(new NyARIntPoint2d[i_length])
{
}

@@ -43,18 +43,18 @@
{
for (int i = i_start; i < i_end; i++)
{
- i_buffer[i] = new NyARIntPoint();
+ i_buffer[i] = new NyARIntPoint2d();
}
}

- new public NyARIntPoint[] getArray()
+ new public NyARIntPoint2d[] getArray()
{
- return (NyARIntPoint[])this._items;
+ return (NyARIntPoint2d[])this._items;
}

- new public NyARIntPoint prePush()
+ new public NyARIntPoint2d prePush()
{
- return (NyARIntPoint)base.prePush();
+ return (NyARIntPoint2d)base.prePush();
}
}
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint2d.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint2d.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint2d.cs (revision 252)
@@ -29,9 +29,10 @@
* <airmail(at)ebony.plala.or.jp>
*
*/
+using System;
+
namespace jp.nyatla.nyartoolkit.cs.core
{
-
public class NyARDoublePoint2d
{
public double x;
@@ -54,11 +55,45 @@
{
this.x = 0;
this.y = 0;
+ return;
}
public NyARDoublePoint2d(double i_x, double i_y)
{
this.x = i_x;
this.y = i_y;
+ return;
}
+ public NyARDoublePoint2d(NyARDoublePoint2d i_src)
+ {
+ this.x = i_src.x;
+ this.y = i_src.y;
+ return;
+ }
+ public NyARDoublePoint2d(NyARIntPoint2d i_src)
+ {
+ this.x = (double)i_src.x;
+ this.y = (double)i_src.y;
+ return;
+ }
+ public void setValue(NyARDoublePoint2d i_src)
+ {
+ this.x = i_src.x;
+ this.y = i_src.y;
+ return;
+ }
+ public void setValue(NyARIntPoint2d i_src)
+ {
+ this.x = (double)i_src.x;
+ this.y = (double)i_src.y;
+ return;
+ }
+ /**
+ * 譬シ邏榊€、繧偵・繧ッ繝医Ν縺ィ縺励※縲∬キ晞屬繧定ソ斐@縺セ縺吶€・
+ * @return
+ */
+ public double dist()
+ {
+ return Math.Sqrt(this.x * this.x + this.y + this.y);
+ }
}
}
Index: forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint2d.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint2d.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint2d.cs (revision 252)
@@ -0,0 +1,36 @@
+・ソusing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARIntPoint2d
+ {
+ public int x;
+
+ public int y;
+ /**
+ * 驟榊・繝輔ぃ繧ッ繝医Μ
+ * @param i_number
+ * @return
+ */
+ public static NyARIntPoint2d[] createArray(int i_number)
+ {
+ NyARIntPoint2d[] ret = new NyARIntPoint2d[i_number];
+ for (int i = 0; i < i_number; i++)
+ {
+ ret[i] = new NyARIntPoint2d();
+ }
+ return ret;
+ }
+ public static void copyArray(NyARIntPoint2d[] i_from, NyARIntPoint2d[] i_to)
+ {
+ for (int i = i_from.Length - 1; i >= 0; i--)
+ {
+ i_to[i].x = i_from[i].x;
+ i_to[i].y = i_from[i].y;
+ }
+ return;
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/core/types/NyARLinear.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/NyARLinear.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/types/NyARLinear.cs (revision 252)
@@ -36,6 +36,15 @@
public double rise;//y霆ク縺ョ蠅怜刈驥・
public double run;//x霆ク縺ョ蠅怜刈驥・
public double intercept;//蛻・援
+ public static NyARLinear[] createArray(int i_number)
+ {
+ NyARLinear[] ret = new NyARLinear[i_number];
+ for (int i = 0; i < i_number; i++)
+ {
+ ret[i] = new NyARLinear();
+ }
+ return ret;
+ }
public void copyFrom(NyARLinear i_source)
{
this.rise = i_source.rise;
Index: forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint3d.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint3d.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint3d.cs (revision 252)
@@ -51,7 +51,7 @@
}
return ret;
}
- public void copyFrom(NyARDoublePoint3d i_in)
+ public void setValue(NyARDoublePoint3d i_in)
{
this.x=i_in.x;
this.y=i_in.y;
Index: forFW2.0/NyARToolkitCS/cs/core/NyARCode.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/NyARCode.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/NyARCode.cs (revision 252)
@@ -31,276 +31,184 @@
*/
using System.IO;
using System;
+using System.Diagnostics;
namespace jp.nyatla.nyartoolkit.cs.core
{
- /**
- * ARToolKit縺ョ繝槭・繧ォ繝シ繧ウ繝シ繝峨r1蛟倶ソ晄戟縺励∪縺吶€・
- *
- */
- public class NyARCode
+ class NyARCodeFileReader
{
- private int[, , ,] pat;// static int pat[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];

- private double[] patpow = new double[4];// static double patpow[AR_PATT_NUM_MAX][4];
-
- private short[,,] patBW;// static int patBW[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];
-
- private double[] patpowBW = new double[4];// static double patpowBW[AR_PATT_NUM_MAX][4];
-
- private int width, height;
-
- public int[, , ,] getPat()
- {
- return pat;
- }
-
- public double[] getPatPow()
- {
- return patpow;
- }
-
- public short[,,] getPatBW()
- {
- return patBW;
- }
-
- public double[] getPatPowBW()
- {
- return patpowBW;
- }
-
- public int getWidth()
- {
- return width;
- }
-
- public int getHeight()
- {
- return height;
- }
-
- public NyARCode(int i_width, int i_height)
- {
- width = i_width;
- height = i_height;
- pat = new int[4, height, width, 3];// static int pat[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];
- patBW = new short[4, height, width];// static int patBW[AR_PATT_NUM_MAX][4][AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3];
- }
-
/**
- * int arLoadPatt( const char *filename ); ARToolKit縺ョ繝代ち繝シ繝ウ繝輔ぃ繧、繝ォ繧偵Ο繝シ繝峨☆繧九€・
- * 繝輔ぃ繧、繝ォ蠖「蠑上・BGR蠖「蠑上〒險倬鹸縺輔l縺溘ヱ繧ソ繝シ繝ウ繝輔ぃ繧、繝ォ縺ァ縺ゅk縺薙→縲・
- *
- * @param filename
- * @return
- * @throws Exception
+ * AR繧ウ繝シ繝峨ヵ繧。繧、繝ォ縺九i繝・・繧ソ繧定ェュ縺ソ霎シ繧薙〒o_raster[4]縺ォ譬シ邏阪@縺セ縺吶€・
+ * @param i_stream
+ * @param o_raster
+ * @throws NyARException
*/
- public void loadARPattFromFile(string filename)
+ public static void loadFromARToolKitFormFile(StreamReader i_stream, NyARRaster[] o_raster)
{
+ Debug.Assert(o_raster.Length == 4);
+ //4蛟九・隕∫エ繧偵Λ繧ケ繧ソ縺ォ繧サ繝・ヨ縺吶k縲・
try
{
- loadARPatt(new StreamReader(filename));
-
+ string[] data = i_stream.ReadToEnd().Split(new Char[] { ' ', '\r', '\n' });
+ //GBRA縺ァ荳€蠎ヲ隱ュ縺ソ縺縺吶€・
+ int idx = 0;
+ for (int h = 0; h < 4; h++)
+ {
+ Debug.Assert(o_raster[h].getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32));
+ NyARRaster ra = o_raster[h];
+ idx = readBlock(data, idx, ra.getWidth(), ra.getHeight(), (int[])ra.getBufferReader().getBuffer());
+ }
}
catch (Exception e)
{
throw new NyARException(e);
}
+ return;
}
-#if NyartoolkitCS_FRAMEWORK_CFW
/**
- *
+ * AR繧ウ繝シ繝峨ヵ繧。繧、繝ォ縺九i繝・・繧ソ繧定ェュ縺ソ霎シ繧薙〒o_code縺ォ譬シ邏阪@縺セ縺吶€・
* @param i_stream
+ * @param o_code
* @throws NyARException
*/
- public void loadARPatt(StreamReader i_stream)
+ public static void loadFromARToolKitFormFile(StreamReader i_stream, NyARCode o_code)
{
+ int width = o_code.getWidth();
+ int height = o_code.getHeight();
+ NyARRaster tmp_raster = new NyARRaster(new NyARIntSize(width, height), new int[width * height], INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);
+ //4蛟九・隕∫エ繧偵Λ繧ケ繧ソ縺ォ繧サ繝・ヨ縺吶k縲・
try
{
- string s = i_stream.ReadToEnd();
- String[] dt = s.Split(new Char[] { ' ', '\r', '\n' });
- int idx = 0;
- //繝代ち繝シ繝ウ繝・・繧ソ縺ッGBRA縺ァ荳ヲ繧薙〒繧九€・
+ int[] buf = (int[])tmp_raster.getBufferReader().getBuffer();
+ string[] data = i_stream.ReadToEnd().Split(new Char[] { ' ', '\r', '\n' });
+ //GBRA縺ァ荳€蠎ヲ隱ュ縺ソ縺縺吶€・
+ int idx=0;
for (int h = 0; h < 4; h++)
{
- int l = 0;
- for (int i3 = 0; i3 < 3; i3++)
- {
- for (int i2 = 0; i2 < height; i2++)
- {
- for (int i1 = 0; i1 < width; i1++)
- {
- short j;
- //謨ー蛟、縺ョ縺ソ隱ュ縺ソ蜃コ縺・遨コ譁・ュ励・隱ュ縺ソ鬟帙・縺暦シ・
-
- for (; ; )
- {
- if (dt[idx].Length > 0)
- {
- break;
- }
- idx++;
- }
- j = (short)(255 - int.Parse(dt[idx]));//j = 255-j;
- idx++;
- //讓呎コ悶ヵ繧。繧、繝ォ縺ョ繝代ち繝シ繝ウ縺ッBGR縺ァ縺ェ繧峨s縺ァ繧九°繧嘘GB縺ォ荳ヲ縺ケ縺ェ縺翫☆
- switch (i3)
- {
- case 0: pat[h, i2, i1, 2] = j; break;//pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+2] = j;break;
- case 1: pat[h, i2, i1, 1] = j; break;//pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+1] = j;break;
- case 2: pat[h, i2, i1, 0] = j; break;//pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+0] = j;break;
- }
- //pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+i3] = j;
- if (i3 == 0)
- {
- patBW[h, i2, i1] = j;//patBW[patno][h][i2*Config.AR_PATT_SIZE_X+i1] = j;
- }
- else
- {
- patBW[h, i2, i1] += j;//patBW[patno][h][i2*Config.AR_PATT_SIZE_X+i1] += j;
- }
- if (i3 == 2)
- {
- patBW[h, i2, i1] /= 3;//patBW[patno][h][i2*Config.AR_PATT_SIZE_X+i1] /= 3;
- }
- l += j;
- }
- }
- }
-
- l /= (height * width * 3);
-
- int m = 0;
- for (int i = 0; i < height; i++)
- {//for( i = 0; i < AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3; i++ ) {
- for (int i2 = 0; i2 < width; i2++)
- {
- for (int i3 = 0; i3 < 3; i3++)
- {
- pat[h, i, i2, i3] -= l;
- m += (pat[h, i, i2, i3] * pat[h, i, i2, i3]);
- }
- }
- }
- patpow[h] = Math.Sqrt((double)m);
- if (patpow[h] == 0.0)
- {
- patpow[h] = 0.0000001;
- }
-
- m = 0;
- for (int i = 0; i < height; i++)
- {
- for (int i2 = 0; i2 < width; i2++)
- {
- patBW[h, i, i2] -= (short)l;
- m += (patBW[h, i, i2] * patBW[h, i, i2]);
- }
- }
- patpowBW[h] = Math.Sqrt((double)m);
- if (patpowBW[h] == 0.0)
- {
- patpowBW[h] = 0.0000001;
- }
+ idx=readBlock(data,idx, width, height, buf);
+ //ARCode縺ォ繧サ繝・ヨ(繧ォ繝ゥ繝シ)
+ o_code.getColorData(h).setRaster(tmp_raster);
+ o_code.getBlackWhiteData(h).setRaster(tmp_raster);
}
}
catch (Exception e)
{
throw new NyARException(e);
}
+ tmp_raster = null;//繝昴う
+ return;
}
-#else
/**
- *
- * @param i_stream
- * @throws NyARException
+ * 1繝悶Ο繝・け蛻・・XRGB繝・・繧ソ繧段_st縺九io_buf縺ク隱ュ縺ソ縺縺励∪縺吶€・
+ * @param i_st
+ * @param o_buf
*/
- public void loadARPatt(StreamReader i_stream)
+ private static int readBlock(string[] i_data, int i_idx, int i_width, int i_height, int[] o_buf)
{
+ int idx = i_idx;
try
{
- string s = i_stream.ReadToEnd();
- string[] dt = s.Split(new Char[] { ' ', '\r', '\n' }, 10000, StringSplitOptions.RemoveEmptyEntries);
- int idx = 0;
- //繝代ち繝シ繝ウ繝・・繧ソ縺ッGBRA縺ァ荳ヲ繧薙〒繧九€・
- for (int h = 0; h < 4; h++)
+ int pixels = i_width * i_height;
+ for (int i3 = 0; i3 < 3; i3++)
{
- int l = 0;
- for (int i3 = 0; i3 < 3; i3++)
+ for (int i2 = 0; i2 < pixels; i2++)
{
- for (int i2 = 0; i2 < height; i2++)
+ //謨ー蛟、縺ョ縺ソ隱ュ縺ソ蜃コ縺・遨コ譁・ュ励・隱ュ縺ソ鬟帙・縺暦シ・
+ for (; ; )
{
- for (int i1 = 0; i1 < width; i1++)
+ if (i_data[idx].Length > 0)
{
- //謨ー蛟、縺ョ縺ソ隱ュ縺ソ蜃コ縺・
- short j = (short)(255 - int.Parse(dt[idx]));//j = 255-j;
- idx++;
- //讓呎コ悶ヵ繧。繧、繝ォ縺ョ繝代ち繝シ繝ウ縺ッBGR縺ァ縺ェ繧峨s縺ァ繧九°繧嘘GB縺ォ荳ヲ縺ケ縺ェ縺翫☆
- switch (i3)
- {
- case 0: pat[h, i2, i1, 2] = j; break;//pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+2] = j;break;
- case 1: pat[h, i2, i1, 1] = j; break;//pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+1] = j;break;
- case 2: pat[h, i2, i1, 0] = j; break;//pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+0] = j;break;
- }
- //pat[patno][h][(i2*Config.AR_PATT_SIZE_X+i1)*3+i3] = j;
- if (i3 == 0)
- {
- patBW[h, i2, i1] = j;//patBW[patno][h][i2*Config.AR_PATT_SIZE_X+i1] = j;
- }
- else
- {
- patBW[h, i2, i1] += j;//patBW[patno][h][i2*Config.AR_PATT_SIZE_X+i1] += j;
- }
- if (i3 == 2)
- {
- patBW[h, i2, i1] /= 3;//patBW[patno][h][i2*Config.AR_PATT_SIZE_X+i1] /= 3;
- }
- l += j;
+ break;
}
+ idx++;
}
+ o_buf[i2] = (o_buf[i2] << 8) | ((0x000000ff & (int)int.Parse(i_data[idx])));
+ idx++;
}
+ }
+ //GBR竊坦GB
+ for (int i3 = 0; i3 < pixels; i3++)
+ {
+ o_buf[i3] = ((o_buf[i3] << 16) & 0xff0000) | (o_buf[i3] & 0x00ff00) | ((o_buf[i3] >> 16) & 0x0000ff);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new NyARException(e);
+ }
+ return idx;
+ }
+ }

- l /= (height * width * 3);
+ /**
+ * ARToolKit縺ョ繝槭・繧ォ繝シ繧ウ繝シ繝峨r1蛟倶ソ晄戟縺励∪縺吶€・
+ *
+ */
+ public class NyARCode
+ {
+ private NyARMatchPattDeviationColorData[] _color_pat = new NyARMatchPattDeviationColorData[4];
+ private NyARMatchPattDeviationBlackWhiteData[] _bw_pat = new NyARMatchPattDeviationBlackWhiteData[4];
+ private int _width;
+ private int _height;

- int m = 0;
- for (int i = 0; i < height; i++)
- {//for( i = 0; i < AR_PATT_SIZE_Y*AR_PATT_SIZE_X*3; i++ ) {
- for (int i2 = 0; i2 < width; i2++)
- {
- for (int i3 = 0; i3 < 3; i3++)
- {
- pat[h, i, i2, i3] -= l;
- m += (pat[h, i, i2, i3] * pat[h, i, i2, i3]);
- }
- }
- }
- patpow[h] = Math.Sqrt((double)m);
- if (patpow[h] == 0.0)
- {
- patpow[h] = 0.0000001;
- }
+ public NyARMatchPattDeviationColorData getColorData(int i_index)
+ {
+ return this._color_pat[i_index];
+ }
+ public NyARMatchPattDeviationBlackWhiteData getBlackWhiteData(int i_index)
+ {
+ return this._bw_pat[i_index];
+ }
+ public int getWidth()
+ {
+ return _width;
+ }

- m = 0;
- for (int i = 0; i < height; i++)
- {
- for (int i2 = 0; i2 < width; i2++)
- {
- patBW[h, i, i2] -= (short)l;
- m += (patBW[h, i, i2] * patBW[h, i, i2]);
- }
- }
- patpowBW[h] = Math.Sqrt((double)m);
- if (patpowBW[h] == 0.0)
- {
- patpowBW[h] = 0.0000001;
- }
- }
+ public int getHeight()
+ {
+ return _height;
+ }
+ public NyARCode(int i_width, int i_height)
+ {
+ this._width = i_width;
+ this._height = i_height;
+ //遨コ縺ョ繝ゥ繧ケ繧ソ繧・蛟倶ス懈・
+ for (int i = 0; i < 4; i++)
+ {
+ this._color_pat[i] = new NyARMatchPattDeviationColorData(i_width, i_height);
+ this._bw_pat[i] = new NyARMatchPattDeviationBlackWhiteData(i_width, i_height);
}
+ return;
+ }
+ public void loadARPattFromFile(String filename)
+ {
+ try
+ {
+ loadARPatt(new StreamReader(filename));
+ }
catch (Exception e)
{
throw new NyARException(e);
}
+ return;
}
-#endif
+ public void setRaster(NyARRaster[] i_raster)
+ {
+ Debug.Assert(i_raster.Length != 4);
+ //繝ゥ繧ケ繧ソ縺ォ繝代ち繝シ繝ウ繧偵Ο繝シ繝峨☆繧九€・
+ for (int i = 0; i < 4; i++)
+ {
+ this._color_pat[i].setRaster(i_raster[i]);
+ }
+ return;
+ }
+
+ public void loadARPatt(StreamReader i_stream)
+ {
+ //繝ゥ繧ケ繧ソ縺ォ繝代ち繝シ繝ウ繧偵Ο繝シ繝峨☆繧九€・
+ NyARCodeFileReader.loadFromARToolKitFormFile(i_stream, this);
+ return;
+ }
+
}
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core/NyARVec.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core/NyARVec.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/core/NyARVec.cs (revision 252)
@@ -32,9 +32,6 @@
using System;
namespace jp.nyatla.nyartoolkit.cs.core
{
-
-
-
public class NyARVec
{
private int clm;
@@ -83,21 +80,22 @@
* @return
*/
public int arVecDisp()
- {
- NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- System.Console.WriteLine(" === vector (" + clm + ") ===\n");// printf(" ===
- // vector (%d)
- // ===\n",
- // v->clm);
- System.Console.Write(" |");// printf(" |");
- for (int c = 0; c < clm; c++) {// for( c = 0; c < v->clm; c++ ){
- System.Console.Write(" " + v[c]);// printf( " %10g", v->v[c] );
- }
- System.Console.WriteLine(" |");// printf(" |\n");
- System.Console.WriteLine(" ===================");// printf("
- // ===================\n");
- return 0;
- }
+ {
+ NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
+ Console.Out.WriteLine(" === vector (" + clm + ") ===\n");// printf(" ===
+ // vector (%d)
+ // ===\n",
+ // v->clm);
+ Console.Out.WriteLine(" |");// printf(" |");
+ for (int c = 0; c < clm; c++)
+ {// for( c = 0; c < v->clm; c++ ){
+ Console.Out.WriteLine(" " + v[c]);// printf( " %10g", v->v[c] );
+ }
+ Console.Out.WriteLine(" |");// printf(" |\n");
+ Console.Out.WriteLine(" ===================");// printf("
+ // ===================\n");
+ return 0;
+ }

/**
* arVecInnerproduct髢「謨ー縺ョ莉」譖ソ蜩・
@@ -164,121 +162,6 @@
return -s;
}

- // /**
- // * arVecTridiagonalize髢「謨ー縺ョ莉」譖ソ蜩・
- // * a,d,e髢薙〒貍皮ョ励r縺励※繧九€ゆス輔r縺ゥ縺・@縺ヲ縺・k縺九・縺輔▲縺ア繧翫&縺」縺ア繧・
- // * @param a
- // * @param d
- // * @param e
- // * @param i_e_start
- // * 貍皮ョ鈴幕蟋句・(繧医¥繧上°繧峨↑縺・¢縺ゥarVecTridiagonalize縺ョ蜻シ縺ウ蜃コ縺怜・縺ァ縺ェ繧薙°縺励※繧・
- // * @return
- // * @throws NyARException
- // */
- // public static void vecTridiagonalize(NyARMat a, NyARVec d, NyARVec e,int
- // i_e_start) throws NyARException
- // {
- // NyARVec vec,vec2;
- // double[][] a_array=a.getArray();
- // double s, t, p, q;
- // int dim;
- //
- // if(a.getClm()!=a.getRow()){
- // throw new NyARException();
- // }
- // if(a.getClm() != d.clm){
- // throw new NyARException();
- // }
- // if(a.getClm() != e.clm){
- // throw new NyARException();
- // }
- // dim = a.getClm();
- //
- // for(int k = 0; k < dim-2; k++ ){
- // vec=a.getRowVec(k);
- // // double[] vec_array=vec.getArray();
- // NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- // d.v[k]=vec.v[k];//d.set(k,v.get(k)); //d->v[k] = v[k];
- //
- // //wv1.clm = dim-k-1;
- // //wv1.v = &(v[k+1]);
- // NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- // e.v[k+i_e_start]=vec.vecHousehold(k+1);//e->v[k] = arVecHousehold(&wv1);
- // if(e.v[k+i_e_start]== 0.0 ){
- // continue;
- // }
- //
- // for(int i = k+1; i < dim; i++ ){
- // s = 0.0;
- // for(int j = k+1; j < i; j++ ) {
- // NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- // s += a_array[j][i] * vec.v[j];//s += a.get(j*dim+i) * v.get(j);//s +=
- // a->m[j*dim+i] * v[j];
- // }
- // for(int j = i; j < dim; j++ ) {
- // NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- // s += a_array[i][j] * vec.v[j];//s += a.get(i*dim+j) * v.get(j);//s +=
- // a->m[i*dim+j] * v[j];
- // }
- // NyARException.trap("譛ェ繝√ぉ繝・け縺ョ繝代せ");
- // d.v[i]=s;//d->v[i] = s;
- // }
- //
- //
- // //wv1.clm = wv2.clm = dim-k-1;
- // //wv1.v = &(v[k+1]);
- // //wv2.v = &(d->v[k+1]);
- // vec=a.getRowVec(k);
- // // vec_array=vec.getArray();
- // NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- // t = vec.vecInnerproduct(d,k+1)/ 2;
- // for(int i = dim-1; i > k; i-- ) {
- // NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- // p = vec.v[i];//p = v.get(i);//p = v[i];
- // d.v[i]-=t*p;q=d.v[i];//q = d->v[i] -= t*p・・
- // for(int j = i; j < dim; j++ ){
- // NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- // a_array[i][j]-=p*(d.v[j] + q*vec.v[j]);//a->m[i*dim+j] -= p*(d->v[j]) +
- // q*v[j];
- // }
- // }
- // }
- //
- // if( dim >= 2) {
- // d.v[dim-2]=a_array[dim-2][dim-2];//d->v[dim-2] =
- // a->m[(dim-2)*dim+(dim-2)];
- // e.v[dim-2+i_e_start]=a_array[dim-2][dim-1];//e->v[dim-2] =
- // a->m[(dim-2)*dim+(dim-1)];
- // }
- //
- // if( dim >= 1 ){
- // d.v[dim-1]=a_array[dim-1][dim-1];//d->v[dim-1] =
- // a->m[(dim-1)*dim+(dim-1)];
- // }
- //
- // for(int k = dim-1; k >= 0; k--) {
- // vec=a.getRowVec(k);//v = a.getPointer(k*dim);//v = &(a->m[k*dim]);
- // if( k < dim-2 ) {
- // for(int i = k+1; i < dim; i++ ){
- // //wv1.clm = wv2.clm = dim-k-1;
- // //wv1.v = &(v[k+1]);
- // //wv2.v = &(a->m[i*dim+k+1]);
- // vec2=a.getRowVec(i);
- //
- // t = vec.vecInnerproduct(vec2,k+1);
- // for(int j = k+1; j < dim; j++ ){
- // NyARException.trap("譛ェ繝√ぉ繝・け繝代せ");
- // a_array[i][j]-=t*vec.v[j];//a.subValue(i*dim+j,t*v.get(j));//a->m[i*dim+j]
- // -= t * v[j];
- // }
- // }
- // }
- // for(int i = 0; i < dim; i++ ){
- // vec.v[i]=0.0;//v.set(i,0.0);//v[i] = 0.0;
- // }
- // vec.v[k]=1;//v.set(k,1);//v[k] = 1;
- // }
- // }
/**
* 迴セ蝨ィ繝ゥ繝・・縺励※縺・k驟榊・繧貞叙繧雁、悶@縺ヲ縲∵眠縺励>驟榊・繧偵Λ繝・・縺励∪縺吶€・
*
@@ -291,4 +174,5 @@
this.clm = i_clm;
}
}
+
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/detector/NyARCustomSingleDetectMarker.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/detector/NyARCustomSingleDetectMarker.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/detector/NyARCustomSingleDetectMarker.cs (revision 252)
@@ -0,0 +1,253 @@
+・ソ/*
+ * PROJECT: NyARToolkitCS
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+
+namespace jp.nyatla.nyartoolkit.cs.detector
+{
+/**
+ * 逕サ蜒上°繧陰RCode縺ォ譛€繧ゆク€閾エ縺吶k繝槭・繧ォ繝シ繧・蛟区、懷・縺励€√◎縺ョ螟画鋤陦悟・繧定ィ育ョ励☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ * 螟画鋤陦悟・繧呈アゅa繧九↓縺ッ縲‥etectMarkerLite髢「謨ー縺ォ繝ゥ繧ケ繧ソ繧、繝。繝シ繧ク繧貞・蜉帙@縺ヲ縲∬ィ育ョ怜ッセ雎。縺ョ遏ゥ蠖「繧堤音螳壹@縺セ縺吶€・
+ * detectMarkerLite縺梧・蜉溘☆繧九→縲“etTransmationMatrix遲峨・髢「謨ー縺御スソ逕ィ蜿ッ閭ス縺ェ迥カ諷九↓縺ェ繧翫€∝、画鋤陦悟・繧呈アゅa繧九%縺ィ縺後〒縺阪∪縺吶€・
+ *
+ *
+ */
+ public class NyARCustomSingleDetectMarker
+ {
+ private const int AR_SQUARE_MAX = 100;
+
+ private bool _is_continue = false;
+ private NyARMatchPatt_Color_WITHOUT_PCA _match_patt;
+ private INyARSquareDetector _square_detect;
+
+ private NyARSquareStack _square_list = new NyARSquareStack(AR_SQUARE_MAX);
+
+ protected INyARTransMat _transmat;
+
+ private double _marker_width;
+ // 讀懷・邨先棡縺ョ菫晏ュ倡畑
+ private int _detected_direction;
+ private double _detected_confidence;
+ private NyARSquare _detected_square;
+ private INyARColorPatt _patt;
+ //逕サ蜃ヲ逅・畑
+ private NyARBinRaster _bin_raster;
+ protected INyARRasterFilter_RgbToBin _tobin_filter;
+
+ private NyARMatchPattDeviationColorData _deviation_data;
+ /**
+ * 讀懷・縺吶kARCode縺ィ繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ縺九i縲・蛟九・ARCode繧呈、懷・縺吶kNyARSingleDetectMarker繧、繝ウ繧ケ繧ソ繝ウ繧ケ繧剃ス懊j縺セ縺吶€・
+ *
+ * @param i_param
+ * 繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ繧呈欠螳壹@縺セ縺吶€・
+ * @param i_code
+ * 讀懷・縺吶kARCode繧呈欠螳壹@縺セ縺吶€・
+ * @param i_marker_width
+ * AR繧ウ繝シ繝峨・迚ゥ逅・し繧、繧コ繧偵€√Α繝ェ繝。繝シ繝医Ν縺ァ謖・ョ壹@縺セ縺吶€・
+ * @param i_filter
+ * RGB竊達IN螟画鋤繝輔ぅ繝ォ繧ソ繧呈欠螳壹@縺セ縺吶€・
+ * @throws NyARException
+ */
+ public NyARCustomSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width, INyARRasterFilter_RgbToBin i_filter)
+ {
+ NyARIntSize scr_size = i_param.getScreenSize();
+ // 隗」譫舌が繝悶ず繧ァ繧ッ繝医r菴懊k
+ this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
+ this._transmat = new NyARTransMat(i_param);
+ // 豈碑シ・さ繝シ繝峨r菫晏ュ・
+ this._marker_width = i_marker_width;
+ //繝代ち繝シ繝ウ繝斐ャ繧ッ繧「繝・・繧剃ス懈・
+ // this._patt = new NyARColorPatt_O1(i_code.getWidth(), i_code.getHeight());
+ this._patt = new NyARColorPatt_O3(i_code.getWidth(), i_code.getHeight());
+ // this._patt = new NyARColorPatt_Perspective(i_code.getWidth(), i_code.getHeight(),25);
+ //蜿門セ励ヱ繧ソ繝シ繝ウ縺ョ蟾ョ蛻・ョ繝シ繧ソ蝎ィ繧剃ス懈・
+ this._deviation_data = new NyARMatchPattDeviationColorData(i_code.getWidth(), i_code.getHeight());
+ //i_code逕ィ縺ョ隧穂セ。蝎ィ繧剃ス懈・
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);
+
+ //・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
+ this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ this._tobin_filter = i_filter;
+ return;
+ }
+
+ private NyARMatchPattResult __detectMarkerLite_mr = new NyARMatchPattResult();
+
+ /**
+ * i_image縺ォ繝槭・繧ォ繝シ讀懷・蜃ヲ逅・r螳溯。後@縲∫オ先棡繧定ィ倬鹸縺励∪縺吶€・
+ *
+ * @param i_raster
+ * 繝槭・繧ォ繝シ繧呈、懷・縺吶k繧、繝。繝シ繧ク繧呈欠螳壹@縺セ縺吶€ゅう繝。繝シ繧ク繧オ繧、繧コ縺ッ縲√き繝。繝ゥ繝代Λ繝。繝シ繧ソ
+ * 縺ィ荳€閾エ縺励※縺・↑縺代l縺ー縺ェ繧翫∪縺帙s縲・
+ * @return 繝槭・繧ォ繝シ縺梧、懷・縺ァ縺阪◆縺九r逵溷⊃蛟、縺ァ霑斐@縺セ縺吶€・
+ * @throws NyARException
+ */
+ public bool detectMarkerLite(INyARRgbRaster i_raster)
+ {
+ //繧オ繧、繧コ繝√ぉ繝・け
+ if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize()))
+ {
+ throw new NyARException();
+ }
+
+ //繝ゥ繧ケ繧ソ繧抵シ貞€、繧、繝。繝シ繧ク縺ォ螟画鋤縺吶k.
+ this._tobin_filter.doFilter(i_raster, this._bin_raster);
+
+
+ this._detected_square = null;
+ NyARSquareStack l_square_list = this._square_list;
+ // 繧ケ繧ッ繧ィ繧「繧ウ繝シ繝峨r謗「縺・
+ this._square_detect.detectMarker(this._bin_raster, l_square_list);
+
+
+ int number_of_square = l_square_list.getLength();
+ // 繧ウ繝シ繝峨・隕九▽縺九▲縺滂シ・
+ if (number_of_square < 1)
+ {
+ return false;
+ }
+
+ bool result = false;
+ NyARMatchPattResult mr = this.__detectMarkerLite_mr;
+ int square_index = 0;
+ int direction = NyARSquare.DIRECTION_UNKNOWN;
+ double confidence = 0;
+ for (int i = 0; i < number_of_square; i++)
+ {
+ // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
+ if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i)))
+ {
+ continue;
+ }
+ //蜿門セ励ヱ繧ソ繝シ繝ウ繧偵き繝ゥ繝シ蟾ョ蛻・ョ繝シ繧ソ縺ォ螟画鋤縺励※隧穂セ。縺吶k縲・
+ this._deviation_data.setRaster(this._patt);
+ if (!this._match_patt.evaluate(this._deviation_data, mr))
+ {
+ continue;
+ }
+ double c2 = mr.confidence;
+ if (confidence > c2)
+ {
+ continue;
+ }
+ // 繧ゅ▲縺ィ荳€閾エ縺吶k繝槭・繧ォ繝シ縺後≠縺」縺溘⊃縺・
+ square_index = i;
+ direction = mr.direction;
+ confidence = c2;
+ result = true;
+ }
+
+ // 繝槭・繧ォ繝シ諠・ア繧剃ソ晏ュ・
+ this._detected_square = (NyARSquare)l_square_list.getItem(square_index);
+ this._detected_direction = direction;
+ this._detected_confidence = confidence;
+ return result;
+ }
+
+ /**
+ * 讀懷・縺励◆繝槭・繧ォ繝シ縺ョ螟画鋤陦悟・繧定ィ育ョ励@縺ヲ縲{_result縺ク蛟、繧定ソ斐@縺セ縺吶€・
+ * 逶エ蜑阪↓螳溯。後@縺歸etectMarkerLite縺梧・蜉溘@縺ヲ縺・↑縺・→菴ソ縺医∪縺帙s縲・
+ *
+ * @param o_result
+ * 螟画鋤陦悟・繧貞女縺大叙繧九が繝悶ず繧ァ繧ッ繝医r謖・ョ壹@縺セ縺吶€・
+ * @throws NyARException
+ */
+ public void getTransmationMatrix(NyARTransMatResult o_result)
+ {
+ // 荳€逡ェ荳€閾エ縺励◆繝槭・繧ォ繝シ縺ョ菴咲スョ縺ィ縺九◎縺ョ霎コ繧定ィ育ョ・
+ if (this._is_continue)
+ {
+ this._transmat.transMatContinue(this._detected_square, this._detected_direction, this._marker_width, o_result);
+ }
+ else
+ {
+ this._transmat.transMat(this._detected_square, this._detected_direction, this._marker_width, o_result);
+ }
+ return;
+ }
+ /**
+ * 逕サ髱「荳翫・繝槭・繧ォ鬆らせ諠・ア繧帝・蛻励∈蜿門セ励@縺セ縺吶€・
+ * @param o_point
+ * 4隕∫エ莉・荳翫・驟榊・繧呈欠螳壹@縺ヲ荳九&縺・€ょ・鬆ュ縺ョ4隕∫エ縺ォ蛟、縺後さ繝斐・縺輔l縺セ縺吶€・
+ */
+ public void getSquarePosition(NyARIntPoint2d[] o_point)
+ {
+ NyARIntPoint2d.copyArray(this._detected_square.imvertex, o_point);
+ return;
+ }
+ /**
+ * 逕サ髱「荳翫・繝槭・繧ォ鬆らせ諠・ア繧帝・蛻励∈縺ョ繝ェ繝輔ぃ繝ャ繝ウ繧ケ繧定ソ斐@縺セ縺吶€・
+ * 霑斐&繧後◆繧ェ繝悶ず繧ァ繧ッ繝医・繧ッ繝ゥ繧ケ縺ォ謇€譛峨@邯壹¢繧峨l縺ヲ縺・∪縺吶€ゅけ繝ゥ繧ケ縺ョ繝。繝ウ繝宣未謨ー繧貞ョ溯。後☆繧九→蜀・ョケ縺梧嶌縺榊、峨o繧翫∪縺吶€・
+ * 螟夜Κ縺ァ繝・・繧ソ繧偵せ繝医ャ繧ッ縺吶k蝣エ蜷医・縲“etSquarePosition縺ァ隍・」ス縺励※荳九&縺・€・
+ * @return
+ */
+ public NyARIntPoint2d[] refSquarePosition()
+ {
+ return this._detected_square.imvertex;
+ }
+
+
+ /**
+ * 讀懷・縺励◆繝槭・繧ォ繝シ縺ョ荳€閾エ蠎ヲ繧定ソ斐@縺セ縺吶€・
+ *
+ * @return 繝槭・繧ォ繝シ縺ョ荳€閾エ蠎ヲ繧定ソ斐@縺セ縺吶€・・・縺セ縺ァ縺ョ蛟、繧偵→繧翫∪縺吶€・荳€閾エ蠎ヲ縺御ス弱>蝣エ蜷医↓縺ッ縲∬ェ、隱崎ュ倥・蜿ッ閭ス諤ァ縺碁ォ倥¥縺ェ繧翫∪縺吶€・
+ * @throws NyARException
+ */
+ public double getConfidence()
+ {
+ return this._detected_confidence;
+ }
+
+ /**
+ * 讀懷・縺励◆繝槭・繧ォ繝シ縺ョ譁ケ菴阪r霑斐@縺セ縺吶€・
+ *
+ * @return 0,1,2,3縺ョ菴輔l縺九r霑斐@縺セ縺吶€・
+ */
+ public int getDirection()
+ {
+ return this._detected_direction;
+ }
+
+ /**
+ * getTransmationMatrix縺ョ險育ョ励Δ繝シ繝峨r險ュ螳壹@縺セ縺吶€・蛻晄悄蛟、縺ッTRUE縺ァ縺吶€・
+ *
+ * @param i_is_continue
+ * TRUE縺ェ繧峨€》ransMatCont莠呈鋤縺ョ險育ョ励r縺励∪縺吶€・FALSE縺ェ繧峨€》ransMat莠呈鋤縺ョ險育ョ励r縺励∪縺吶€・
+ */
+ public void setContinueMode(bool i_is_continue)
+ {
+ this._is_continue = i_is_continue;
+ }
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/detector/NyARDetectMarker.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/detector/NyARDetectMarker.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/detector/NyARDetectMarker.cs (revision 252)
@@ -33,7 +33,6 @@

namespace jp.nyatla.nyartoolkit.cs.detector
{
-
class NyARDetectMarkerResult
{
public int arcode_id;
@@ -78,33 +77,30 @@

private bool _is_continue = false;

- private NyARMatchPatt_Color_WITHOUT_PCA _match_patt;
+ private NyARMatchPatt_Color_WITHOUT_PCA[] _match_patt;

private INyARSquareDetector _square_detect;

private NyARSquareStack _square_list = new NyARSquareStack(AR_SQUARE_MAX);

- private NyARCode[] _codes;
-
protected INyARTransMat _transmat;

private double[] _marker_width;

- private int _number_of_code;
-
// 讀懷・邨先棡縺ョ菫晏ュ倡畑
private INyARColorPatt _patt;

private NyARDetectMarkerResultHolder _result_holder = new NyARDetectMarkerResultHolder();
-
+ private NyARMatchPattDeviationColorData _deviation_data;
/**
* 隍・焚縺ョ繝槭・繧ォ繝シ繧呈、懷・縺励€∵怙繧ゆク€閾エ縺吶kARCode繧段_code縺九i讀懃エ「縺吶k繧ェ繝悶ず繧ァ繧ッ繝医r菴懊j縺セ縺吶€・
*
* @param i_param
* 繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ繧呈欠螳壹@縺セ縺吶€・
* @param i_code
- * 讀懷・縺吶k繝槭・繧ォ繝シ縺ョARCode驟榊・繧呈欠螳壹@縺セ縺吶€る・蛻苓ヲ∫エ縺ョ繧、繝ウ繝・ャ繧ッ繧ケ逡ェ蜿キ縺後€√◎縺ョ縺セ縺セgetARCodeIndex髢「謨ー縺ァ 蠕励i繧後kARCode繧、繝ウ繝・ャ繧ッ繧ケ縺ォ縺ェ繧翫∪縺吶€・萓九∴縺ー縲∬ヲ∫エ[1]縺ョARCode縺ォ荳€閾エ縺励◆繝槭・繧ォ繝シ縺ァ縺ゅk蝣エ蜷医・縲“etARCodeIndex縺ッ1繧定ソ斐@縺セ縺吶€・
- * 蜈磯ュ縺九ii_number_of_code蛟九・隕∫エ縺ォ縺ッ縲∵怏蜉ケ縺ェ蛟、繧呈欠螳壹☆繧句ソ・ヲ√′縺ゅj縺セ縺吶€・
+ * 讀懷・縺吶k繝槭・繧ォ繝シ縺ョARCode驟榊・繧呈欠螳壹@縺セ縺吶€・
+ * 驟榊・隕∫エ縺ョ繧、繝ウ繝・ャ繧ッ繧ケ逡ェ蜿キ縺後€√◎縺ョ縺セ縺セgetARCodeIndex髢「謨ー縺ァ蠕励i繧後kARCode繧、繝ウ繝・ャ繧ッ繧ケ縺ォ縺ェ繧翫∪縺吶€・
+ * 萓九∴縺ー縲∬ヲ∫エ[1]縺ョARCode縺ォ荳€閾エ縺励◆繝槭・繧ォ繝シ縺ァ縺ゅk蝣エ蜷医・縲“etARCodeIndex縺ッ1繧定ソ斐@縺セ縺吶€・
* @param i_marker_width
* i_code縺ョ繝槭・繧ォ繝シ繧オ繧、繧コ繧偵Α繝ェ繝。繝シ繝医Ν縺ァ謖・ョ壹@縺滄・蛻励r謖・ョ壹@縺セ縺吶€・蜈磯ュ縺九ii_number_of_code蛟九・隕∫エ縺ォ縺ッ縲∵怏蜉ケ縺ェ蛟、繧呈欠螳壹☆繧句ソ・ヲ√′縺ゅj縺セ縺吶€・
* @param i_number_of_code
@@ -117,33 +113,36 @@
// 隗」譫舌が繝悶ず繧ァ繧ッ繝医r菴懊k
this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
this._transmat = new NyARTransMat(i_param);
- // 豈碑シ・さ繝シ繝峨r菫晏ュ・
- this._codes = i_code;
- // 豈碑シ・さ繝シ繝峨・隗」蜒丞コヲ縺ッ蜈ィ驛ィ蜷後§縺九↑・滂シ磯&縺・→繝代ち繝シ繝ウ繧定、・焚遞ョ縺、縺上i縺ェ縺・→縺・¢縺ェ縺・°繧会シ・
+
+ //蜷・さ繝シ繝臥畑縺ョ豈碑シ・勣繧剃ス懊k縲・
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA[i_number_of_code];
int cw = i_code[0].getWidth();
int ch = i_code[0].getHeight();
+ this._match_patt[0] = new NyARMatchPatt_Color_WITHOUT_PCA(i_code[0]);
for (int i = 1; i < i_number_of_code; i++)
{
+ //隗」蜒丞コヲ繝√ぉ繝・け
if (cw != i_code[i].getWidth() || ch != i_code[i].getHeight())
{
- // 驕輔≧隗」蜒丞コヲ縺ョ縺梧キキ縺悶▲縺ヲ縺・k縲・
throw new NyARException();
}
+ this._match_patt[i] = new NyARMatchPatt_Color_WITHOUT_PCA(i_code[i]);
}
// 隧穂セ。繝代ち繝シ繝ウ縺ョ繝帙Ν繝€繧剃ス懊k
this._patt = new NyARColorPatt_O3(cw, ch);
- this._number_of_code = i_number_of_code;
-
+ //螳溘し繧、繧コ菫晏ュ・
this._marker_width = i_marker_width;
- // 隧穂セ。蝎ィ繧剃ス懊k縲・
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA();
+ //蟾ョ蛻・ョ繝シ繧ソ繧、繝ウ繧ケ繧ソ繝ウ繧ケ縺ョ菴懈・
+ this._deviation_data = new NyARMatchPattDeviationColorData(cw, ch);
//・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ return;
}

private NyARBinRaster _bin_raster;

private NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(100);
+ private NyARMatchPattResult __detectMarkerLite_mr = new NyARMatchPattResult();

/**
* i_image縺ォ繝槭・繧ォ繝シ讀懷・蜃ヲ逅・r螳溯。後@縲∫オ先棡繧定ィ倬鹸縺励∪縺吶€・
@@ -180,45 +179,41 @@
}
// 菫晄戟繝ェ繧ケ繝医・繧オ繧、繧コ繧定ェソ謨エ
this._result_holder.reservHolder(number_of_square);
+ NyARMatchPattResult mr = this.__detectMarkerLite_mr;

// 1繧ケ繧ッ繧ィ繧「豈弱↓縲∽ク€閾エ縺吶k繧ウ繝シ繝峨r豎コ螳壹@縺ヲ縺・¥
for (int i = 0; i < number_of_square; i++)
{
- NyARSquare square = l_square_list.getItem(i);
+ NyARSquare square = (NyARSquare)l_square_list.getItem(i);
+
// 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
if (!this._patt.pickFromRaster(i_raster, square))
{
// 繧、繝。繝シ繧ク縺ョ蛻・j蜃コ縺励・螟ア謨励☆繧九%縺ィ繧ゅ≠繧九€・
continue;
}
- // 繝代ち繝シ繝ウ繧定ゥ穂セ。蝎ィ縺ォ繧サ繝・ヨ
- if (!this._match_patt.setPatt(this._patt))
+ //蜿門セ励ヱ繧ソ繝シ繝ウ繧偵き繝ゥ繝シ蟾ョ蛻・ョ繝シ繧ソ縺ォ螟画鋤縺吶k縲・
+ this._deviation_data.setRaster(this._patt);
+ int square_index = 0;
+ int direction = NyARSquare.DIRECTION_UNKNOWN;
+ double confidence = 0;
+ for (int i2 = 0; i2 < this._match_patt.Length; i2++)
{
- // 險育ョ励↓螟ア謨励@縺溘€・
- throw new NyARException();
- }
- // 繧ウ繝シ繝峨→鬆・分縺ォ豈碑シ・@縺ヲ縺・¥
- int code_index = 0;
- _match_patt.evaluate(_codes[0]);
- double confidence = _match_patt.getConfidence();
- int direction = _match_patt.getDirection();
- for (int i2 = 1; i2 < this._number_of_code; i2++)
- {
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- _match_patt.evaluate(_codes[i2]);
- double c2 = _match_patt.getConfidence();
+ this._match_patt[i2].evaluate(this._deviation_data, mr);
+
+ double c2 = mr.confidence;
if (confidence > c2)
{
continue;
}
- // 繧医j荳€閾エ縺吶kARCode縺ョ諠・ア繧剃ソ晏ュ・
- code_index = i2;
- direction = _match_patt.getDirection();
+ // 繧ゅ▲縺ィ荳€閾エ縺吶k繝槭・繧ォ繝シ縺後≠縺」縺溘⊃縺・
+ square_index = i2;
+ direction = mr.direction;
confidence = c2;
}
- // i逡ェ逶ョ縺ョ繝代ち繝シ繝ウ諠・ア繧剃ソ晏ュ倥☆繧九€・
+ // i逡ェ逶ョ縺ョ繝代ち繝シ繝ウ諠・ア繧定ィ倬鹸縺吶k縲・
NyARDetectMarkerResult result = this._result_holder.result_array[i];
- result.arcode_id = code_index;
+ result.arcode_id = square_index;
result.confidence = confidence;
result.direction = direction;
result.ref_square = square;
@@ -297,6 +292,6 @@
{
this._is_continue = i_is_continue;
}
-
}
+
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/detector/NyARSingleDetectMarker.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/detector/NyARSingleDetectMarker.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/detector/NyARSingleDetectMarker.cs (revision 252)
@@ -34,196 +34,44 @@

namespace jp.nyatla.nyartoolkit.cs.detector
{
+/**
+ * 逕サ蜒上°繧陰RCode縺ォ譛€繧ゆク€閾エ縺吶k繝槭・繧ォ繝シ繧・蛟区、懷・縺励€√◎縺ョ螟画鋤陦悟・繧定ィ育ョ励☆繧九け繝ゥ繧ケ縺ァ縺吶€・
+ *
+ */
+public class NyARSingleDetectMarker : NyARCustomSingleDetectMarker
+{
+ /**
+ * 讀懷・縺吶kARCode縺ィ繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ縺九i縲・蛟九・ARCode繧呈、懷・縺吶kNyARSingleDetectMarker繧、繝ウ繧ケ繧ソ繝ウ繧ケ繧剃ス懊j縺セ縺吶€・
+ *
+ * @param i_param
+ * 繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ繧呈欠螳壹@縺セ縺吶€・
+ * @param i_code
+ * 讀懷・縺吶kARCode繧呈欠螳壹@縺セ縺吶€・
+ * @param i_marker_width
+ * AR繧ウ繝シ繝峨・迚ゥ逅・し繧、繧コ繧偵€√Α繝ェ繝。繝シ繝医Ν縺ァ謖・ョ壹@縺セ縺吶€・
+ * @throws NyARException
+ */
+ public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width)
+ : base(i_param, i_code, i_marker_width, new NyARRasterFilter_ARToolkitThreshold(100))
+ {
+ return;
+ }

- /**
- * 逕サ蜒上°繧陰RCode縺ォ譛€繧ゆク€閾エ縺吶k繝槭・繧ォ繝シ繧・蛟区、懷・縺励€√◎縺ョ螟画鋤陦悟・繧定ィ育ョ励☆繧九け繝ゥ繧ケ縺ァ縺吶€・
- *
- */
- public class NyARSingleDetectMarker
- {
- private const int AR_SQUARE_MAX = 100;

- private bool _is_continue = false;
- private NyARMatchPatt_Color_WITHOUT_PCA _match_patt;
- private INyARSquareDetector _square_detect;
+ /**
+ * i_image縺ォ繝槭・繧ォ繝シ讀懷・蜃ヲ逅・r螳溯。後@縲∫オ先棡繧定ィ倬鹸縺励∪縺吶€・
+ *
+ * @param i_raster
+ * 繝槭・繧ォ繝シ繧呈、懷・縺吶k繧、繝。繝シ繧ク繧呈欠螳壹@縺セ縺吶€ゅう繝。繝シ繧ク繧オ繧、繧コ縺ッ縲√き繝。繝ゥ繝代Λ繝。繝シ繧ソ
+ * 縺ィ荳€閾エ縺励※縺・↑縺代l縺ー縺ェ繧翫∪縺帙s縲・
+ * @return 繝槭・繧ォ繝シ縺梧、懷・縺ァ縺阪◆縺九r逵溷⊃蛟、縺ァ霑斐@縺セ縺吶€・
+ * @throws NyARException
+ */
+ public bool detectMarkerLite(INyARRgbRaster i_raster,int i_threshold)
+ {
+ ((NyARRasterFilter_ARToolkitThreshold)this._tobin_filter).setThreshold(i_threshold);
+ return base.detectMarkerLite(i_raster);
+ }
+}

- private NyARSquareStack _square_list = new NyARSquareStack(AR_SQUARE_MAX);
-
- private NyARCode _code;
-
- protected INyARTransMat _transmat;
-
- private double _marker_width;
-
- // 讀懷・邨先棡縺ョ菫晏ュ倡畑
- private int _detected_direction;
-
- private double _detected_confidence;
-
- private NyARSquare _detected_square;
-
- private INyARColorPatt _patt;
-
- /**
- * 讀懷・縺吶kARCode縺ィ繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ縺九i縲・蛟九・ARCode繧呈、懷・縺吶kNyARSingleDetectMarker繧、繝ウ繧ケ繧ソ繝ウ繧ケ繧剃ス懊j縺セ縺吶€・
- *
- * @param i_param
- * 繧ォ繝。繝ゥ繝代Λ繝。繝シ繧ソ繧呈欠螳壹@縺セ縺吶€・
- * @param i_code
- * 讀懷・縺吶kARCode繧呈欠螳壹@縺セ縺吶€・
- * @param i_marker_width
- * AR繧ウ繝シ繝峨・迚ゥ逅・し繧、繧コ繧偵€√Α繝ェ繝。繝シ繝医Ν縺ァ謖・ョ壹@縺セ縺吶€・
- * @throws NyARException
- */
- public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width)
- {
- NyARIntSize scr_size = i_param.getScreenSize();
- // 隗」譫舌が繝悶ず繧ァ繧ッ繝医r菴懊k
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
- this._transmat = new NyARTransMat(i_param);
- // 豈碑シ・さ繝シ繝峨r菫晏ュ・
- this._code = i_code;
- this._marker_width = i_marker_width;
- // 隧穂セ。繝代ち繝シ繝ウ縺ョ繝帙Ν繝€繧剃ス懊k
- this._patt = new NyARColorPatt_O3(_code.getWidth(), _code.getHeight());
- // 隧穂セ。蝎ィ繧剃ス懊k縲・
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA();
- //・貞€、逕サ蜒上ヰ繝・ヵ繧。繧剃ス懊k
- this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
- }
-
- NyARBinRaster _bin_raster;
- NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(100);
-
- /**
- * i_image縺ォ繝槭・繧ォ繝シ讀懷・蜃ヲ逅・r螳溯。後@縲∫オ先棡繧定ィ倬鹸縺励∪縺吶€・
- *
- * @param i_raster
- * 繝槭・繧ォ繝シ繧呈、懷・縺吶k繧、繝。繝シ繧ク繧呈欠螳壹@縺セ縺吶€ゅう繝。繝シ繧ク繧オ繧、繧コ縺ッ縲√き繝。繝ゥ繝代Λ繝。繝シ繧ソ
- * 縺ィ荳€閾エ縺励※縺・↑縺代l縺ー縺ェ繧翫∪縺帙s縲・
- * @return 繝槭・繧ォ繝シ縺梧、懷・縺ァ縺阪◆縺九r逵溷⊃蛟、縺ァ霑斐@縺セ縺吶€・
- * @throws NyARException
- */
- public bool detectMarkerLite(INyARRgbRaster i_raster, int i_threshold)
- {
- //繧オ繧、繧コ繝√ぉ繝・け
- if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize()))
- {
- throw new NyARException();
- }
-
- //繝ゥ繧ケ繧ソ繧抵シ貞€、繧、繝。繝シ繧ク縺ォ螟画鋤縺吶k.
- this._tobin_filter.setThreshold(i_threshold);
- this._tobin_filter.doFilter(i_raster, this._bin_raster);
-
-
- this._detected_square = null;
- NyARSquareStack l_square_list = this._square_list;
- // 繧ケ繧ッ繧ィ繧「繧ウ繝シ繝峨r謗「縺・
- this._square_detect.detectMarker(this._bin_raster, l_square_list);
-
-
- int number_of_square = l_square_list.getLength();
- // 繧ウ繝シ繝峨・隕九▽縺九▲縺滂シ・
- if (number_of_square < 1)
- {
- return false;
- }
-
- // 隧穂セ。蝓コ貅悶↓縺ェ繧九ヱ繧ソ繝シ繝ウ繧偵う繝。繝シ繧ク縺九i蛻・j蜃コ縺・
- if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(0)))
- {
- // 繝代ち繝シ繝ウ縺ョ蛻・j蜃コ縺励↓螟ア謨・
- return false;
- }
- // 繝代ち繝シ繝ウ繧定ゥ穂セ。蝎ィ縺ォ繧サ繝・ヨ
- if (!this._match_patt.setPatt(this._patt))
- {
- // 險育ョ励↓螟ア謨励@縺溘€・
- throw new NyARException();
- }
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- this._match_patt.evaluate(this._code);
- int square_index = 0;
- int direction = this._match_patt.getDirection();
- double confidence = this._match_patt.getConfidence();
- for (int i = 1; i < number_of_square; i++)
- {
- // 谺。縺ョ繝代ち繝シ繝ウ繧貞叙蠕・
- this._patt.pickFromRaster(i_raster, l_square_list.getItem(i));
- // 隧穂セ。蝎ィ縺ォ繧サ繝・ヨ縺吶k縲・
- this._match_patt.setPatt(this._patt);
- // 繧ウ繝シ繝峨→豈碑シ・☆繧・
- this._match_patt.evaluate(this._code);
- double c2 = this._match_patt.getConfidence();
- if (confidence > c2)
- {
- continue;
- }
- // 繧ゅ▲縺ィ荳€閾エ縺吶k繝槭・繧ォ繝シ縺後≠縺」縺溘⊃縺・
- square_index = i;
- direction = this._match_patt.getDirection();
- confidence = c2;
- }
- // 繝槭・繧ォ繝シ諠・ア繧剃ソ晏ュ・
- this._detected_square = l_square_list.getItem(square_index);
- this._detected_direction = direction;
- this._detected_confidence = confidence;
- return true;
- }
-
- /**
- * 讀懷・縺励◆繝槭・繧ォ繝シ縺ョ螟画鋤陦悟・繧定ィ育ョ励@縺ヲ縲{_result縺ク蛟、繧定ソ斐@縺セ縺吶€・
- * 逶エ蜑阪↓螳溯。後@縺歸etectMarkerLite縺梧・蜉溘@縺ヲ縺・↑縺・→菴ソ縺医∪縺帙s縲・
- *
- * @param o_result
- * 螟画鋤陦悟・繧貞女縺大叙繧九が繝悶ず繧ァ繧ッ繝医r謖・ョ壹@縺セ縺吶€・
- * @throws NyARException
- */
- public void getTransmationMatrix(NyARTransMatResult o_result)
- {
- // 荳€逡ェ荳€閾エ縺励◆繝槭・繧ォ繝シ縺ョ菴咲スョ縺ィ縺九◎縺ョ霎コ繧定ィ育ョ・
- if (this._is_continue)
- {
- this._transmat.transMatContinue(this._detected_square, this._detected_direction, this._marker_width, o_result);
- }
- else
- {
- this._transmat.transMat(this._detected_square, this._detected_direction, this._marker_width, o_result);
- }
- return;
- }
-
- /**
- * 讀懷・縺励◆繝槭・繧ォ繝シ縺ョ荳€閾エ蠎ヲ繧定ソ斐@縺セ縺吶€・
- *
- * @return 繝槭・繧ォ繝シ縺ョ荳€閾エ蠎ヲ繧定ソ斐@縺セ縺吶€・・・縺セ縺ァ縺ョ蛟、繧偵→繧翫∪縺吶€・荳€閾エ蠎ヲ縺御ス弱>蝣エ蜷医↓縺ッ縲∬ェ、隱崎ュ倥・蜿ッ閭ス諤ァ縺碁ォ倥¥縺ェ繧翫∪縺吶€・
- * @throws NyARException
- */
- public double getConfidence()
- {
- return this._detected_confidence;
- }
-
- /**
- * 讀懷・縺励◆繝槭・繧ォ繝シ縺ョ譁ケ菴阪r霑斐@縺セ縺吶€・
- *
- * @return 0,1,2,3縺ョ菴輔l縺九r霑斐@縺セ縺吶€・
- */
- public int getDirection()
- {
- return this._detected_direction;
- }
-
- /**
- * getTransmationMatrix縺ョ險育ョ励Δ繝シ繝峨r險ュ螳壹@縺セ縺吶€・蛻晄悄蛟、縺ッTRUE縺ァ縺吶€・
- *
- * @param i_is_continue
- * TRUE縺ェ繧峨€》ransMatCont莠呈鋤縺ョ險育ョ励r縺励∪縺吶€・FALSE縺ェ繧峨€》ransMat莠呈鋤縺ョ險育ョ励r縺励∪縺吶€・
- */
- public void setContinueMode(bool i_is_continue)
- {
- this._is_continue = i_is_continue;
- }
- }
}
\ No newline at end of file
Index: forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.cs (revision 252)
@@ -0,0 +1,278 @@
+・ソ/*
+ * PROJECT: NyARToolkit
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+using jp.nyatla.nyartoolkit.cs.core;
+
+namespace jp.nyatla.nyartoolkit.cs.core2
+{
+ /**
+ * 譏守せ縺ィ證礼せ繧単繧ソ繧、繝ォ豕輔〒讀懷・縺励※縲√◎縺ョ荳ュ螟ョ蛟、繧帝明蛟、縺ィ縺吶k縲・
+ *
+ *
+ */
+ public class NyARRasterThresholdAnalyzer_SlidePTile : INyARRasterThresholdAnalyzer
+ {
+ interface ICreateHistgramImpl
+ {
+ int createHistgramImpl(INyARBufferReader i_reader, NyARIntSize i_size, int[] o_histgram);
+ }
+ /**
+ * Glayscale(MAX256)縺ョ繝偵せ繝医げ繝ゥ繝險育ョ励け繝ゥ繧ケ
+ */
+ class CreateHistgramImpl_INT1D_GLAY_8 : ICreateHistgramImpl
+ {
+ public int _v_interval;
+ public CreateHistgramImpl_INT1D_GLAY_8(int i_v_interval)
+ {
+ this._v_interval = i_v_interval;
+ return;
+ }
+ public int createHistgramImpl(INyARBufferReader i_reader, NyARIntSize i_size, int[] o_histgram)
+ {
+ Debug.Assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));
+
+ int sum = 0;
+ int[] input = (int[])i_reader.getBuffer();
+ for (int y = i_size.h - 1; y >= 0; y -= this._v_interval)
+ {
+ sum += i_size.w;
+ int pt = y * i_size.w;
+ for (int x = i_size.w - 1; x >= 0; x--)
+ {
+ o_histgram[input[pt]]++;
+ pt++;
+ }
+ }
+ return sum;
+ }
+ }
+ class CreateHistgramImpl_BYTE1D_RGB_24 : ICreateHistgramImpl
+ {
+ private int _v_interval;
+ public CreateHistgramImpl_BYTE1D_RGB_24(int i_v_interval)
+ {
+ this._v_interval = i_v_interval;
+ return;
+ }
+ public int createHistgramImpl(INyARBufferReader i_reader, NyARIntSize i_size, int[] o_histgram)
+ {
+ Debug.Assert(
+ i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24)||
+ i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24));
+
+ byte[] input = (byte[])i_reader.getBuffer();
+ int pix_count = i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+ int sum = 0;
+ for (int y = i_size.h - 1; y >= 0; y -= this._v_interval)
+ {
+ sum += i_size.w;
+ int pt = y * i_size.w * 3;
+ int x, v;
+ for (x = pix_count - 1; x >= pix_mod_part; x--)
+ {
+ v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;
+ o_histgram[v]++;
+ pt += 3;
+ }
+ //繧ソ繧、繝ェ繝ウ繧ー
+ for (; x >= 0; x -= 8)
+ {
+ v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 3] & 0xff) + (input[pt + 4] & 0xff) + (input[pt + 5] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 6] & 0xff) + (input[pt + 7] & 0xff) + (input[pt + 8] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 9] & 0xff) + (input[pt + 10] & 0xff) + (input[pt + 11] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 12] & 0xff) + (input[pt + 13] & 0xff) + (input[pt + 14] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 15] & 0xff) + (input[pt + 16] & 0xff) + (input[pt + 17] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 18] & 0xff) + (input[pt + 19] & 0xff) + (input[pt + 20] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 21] & 0xff) + (input[pt + 22] & 0xff) + (input[pt + 23] & 0xff)) / 3;
+ o_histgram[v]++;
+ pt += 3 * 8;
+ }
+ }
+ return sum;
+ }
+ }
+ class CreateHistgramImpl_BYTE1D_B8G8R8X8_32 : ICreateHistgramImpl
+ {
+ private int _v_interval;
+ public CreateHistgramImpl_BYTE1D_B8G8R8X8_32(int i_v_interval)
+ {
+ this._v_interval = i_v_interval;
+ return;
+ }
+ public int createHistgramImpl(INyARBufferReader i_reader, NyARIntSize i_size, int[] o_histgram)
+ {
+ Debug.Assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));
+ byte[] input = (byte[])i_reader.getBuffer();
+ int pix_count = i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+ int sum = 0;
+ for (int y = i_size.h - 1; y >= 0; y -= this._v_interval)
+ {
+ sum += i_size.w;
+ int pt = y * i_size.w * 3;
+ int x, v;
+ for (x = pix_count - 1; x >= pix_mod_part; x--)
+ {
+ v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;
+ o_histgram[v]++;
+ pt += 4;
+ }
+ //繧ソ繧、繝ェ繝ウ繧ー
+ for (; x >= 0; x -= 8)
+ {
+ v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 4] & 0xff) + (input[pt + 5] & 0xff) + (input[pt + 6] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 8] & 0xff) + (input[pt + 9] & 0xff) + (input[pt + 10] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 12] & 0xff) + (input[pt + 13] & 0xff) + (input[pt + 14] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 16] & 0xff) + (input[pt + 17] & 0xff) + (input[pt + 18] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 20] & 0xff) + (input[pt + 21] & 0xff) + (input[pt + 22] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 24] & 0xff) + (input[pt + 25] & 0xff) + (input[pt + 26] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 28] & 0xff) + (input[pt + 29] & 0xff) + (input[pt + 30] & 0xff)) / 3;
+ o_histgram[v]++;
+ pt += 4 * 8;
+ }
+ }
+ return sum;
+ }
+ }
+ private int _persentage;
+ private int _threshold;
+ private ICreateHistgramImpl _histgram;
+
+ /**
+ * @param i_persentage
+ * 0<=50縺ァ縺ゅk縺薙→縲ら區/鮟偵・繝シ繧ォ繝シ縺ョ蝣エ蜷医・10・・0繧呈耳螂ィ 豁」縺ョ蝣エ蜷医€・サ堤せ繧貞渕貅悶↓縺励∪縺吶€・雋縺ョ蝣エ蜷医€∫區轤ケ繧貞渕貅悶↓縺励∪縺吶€・
+ * (CMOS繧ォ繝。繝ゥ縺ョ蝣エ蜷医€∝渕貅也せ縺ッ逋ス轤ケ縺ョ譁ケ縺瑚憶縺・
+ */
+ public NyARRasterThresholdAnalyzer_SlidePTile(int i_persentage, int i_raster_format, int i_vertical_interval)
+ {
+ Debug.Assert(0 <= i_persentage && i_persentage <= 50);
+ this._persentage = i_persentage;
+ switch (i_raster_format)
+ {
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
+ this._histgram = new CreateHistgramImpl_BYTE1D_RGB_24(i_vertical_interval);
+ break;
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8:
+ this._histgram = new CreateHistgramImpl_INT1D_GLAY_8(i_vertical_interval);
+ break;
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:
+ this._histgram = new CreateHistgramImpl_BYTE1D_B8G8R8X8_32(i_vertical_interval);
+ break;
+ default:
+ throw new NyARException();
+ }
+ }
+ public void setVerticalInterval(int i_step)
+ {
+ return;//譛ェ螳溯」・ク€蜿キ
+ }
+
+ private int[] _histgram_buf = new int[256];
+ public void analyzeRaster(INyARRaster i_input)
+ {
+ INyARBufferReader buffer_reader = i_input.getBufferReader();
+
+ int[] histgram = this._histgram_buf;
+ NyARIntSize size = i_input.getSize();
+
+ //譛€螟ァ逕サ蜒上し繧、繧コ縺ョ蛻カ髯・
+ Debug.Assert(size.w * size.h < 0x40000000);
+
+ //繝偵せ繝医げ繝ゥ繝蛻晄悄蛹・
+ for (int i = 0; i < 256; i++)
+ {
+ histgram[i] = 0;
+ }
+ int sum_of_pixel = this._histgram.createHistgramImpl(i_input.getBufferReader(), size, histgram);
+
+ // 髢セ蛟、繝斐け繧サ繝ォ謨ー遒コ螳・
+ int th_pixcels = sum_of_pixel * this._persentage / 100;
+ int th_wk;
+ int th_w, th_b;
+
+ // 鮟堤せ蝓コ貅・
+ th_wk = th_pixcels;
+ for (th_b = 0; th_b < 254; th_b++)
+ {
+ th_wk -= histgram[th_b];
+ if (th_wk <= 0)
+ {
+ break;
+ }
+ }
+ // 逋ス轤ケ蝓コ貅・
+ th_wk = th_pixcels;
+ for (th_w = 255; th_w > 1; th_w--)
+ {
+ th_wk -= histgram[th_w];
+ if (th_wk <= 0)
+ {
+ break;
+ }
+ }
+ // 髢セ蛟、縺ョ菫晏ュ・
+ this._threshold = (th_w + th_b) / 2;
+ return;
+ }
+ public int getThreshold()
+ {
+ return this._threshold;
+ }
+
+ public int getThreshold(int i_x, int i_y)
+ {
+ return this._threshold;
+ }
+ }
+
+}
Index: forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/INyARRasterThresholdAnalyzer.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/INyARRasterThresholdAnalyzer.cs (revision 0)
+++ forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/INyARRasterThresholdAnalyzer.cs (revision 252)
@@ -0,0 +1,45 @@
+・ソ/*
+ * PROJECT: NyARToolkit
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+
+
+namespace jp.nyatla.nyartoolkit.cs.core2
+{
+ public interface INyARRasterThresholdAnalyzer
+ {
+ void analyzeRaster(INyARRaster i_input);
+ int getThreshold();
+ }
+}
Index: forFW2.0/NyARToolkitCS/cs/NyARException.cs
===================================================================
--- forFW2.0/NyARToolkitCS/cs/NyARException.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/cs/NyARException.cs (revision 252)
@@ -34,19 +34,34 @@

namespace jp.nyatla.nyartoolkit.cs
{
- public class NyARException : Exception {
- public NyARException():base()
+ public class NyARException : Exception
+ {
+ public NyARException()
+ : base()
{
- }
- public NyARException(Exception e):base("",e)
+ return;
+ }
+
+ public NyARException(Exception e)
+ : base("NyARException", e)
{
- }
- public NyARException(String m):base(m)
+ return;
+ }
+
+ public NyARException(String m)
+ : base(m)
{
- }
- public static void trap(String m)
- {
- throw new NyARException("繝医Λ繝・・:"+m);
- }
+ return;
+ }
+
+ public static void trap(String m)
+ {
+ throw new NyARException("繝医Λ繝・・:" + m);
+ }
+
+ public static void notImplement()
+ {
+ throw new NyARException("Not Implement!");
+ }
}
}
Index: forFW2.0/NyARToolkitCS/Properties/Resources.Designer.cs
===================================================================
--- forFW2.0/NyARToolkitCS/Properties/Resources.Designer.cs (revision 222)
+++ forFW2.0/NyARToolkitCS/Properties/Resources.Designer.cs (revision 252)
@@ -8,7 +8,7 @@
// </auto-generated>
//------------------------------------------------------------------------------

-namespace jp.nyatla.nyartoolkit.cs.Properties {
+namespace jp.nyatla.nyartoolkit.Properties {
using System;


@@ -39,7 +39,7 @@
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("jp.nyatla.nyartoolkit.cs.Properties.Resources", typeof(Resources).Assembly);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("jp.nyatla.nyartoolkit.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
Index: forFW2.0/NyARToolkitCSUtils/Direct3d/NyARTexture_XRGB32.cs
===================================================================
--- forFW2.0/NyARToolkitCSUtils/Direct3d/NyARTexture_XRGB32.cs (revision 222)
+++ forFW2.0/NyARToolkitCSUtils/Direct3d/NyARTexture_XRGB32.cs (revision 252)
@@ -111,9 +111,10 @@
//繝・け繧ケ繝√Ε縺ョ繝斐ャ繝√▲縺ヲ菴包シ・
int cp_size = this.m_width * 4;
int sk_size = (this.m_texture_width - this.m_width) * 4;
- for (int r = this.m_height - 1; r >= 0; r--)
+ int s = 0;
+ for (int r = this.m_height - 1; r >= 0; r--,s++)
{
- texture_rect.Write(buf, r * cp_size, cp_size);
+ texture_rect.Write(buf, s * cp_size, cp_size);
texture_rect.Seek(sk_size, System.IO.SeekOrigin.Current);
}
}
@@ -124,5 +125,9 @@
}
return;
}
+ public void Dispose()
+ {
+ this.d3d_texture.Dispose();
+ }
}
}
Index: forFW2.0/NyARToolkitCSUtils/Direct3d/NyARSurface_XRGB32.cs
===================================================================
--- forFW2.0/NyARToolkitCSUtils/Direct3d/NyARSurface_XRGB32.cs (revision 222)
+++ forFW2.0/NyARToolkitCSUtils/Direct3d/NyARSurface_XRGB32.cs (revision 252)
@@ -39,7 +39,7 @@
/* DsXRGB32Raster縺ョ繝ゥ繧ケ繧ソ繝・・繧ソ繧貞叙繧願セシ繧€縺薙→縺悟・譚・繧鬼urface縺ァ縺吶€・
* 縺薙・Surface縺ッ縺昴・縺セ縺セARToolKit縺ョ閭梧勹謠冗判縺ォ菴ソ縺・∪縺吶€・
*/
- public class NyARSurface_XRGB32
+ public class NyARSurface_XRGB32:IDisposable
{
private int m_width;
private int m_height;
@@ -73,6 +73,7 @@
{
Debug.Assert(i_sample.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));
GraphicsStream gs = this.m_surface.LockRectangle(LockFlags.None);
+ /*
int cp_size = this.m_width * 4;
int s_idx=0;
int d_idx = (this.m_height - 1) * cp_size;
@@ -82,10 +83,16 @@
s_idx += cp_size;
d_idx -= cp_size;
}
+ */
+ Marshal.Copy((byte[])i_sample.getBufferReader().getBuffer(), 0, (IntPtr)((int)gs.InternalData), this.m_width * 4*this.m_height);
+
this.m_surface.UnlockRectangle();

return;
}
-
+ public void Dispose()
+ {
+ this.d3d_surface.Dispose();
+ }
}
}
Index: forFW2.0/NyARToolkitCSUtils/Capture/CaptureDevice.cs
===================================================================
--- forFW2.0/NyARToolkitCSUtils/Capture/CaptureDevice.cs (revision 222)
+++ forFW2.0/NyARToolkitCSUtils/Capture/CaptureDevice.cs (revision 252)
@@ -76,6 +76,12 @@
get { return m_video_info.BmiHeader.BitCount; }
}

+ public bool video_vertical_flip
+ {
+ //VideoFormat縺九i蜿悶k繧医≧縺ォ縺励↑縺・→窶ヲ縲・
+ get { return true;}
+ }
+
/**
* 繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ縺ョ繝代せ繧定ソ斐☆縲・
*/
Index: forFW2.0/NyARToolkitCSUtils/NyAR/DsBGRX32Raster.cs
===================================================================
--- forFW2.0/NyARToolkitCSUtils/NyAR/DsBGRX32Raster.cs (revision 222)
+++ forFW2.0/NyARToolkitCSUtils/NyAR/DsBGRX32Raster.cs (revision 252)
@@ -93,9 +93,26 @@
{
return this._buffer_reader;
}
- public void setBuffer(IntPtr i_buf)
+ public void setBuffer(IntPtr i_buf,bool i_flip_vertical)
{
- Marshal.Copy(i_buf, this._ref_buf, 0, this._ref_buf.Length);
+ if (i_flip_vertical)
+ {
+ //荳贋ク句渚霆「縺輔○繧・
+ int w = this._size.w*4;
+ int st = w * (this._size.h - 1);
+ int et = 0;
+ for (int i = this._size.h - 1; i >= 0; i--)
+ {
+ Marshal.Copy((IntPtr)((int)i_buf + et), this._ref_buf, st, w);
+ st -= w;
+ et += w;
+ }
+ }
+ else
+ {
+ //荳贋ク九r蜿崎サ「縺輔○縺ェ縺・€・
+ Marshal.Copy(i_buf, this._ref_buf, 0, this._ref_buf.Length);
+ }
return;
}
}
Index: forFW2.0/NyARToolkitCSUtils/NyAR/DsRGB565Raster.cs
===================================================================
--- forFW2.0/NyARToolkitCSUtils/NyAR/DsRGB565Raster.cs (revision 222)
+++ forFW2.0/NyARToolkitCSUtils/NyAR/DsRGB565Raster.cs (revision 252)
@@ -78,15 +78,13 @@
private INyARRgbPixelReader _rgb_reader;
private INyARBufferReader _buffer_reader;
private short[] _ref_buf;
- private bool _is_top_to_botomm;
- public DsRGB565Raster(int i_width, int i_height, bool i_is_top_to_botomm)
+ public DsRGB565Raster(int i_width, int i_height)
: base(new NyARIntSize(i_width, i_height))
{
if (i_width % 4 != 0)
{
throw new NyARException();
}
- this._is_top_to_botomm = i_is_top_to_botomm;
this._ref_buf = new short[i_height * i_width];
this._rgb_reader = new PixelReader(this);
this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE);
@@ -100,26 +98,26 @@
{
return this._buffer_reader;
}
- public void setBuffer(IntPtr i_buf)
+ public void setBuffer(IntPtr i_buf, bool i_flip_vertical)
{
- if (this._is_top_to_botomm)
+ if (i_flip_vertical)
{
- //荳贋ク九r蜿崎サ「縺輔○縺ェ縺・€・
- Marshal.Copy(i_buf, this._ref_buf, 0, this._ref_buf.Length);
- }
- else
- {
//荳贋ク句渚霆「縺輔○繧・
int w = this._size.w;
int st = w * (this._size.h - 1);
int et = 0;
for (int i = this._size.h - 1; i >= 0; i--)
{
- Marshal.Copy((IntPtr)((int)i_buf + et*2), this._ref_buf, st, w);
+ Marshal.Copy((IntPtr)((int)i_buf + et), this._ref_buf, st, w);
st -= w;
- et += w;
+ et += w*2;
}
}
+ else
+ {
+ //荳贋ク九r蜿崎サ「縺輔○縺ェ縺・€・
+ Marshal.Copy(i_buf, this._ref_buf, 0, this._ref_buf.Length);
+ }
return;
}

Index: forFW2.0/NyARToolkitCSUtils/NyAR/NyARD3dUtil.cs
===================================================================
--- forFW2.0/NyARToolkitCSUtils/NyAR/NyARD3dUtil.cs (revision 222)
+++ forFW2.0/NyARToolkitCSUtils/NyAR/NyARD3dUtil.cs (revision 252)
@@ -55,7 +55,7 @@
{
view_distance_max = i_new_value;
}
- /* 繧ォ繝。繝ゥ縺ョ繝励Ο繧ク繧ァ繧ッ繧キ繝ァ繝ウMatrix繧定ソ斐@縺セ縺吶€・
+ /* 繧ォ繝。繝ゥ縺ョ繝励Ο繧ク繧ァ繧ッ繧キ繝ァ繝ウMatrix(RH)繧定ソ斐@縺セ縺吶€・
* 縺薙・Matrix縺ッMicrosoft.DirectX.Direct3d.Device.Transform.Projection縺ォ險ュ螳壹〒縺阪∪縺吶€・
*/
public void toCameraFrustumRH(NyARParam i_arparam, ref Matrix o_d3d_projection)
@@ -116,8 +116,8 @@
o_d3d_projection.M24 = (float)(q[3, 1] * trans[0][1] + q[3, 1] * trans[1][1] + q[3, 2] * trans[2][1]);
o_d3d_projection.M31 = (float)(q[0, 2] * trans[0][2] + q[0, 1] * trans[1][2] + q[0, 2] * trans[2][2]);
o_d3d_projection.M32 = (float)(q[1, 2] * trans[0][2] + q[1, 1] * trans[1][2] + q[1, 2] * trans[2][2]);
- o_d3d_projection.M33 = -(float)(q[2, 2] * trans[0][2] + q[2, 1] * trans[1][2] + q[2, 2] * trans[2][2]);
- o_d3d_projection.M34 = -(float)(q[3, 2] * trans[0][2] + q[3, 1] * trans[1][2] + q[3, 2] * trans[2][2]);
+ o_d3d_projection.M33 = (float)(q[2, 2] * trans[0][2] + q[2, 1] * trans[1][2] + q[2, 2] * trans[2][2]);
+ o_d3d_projection.M34 = (float)(q[3, 2] * trans[0][2] + q[3, 1] * trans[1][2] + q[3, 2] * trans[2][2]);
o_d3d_projection.M41 = (float)(q[0, 3] * trans[0][3] + q[0, 1] * trans[1][3] + q[0, 2] * trans[2][3] + q[0, 3]);
o_d3d_projection.M42 = (float)(q[1, 3] * trans[0][3] + q[1, 1] * trans[1][3] + q[1, 2] * trans[2][3] + q[1, 3]);
o_d3d_projection.M43 = (float)(q[2, 3] * trans[0][3] + q[2, 1] * trans[1][3] + q[2, 2] * trans[2][3] + q[2, 3]);
@@ -126,23 +126,24 @@
}
public void toD3dMatrix(NyARTransMatResult i_ny_result,ref Matrix o_result)
{
- //AR縺ョMatrix繧奪irectX縺ョMatrix縺ォ螟画鋤
- o_result.M11 = (float)i_ny_result.m00;
- o_result.M12 = (float)i_ny_result.m10;
- o_result.M13 = (float)i_ny_result.m20;
- o_result.M14 = 0;
- o_result.M21 = (float)i_ny_result.m01;
- o_result.M22 = (float)i_ny_result.m11;
- o_result.M23 = (float)i_ny_result.m21;
- o_result.M24 = 0;
- o_result.M31 = (float)i_ny_result.m02;
- o_result.M32 = (float)i_ny_result.m12;
- o_result.M33 = (float)i_ny_result.m22;
- o_result.M34 = 0;
- o_result.M41 = (float)i_ny_result.m03;
- o_result.M42 = (float)i_ny_result.m13;
- o_result.M43 = (float)i_ny_result.m23;
- o_result.M44 = 1;
+ Matrix m;
+ m.M11 = (float)i_ny_result.m00;
+ m.M12 = -(float)i_ny_result.m10;
+ m.M13 = -(float)i_ny_result.m20;
+ m.M14 = 0;
+ m.M21 = (float)i_ny_result.m01;
+ m.M22 = -(float)i_ny_result.m11;
+ m.M23 = -(float)i_ny_result.m21;
+ m.M24 = 0;
+ m.M31 = (float)i_ny_result.m02;
+ m.M32 = -(float)i_ny_result.m12;
+ m.M33 = -(float)i_ny_result.m22;
+ m.M34 = 0;
+ m.M41 = (float)i_ny_result.m03;
+ m.M42 = -(float)i_ny_result.m13;
+ m.M43 = -(float)i_ny_result.m23;
+ m.M44 = 1;
+ o_result = m;
return;
}
}
Index: readme.ja.txt
===================================================================
--- readme.ja.txt (revision 222)
+++ readme.ja.txt (revision 252)
@@ -1,7 +1,7 @@
ARToolkit C# class library NyARToolkitCS.
Copyright (C)2008-2009 R.Iizuka

-version 2.2.0
+version 2.3.0

http://nyatla.jp/
airmail(at)ebony.plala.or.jp
@@ -13,7 +13,7 @@
NyARToolkitCS縺ッ縲∫エ皮イ九↑C#縺ョ縺ソ縺ァ螳溯」・@縺櫻yARToolkit莠呈鋤縺ョ
繧ッ繝ゥ繧ケ繝ゥ繧、繝悶Λ繝ェ縺ァ縺吶€・

-ARToolkit 2.72.1蜿翫・縲¨yARToolkit version 2.2.0
+ARToolkit 2.72.1蜿翫・縲¨yARToolkit version 2.3.0
繧偵・繝シ繧ケ縺ォ縺励※縺・∪縺吶€・

窶サNyARToolkit縺ョcore2繝代ャ繧ア繝シ繧ク縺ョ荳€驛ィ縺ッ螳溯」・&繧後※縺・∪縺帙s縲・
@@ -113,6 +113,8 @@
繧ュ繝」繝励メ繝」繝・ヰ繧、繧ケ縺ョ險ュ螳壹°繧峨・繝シ繧ォ繝シ縺ョ讀懷・蠕後・Direct3D縺ク縺ョ蜃コ蜉帙∪縺ァ縺ョ縲・
荳€騾」縺ョ豬√l繧定ソス縺・%縺ィ縺悟・譚・縺セ縺吶€・

+SingleNyIdMarkerDirect3d (./sample/SingleNyIdMarkerDirect3d)
+ ・醍ィョ鬘槭・NyId繝槭・繧ォ繧定ェ崎ュ倥☆繧九し繝ウ繝励Ν縺ァ縺吶€・



Index: extlib/NyWMCapture/LICENCE.txt
===================================================================
--- extlib/NyWMCapture/LICENCE.txt (revision 0)
+++ extlib/NyWMCapture/LICENCE.txt (revision 252)
@@ -0,0 +1,26 @@
+The MIT License
+
+NyWMCapture
+
+Copyright (c) 2008 nyatla
+airmail(at)ebony.plala.or.jp
+http://nyatla.jp/
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
Index: extlib/NyWMCapture/readme.ja.txt
===================================================================
--- extlib/NyWMCapture/readme.ja.txt (revision 0)
+++ extlib/NyWMCapture/readme.ja.txt (revision 252)
@@ -0,0 +1,79 @@
+・ソWindowsMobile逕ィ繧ュ繝」繝励メ繝」COM DLL.
+Copyright (C)2008 nyatla
+
+version 0.1.2
+
+http://nyatla.jp/
+airmail(at)ebony.plala.or.jp
+--------------------------------------------------
+
+
+繝サNyWMCapture
+
+NyARToolkit縺ッ縲仝indowsMobile逕ィ縺ョ繧ュ繝」繝励メ繝」謾ッ謠エCOM繧ェ繝悶ず繧ァ繧ッ繝医〒縺吶€・
+DirectShow縺九i繧ウ繝シ繝ォ繝舌ャ繧ッ髢「謨ー繧堤オ檎罰縺励※繧ュ繝」繝励メ繝」逕サ蜒上r蜿悶j霎シ繧€
+API繧呈署萓帙@縺セ縺吶€・
+
+
+繝サ髢狗匱迺ー蠅・
+ Visual Stadio 2008 Professional 莉・荳・
+ (2005縺ァ繧ゅ・繝ュ繧ク繧ァ繧ッ繝医r菴懊j逶エ縺帙・繧ウ繝ウ繝代う繝ォ縺ァ縺阪k縺九b・・
+
+
+繝サ繝・ぅ繝ャ繧ッ繝医Μ讒区・
+./build
+ 繝励Ο繧ク繧ァ繧ッ繝医ヵ繧。繧、繝ォ縺後≠繧翫∪縺吶€・
+./dll
+ 繧ウ繝ウ繝代う繝ォ貂医・dll縺後≠繧翫∪縺吶€ゅさ繝ウ繝代う繝ォ縺励◆dll繧ゅ%縺ョ繝・ぅ繝ャ繧ッ繝医Μ
+ 縺ォ蜃コ蜉帙&繧後∪縺吶€・
+./doc
+ 險ュ螳壼€、縺ェ縺ゥ縺ョ繝。繝「縺後≠繧翫∪縺吶€・
+./extlib
+ 螟夜Κ繝ゥ繧、繝悶Λ繝ェBaseClasses縺後≠繧翫∪縺吶€・
+ NyARToolkit繧医j蜈医↓繧ウ繝ウ繝代う繝ォ縺励※縺翫>縺ヲ縺上□縺輔>縲・
+ BaseClasses縺ョ繧ウ繝ウ繝代う繝ォ縺ッ縲・BaseClasses縺ョ繧ウ繝ウ繝代う繝ォ譁ケ豕・繧貞盾閠・↓
+ 縺励※縺上□縺輔>縲・
+./inc
+ DLL縺ョC++逕ィ縺ョ繝倥ャ繝€繝輔ぃ繧、繝ォ縺ァ縺吶€・
+./inc.cs
+ C#逕ィ縺ョ繝倥ャ繝€繝励Ο繧ク繧ァ繧ッ繝医〒縺吶€・
+./obj
+ 繧ェ繝悶ず繧ァ繧ッ繝医ヵ繧。繧、繝ォ縺ョ蜃コ蜉帙ヵ繧ゥ繝ォ繝€縺ァ縺吶€・
+./sample
+ 繧ュ繝」繝励メ繝」縺ョ繧オ繝ウ繝励Ν繝励Ο繧ー繝ゥ繝縺後≠繧翫∪縺吶€・
+ DLLTest C++縺ョ繧オ繝ウ繝励Ν繝励Ο繧ク繧ァ繧ッ繝医〒縺吶€・
+ DllTestCS C#縺ョ繧オ繝ウ繝励Ν繝励Ο繧ク繧ァ繧ッ繝医〒縺吶€・
+./src
+ 繧ス繝シ繧ケ繝輔ぃ繧、繝ォ縺後≠繧翫∪縺吶€・
+
+
+
+繝サBaseClasses縺ョ繧ウ繝ウ繝代う繝ォ譁ケ豕・
+莉伜ア槭・BaseClass繝励Ο繧ク繧ァ繧ッ繝医・繧ス繝シ繧ケ繝輔ぃ繧、繝ォ繧貞炎髯、縺励※縺ゅk縺ョ縺ァ縲・
+蛻・騾斐た繝シ繧ケ繝輔ぃ繧、繝ォ繧貞・謇九☆繧句ソ・ヲ√′縺ゅj縺セ縺吶€・
+
+BaseClasses縺ョ繧ス繝シ繧ケ繝輔ぃ繧、繝ォ縺ッ縲仝indowsCE Platform Builder縺ォ蜷ォ縺セ繧後※縺・k縺ョ縺ァ縲・
+隧穂セ。迚医r繝€繧ヲ繝ウ繝ュ繝シ繝峨@縺ヲ繧、繝ウ繧ケ繝医・繝ォ縺励※縺翫>縺ヲ荳九&縺・€・
+
+谺。縺ォ縲√う繝ウ繧ケ繝医・繝ォ繝・ぅ繝ャ繧ッ繝医Μ縺九i莉・荳九・繧医≧縺ォ繝輔ぃ繧、繝ォ繧偵さ繝斐・縺励∪縺吶€・
+
+.\WINCE500\PUBLIC\DIRECTX\SDK\SAMPLES\DSHOW\BASECLASSES\縺九i縲・cpp繝輔ぃ繧、繝ォ繧・
+./extlib/BaseClassesCE500/src縺ク繧ウ繝斐・縺励∪縺吶€・
+
+.\WINCE500\PUBLIC\DIRECTX\SDK\縺九i縲・h,.idl繝輔ぃ繧、繝ォ繧・
+./extlib/BaseClassesCE500/inc縺ク繧ウ繝斐・縺励∪縺吶€・
+
+繧ウ繝斐・縺励◆縺縺代〒縺ッ繧ウ繝ウ繝代う繝ォ繧ィ繝ゥ繝シ縺悟・繧九→諤昴≧縺ョ縺ァ縲・←蛻・↓菫ョ豁」繧偵@縺ヲ縺上□縺輔>縲・
+
+
+
+
+繝サ繝ゥ繧、繧サ繝ウ繧ケ
+NyWMCapture縺ッMIT繝ゥ繧、繧サ繝ウ繧ケ縺ァ驟榊ク・@縺ヲ縺・∪縺吶€・
+
+
+
+
+
+
+2008.07.22 nyatla
Index: extlib/NyWMCapture/dll/Windows Mobile 5.0 Pocket PC SDK (ARMV4I)/Release/NyWMCapture.dll
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: data/NyIdMarker.txt
===================================================================
--- data/NyIdMarker.txt (revision 0)
+++ data/NyIdMarker.txt (revision 252)
@@ -0,0 +1,5 @@
+Please check Data directory of NyARToolkit for Java.
+--
+NyIdMarkerの仕様書は、NyARToolkit for JavaのDataディレクトリにあります。
+http://svn.sourceforge.jp/view/NyARToolkit/trunk/Data/NyARIdMarkerFormat.odt?root=nyartoolkit&view=log
+
Index: data/NyIdMarker_template.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: data\NyIdMarker_template.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream

Index: data/320x240NyId.raw
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: data\320x240NyId.raw
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream