Download List

Sponsored link

System Requirements

System requirement is not defined

Released at 2009-10-15 20:36
NyARToolkit for C Sharp 2.4.0 (1 files Hide)

Release Notes

NyARToolkit for Java/2.4.0の機能に追従しています。

Changelog

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/SimpleLiteDirect3d.WindowsMobile5/SimpleLiteD3d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/SimpleLiteDirect3d.WindowsMobile5/SimpleLiteD3d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/SimpleLiteDirect3d.WindowsMobile5/SimpleLiteD3d.cs (revision 304)
@@ -153,17 +153,18 @@

//AR用のパターンコードを読み出
NyARCode code = i_resource.createNyARCode();
+ //ARラスタを作る(DirectShowキャプチャ仕様)。
+ this.m_raster = i_resource.createARRaster();

//1パターンのみを追跡するクラスを作成
- this.m_ar = new NyARSingleDetectMarker_X2(i_resource.ar_param, code, 80.0);
+ this.m_ar = new NyARSingleDetectMarker_X2(i_resource.ar_param, code, 80.0, this.m_raster.getBufferReader().getBufferType());
this._utils = new NyARD3dUtil();
//計算モードの設定
this.m_ar.setContinueMode(false);

////立方体(頂点数8)の準備

- //ARラスタを作る(DirectShowキャプチャ仕様)。
- this.m_raster = i_resource.createARRaster();
+
return;
}

@@ -204,7 +205,7 @@
this._capture.stop();
}

-
+/*
public bool InitializeApplication(NyARToolkitCS topLevelForm, ResourceBuilder i_resource)
{
NyMath.initialize();
@@ -218,16 +219,16 @@
//AR用のパターンコードを読み出
NyARCode code = i_resource.createNyARCode();

+ //ARラスタを作る(DirectShowキャプチャ仕様)。
+ this.m_raster = i_resource.createARRaster();
//1パターンのみを追跡するクラスを作成
- this.m_ar = new NyARSingleDetectMarker_X2(i_resource.ar_param, code, 80.0);
+ this.m_ar = new NyARSingleDetectMarker_X2(i_resource.ar_param, code, 80.0, this.m_raster.getBufferReader().getBufferType());
this._utils = new NyARD3dUtil();
//計算モードの設定
this.m_ar.setContinueMode(false);

- //ARラスタを作る(DirectShowキャプチャ仕様)。
- this.m_raster = i_resource.createARRaster();
return true;
- }
+ }*/
private bool is_marker_enable=false;
private Matrix trans_matrix = new Matrix();
private NyARTransMatResult trans_result = new NyARTransMatResult();
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/sample/RawTest/Program.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/sample/RawTest/Program.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/sample/RawTest/Program.cs (revision 304)
@@ -69,23 +69,26 @@

//1パターンのみを追跡するクラスを作成
// NyARSingleDetectMarker_Quad ar = new NyARSingleDetectMarker_Quad(ap, code, 80.0);
- NyARSingleDetectMarker_X2 ar = new NyARSingleDetectMarker_X2(ap, code, 80.0);
+ NyARSingleDetectMarker_X2 ar = new NyARSingleDetectMarker_X2(ap, code, 80.0,ra.getBufferReader().getBufferType());
NyARTransMatResult result_mat = new NyARTransMatResult();
ar.setContinueMode(false);
ar.detectMarkerLite(ra, 100);
ar.getTransmationMatrix(result_mat);

//マーカーを検出
- Stopwatch sw = new Stopwatch();
- sw.Start();
- for (int i = 0; i < 10; i++)
+ for (int i3 = 0; i3 < 10; i3++)
{
- //変換行列を取得
- //ar.detectMarkerLite(ra, 100);
- ar.getTransmationMatrix(result_mat);
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ for (int i = 0; i < 10; i++)
+ {
+ //変換行列を取得
+ ar.detectMarkerLite(ra, 100);
+ ar.getTransmationMatrix(result_mat);
+ }
+ sw.Stop();
+ Debug.WriteLine(sw.ElapsedMilliseconds + "[ms]");
}
- sw.Stop();
- Debug.WriteLine(sw.ElapsedMilliseconds + "[ms]");
return;
}
public static void main(String[] args)
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/NyARToolkitCS.WindowsMobile5.sandbox/NyARToolkitCS.WindowsMobile5.sandbox.csproj
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/NyARToolkitCS.WindowsMobile5.sandbox/NyARToolkitCS.WindowsMobile5.sandbox.csproj (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/NyARToolkitCS.WindowsMobile5.sandbox/NyARToolkitCS.WindowsMobile5.sandbox.csproj (revision 304)
@@ -84,15 +84,9 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARFixedFloatTransOffset.cs">
<Link>cs\x2\NyARFixedFloatTransOffset.cs</Link>
</Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARLabeling_ARToolKit_X2.cs">
- <Link>cs\x2\NyARLabeling_ARToolKit_X2.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARSingleDetectMarker_X2.cs">
<Link>cs\x2\NyARSingleDetectMarker_X2.cs</Link>
</Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARSquareDetector_X2.cs">
- <Link>cs\x2\NyARSquareDetector_X2.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARTransMat_X2.cs">
<Link>cs\x2\NyARTransMat_X2.cs</Link>
</Compile>
@@ -105,6 +99,21 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARFixedFloatObserv2IdealMap.cs">
<Link>cs\x2\NyARFixedFloatObserv2IdealMap.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARFixedFloatVertexCounter.cs">
+ <Link>cs\x2\NyARFixedFloatVertexCounter.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\SquareContourDetector_X2.cs">
+ <Link>cs\x2\SquareContourDetector_X2.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARSquareDetector_ARToolKit_X2.cs">
+ <Link>cs\x2\NyARSquareDetector_ARToolKit_X2.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\NyARSquareDetector_Rle_X2.cs">
+ <Link>cs\x2\NyARSquareDetector_Rle_X2.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS.sandbox\cs\x2\SingleARMarkerProcesser_X2.cs">
+ <Link>cs\x2\SingleARMarkerProcesser_X2.cs</Link>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/NyARToolkitCS.WindowsMobile5/NyARToolkitCS.WindowsMobile5.csproj
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/NyARToolkitCS.WindowsMobile5/NyARToolkitCS.WindowsMobile5.csproj (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forWM5/NyARToolkitCS.WindowsMobile5/NyARToolkitCS.WindowsMobile5.csproj (revision 304)
@@ -51,34 +51,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\INyARSquareDetector.cs">
- <Link>cs\core\INyARSquareDetector.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\INyARLabeling.cs">
- <Link>cs\core\labeling\INyARLabeling.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\INyARLabelingImage.cs">
- <Link>cs\core\labeling\INyARLabelingImage.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\NyARLabelingImage.cs">
- <Link>cs\core\labeling\NyARLabelingImage.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\NyARLabelingLabel.cs">
- <Link>cs\core\labeling\NyARLabelingLabel.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\NyARLabelingLabelStack.cs">
- <Link>cs\core\labeling\NyARLabelingLabelStack.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\NyARLabeling_ARToolKit.cs">
- <Link>cs\core\labeling\NyARLabeling_ARToolKit.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\match\INyARMatchPatt.cs">
<Link>cs\core\match\INyARMatchPatt.cs</Link>
</Compile>
<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>
@@ -91,19 +69,9 @@
<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>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARVertexCounter.cs">
- <Link>cs\core\NyARVertexCounter.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARSquareDetector.cs">
- <Link>cs\core\NyARSquareDetector.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARSquareStack.cs">
- <Link>cs\core\NyARSquareStack.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\param\NyARCameraDistortionFactor.cs">
<Link>cs\core\param\NyARCameraDistortionFactor.cs</Link>
</Compile>
@@ -128,21 +96,6 @@
<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>
@@ -167,16 +120,12 @@
<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 Include="..\..\forFW2.0\NyARToolkitCS\cs\core\rasterreader\NyARRgbPixelReader_INT1D_GRAY_8.cs">
+ <Link>cs\core\rasterreader\NyARRgbPixelReader_INT1D_GRAY_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>
@@ -189,14 +138,12 @@
<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>
@@ -212,9 +159,6 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\raster\rgb\NyARRgbRaster_RGB.cs">
<Link>cs\core\raster\rgb\NyARRgbRaster_RGB.cs</Link>
</Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\fitveccalc\NyARFitVecCalculator.cs">
- <Link>cs\core\transmat\fitveccalc\NyARFitVecCalculator.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\INyARTransMat.cs">
<Link>cs\core\transmat\INyARTransMat.cs</Link>
</Compile>
@@ -227,24 +171,19 @@
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\NyARTransOffset.cs">
<Link>cs\core\transmat\NyARTransOffset.cs</Link>
</Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\optimize\INyARRotTransOptimize.cs">
- <Link>cs\core\transmat\optimize\INyARRotTransOptimize.cs</Link>
- </Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\optimize\NyARRotTransOptimize.cs">
- <Link>cs\core\transmat\optimize\NyARRotTransOptimize.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\rotmatrix\NyARRotMatrix.cs">
<Link>cs\core\transmat\rotmatrix\NyARRotMatrix.cs</Link>
</Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\rotmatrix\NyARRotMatrix_ARToolKit.cs">
<Link>cs\core\transmat\rotmatrix\NyARRotMatrix_ARToolKit.cs</Link>
</Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\rotmatrix\NyARRotMatrix_NyARToolKit.cs">
- <Link>cs\core\transmat\rotmatrix\NyARRotMatrix_NyARToolKit.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\rotmatrix\NyARRotVector.cs">
<Link>cs\core\transmat\rotmatrix\NyARRotVector.cs</Link>
</Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\rotmatrix\NyARRotMatrix_ARToolKit_O2.cs">
+ <Link>cs\core\transmat\rotmatrix\NyARRotMatrix_ARToolKit_O2.cs</Link>
+ </Compile>
+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\types\matrix\INyARDoubleMatrix.cs">
<Link>cs\core\types\matrix\INyARDoubleMatrix.cs</Link>
</Compile>
@@ -260,7 +199,6 @@
<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>
@@ -282,17 +220,12 @@
<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>
@@ -303,16 +236,17 @@
<Link>cs\core\utils\NyARSystemOfLinearEquationsProcessor.cs</Link>
</Compile>

+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\utils\NyAREquationSolver.cs">
+ <Link>cs\core\utils\NyAREquationSolver.cs</Link>
+ </Compile>

+
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\NyARException.cs">
<Link>cs\NyARException.cs</Link>
</Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARMat.cs">
<Link>cs\core\NyARMat.cs</Link>
</Compile>
- <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARSquare.cs">
- <Link>cs\core\NyARSquare.cs</Link>
- </Compile>
<Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\NyARVersion.cs">
<Link>cs\core\NyARVersion.cs</Link>
</Compile>
@@ -328,7 +262,6 @@
<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>
@@ -338,7 +271,6 @@
<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>
@@ -351,15 +283,12 @@
<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>
@@ -399,17 +328,108 @@
<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="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\artoolkit\NyARLabeling_ARToolKit.cs">
+ <Link>cs\core\labeling\artoolkit\NyARLabeling_ARToolKit.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\artoolkit\NyARLabelingImage.cs">
+ <Link>cs\core\labeling\artoolkit\NyARLabelingImage.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\artoolkit\NyARLabelingLabel.cs">
+ <Link>cs\core\labeling\artoolkit\NyARLabelingLabel.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\artoolkit\NyARLabelingLabelStack.cs">
+ <Link>cs\core\labeling\artoolkit\NyARLabelingLabelStack.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\rlelabeling\NyARLabeling_Rle.cs">
+ <Link>cs\core\labeling\rlelabeling\NyARLabeling_Rle.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\rlelabeling\RleLabelFragmentInfoStack.cs">
+ <Link>cs\core\labeling\rlelabeling\RleLabelFragmentInfoStack.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\LabelOverlapChecker.cs">
+ <Link>cs\core\labeling\LabelOverlapChecker.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\NyARLabelInfo.cs">
+ <Link>cs\core\labeling\NyARLabelInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\labeling\NyARLabelInfoStack.cs">
+ <Link>cs\core\labeling\NyARLabelInfoStack.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\pickup\NyARColorPatt_Perspective_O2.cs">
+ <Link>cs\core\pickup\NyARColorPatt_Perspective_O2.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\ContourPickup.cs">
+ <Link>cs\core\squaredetect\ContourPickup.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\INyARSquareDetector.cs">
+ <Link>cs\core\squaredetect\INyARSquareDetector.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\NyARSquare.cs">
+ <Link>cs\core\squaredetect\NyARSquare.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\NyARSquareDetector_ARToolKit.cs">
+ <Link>cs\core\squaredetect\NyARSquareDetector_ARToolKit.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\NyARSquareDetector_Rle.cs">
+ <Link>cs\core\squaredetect\NyARSquareDetector_Rle.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\NyARSquareStack.cs">
+ <Link>cs\core\squaredetect\NyARSquareStack.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\NyARVertexCounter.cs">
+ <Link>cs\core\squaredetect\NyARVertexCounter.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\squaredetect\SquareContourDetector.cs">
+ <Link>cs\core\squaredetect\SquareContourDetector.cs</Link>
+ </Compile>

+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\NyARTransMat_ARToolKit.cs">
+ <Link>cs\core\transmat\NyARTransMat_ARToolKit.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\optimize\NyARPartialDifferentiationOptimize.cs">
+ <Link>cs\core\transmat\optimize\NyARPartialDifferentiationOptimize.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\optimize\artoolkit\INyARRotTransOptimize.cs">
+ <Link>cs\core\transmat\optimize\artoolkit\INyARRotTransOptimize.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\optimize\artoolkit\NyARRotTransOptimize.cs">
+ <Link>cs\core\transmat\optimize\artoolkit\NyARRotTransOptimize.cs</Link>
+ </Compile>

+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\solver\INyARTransportVectorSolver.cs">
+ <Link>cs\core\transmat\optimize\solver\INyARTransportVectorSolver.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\solver\NyARTransportVectorSolver.cs">
+ <Link>cs\core\transmat\optimize\solver\NyARTransportVectorSolver.cs</Link>
+ </Compile>
+ <Compile Include="..\..\forFW2.0\NyARToolkitCS\cs\core\transmat\solver\NyARTransportVectorSolver_ARToolKit.cs">
+ <Link>cs\core\transmat\optimize\solver\NyARTransportVectorSolver_ARToolKit.cs</Link>
+ </Compile>
+
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="cs\core\transmat\fitveccalc\" />
+ <Folder Include="cs\core\transmat\optimize\" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
Index: D:/project.sorceforge/NyARToolkitCS/trunk/LICENCE.txt
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/LICENCE.txt (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/LICENCE.txt (revision 304)
@@ -1,10 +1,10 @@
ARToolkit Java class library NyARToolkitCS.
-Copyright (C)2008 R.Iizuka
+Copyright (C)2008-2009 Ryo 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 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 3 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
@@ -12,24 +12,21 @@
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+along with this program. If not, see <http://www.gnu.org/licenses/>.



C#版 NyARToolkit クラスライブラリ NyARToolkitCS
-Copyright (C)2008 R.Iizuka
+Copyright (C)2008-2009 Ryo Iizuka

-このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェ
-ア財団によって発行された GNU 一般公衆利用許諾契約書(バージョン2か、希
-望によってはそれ以降のバージョンのうちどれか)の定める条件の下で再頒布
-または改変することができます。
+このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア
+財団によって発行されたGNU 一般公衆利用許諾書(バージョン3か、それ以降のバー
+ジョンのうちどれか)が定める条件の下で再頒布または改変 することができます。

-このプログラムは有用であることを願って頒布されますが、*全くの無保証*
-です。商業可能性の保証や特定の目的への適合性は、言外に示されたものも含
-め全く存在しません。詳しくはGNU 一般公衆利用許諾契約書をご覧ください。
-
-あなたはこのプログラムと共に、GNU 一般公衆利用許諾契約書の複製物を一部
-受け取ったはずです。もし受け取っていなければ、フリーソフトウェア財団ま
-で請求してください(宛先は the Free Software Foundation, Inc., 59
-Temple Place, Suite 330, Boston, MA 02111-1307 USA)。
\ No newline at end of file
+このプログラムは有用であることを願って頒布されますが、*全くの無保証 *です。
+商業可能性の保証や特定目的への適合性は、言外に示されたものも 含め、全く存
+在しません。詳しくはGNU 一般公衆利用許諾書をご覧ください。
+
+あなたはこのプログラムと共に、GNU 一般公衆利用許諾書のコピーを一部受け取って
+いるはずです。もし受け取っていなければ、<http://www.gnu.org/licenses/>
+ご覧ください。
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/CaptureTest/Form1.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/CaptureTest/Form1.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/CaptureTest/Form1.cs (revision 304)
@@ -34,8 +34,6 @@
NyARCode code = new NyARCode(16, 16);
code.loadARPattFromFile(AR_CODE_FILE);

- //1パターンのみを追跡するクラスを作成
- this.m_ar = new NyARSingleDetectMarker(ap, code, 80.0);
NyARTransMatResult result_mat = new NyARTransMatResult();
//計算モードの設定
this.m_ar.setContinueMode(false);
@@ -54,6 +52,8 @@
this.m_cap = cap;
//ラスタを作る。
this.m_raster = new DsBGRX32Raster(cap.video_width, cap.video_height, cap.video_width * cap.video_bit_count / 8);
+ //1パターンのみを追跡するクラスを作成
+ this.m_ar = new NyARSingleDetectMarker(ap, code, 80.0, this.m_raster.getBufferReader().getBufferType());
}
public void OnBuffer(CaptureDevice i_sender, double i_sample_time, IntPtr i_buffer, int i_buffer_len)
{
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/RawTest/NyIdTest.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/RawTest/NyIdTest.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/RawTest/NyIdTest.cs (revision 304)
@@ -49,8 +49,9 @@
public int current_id = -1;

public MarkerProcessor(NyARParam i_cparam, int i_raster_format)
- : base(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format)
{
+ initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format);
+
//アプリケーションフレームワークの初期化
return;
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/RawTest/RawTest.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/RawTest/RawTest.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/RawTest/RawTest.cs (revision 304)
@@ -30,8 +30,8 @@
using jp.nyatla.nyartoolkit.cs;
using jp.nyatla.nyartoolkit.cs.core;
using jp.nyatla.nyartoolkit.cs.detector;
-using jp.nyatla.nyartoolkit.cs.sandbox.x2;
-using jp.nyatla.nyartoolkit.cs.sandbox.quadx2;
+//using jp.nyatla.nyartoolkit.cs.sandbox.x2;
+//using jp.nyatla.nyartoolkit.cs.sandbox.quadx2;
namespace ConsoleApplication1
{
/**
@@ -46,7 +46,7 @@
private const String camera_file = "../../../../../data/camera_para.dat";
public RawFileTest()
{
- NyMath.initialize();
+// NyMath.initialize();
}
public void Test()
{
@@ -67,7 +67,7 @@
// Blank_Raster ra=new Blank_Raster(320, 240);

//1パターンのみを追跡するクラスを作成
- NyARSingleDetectMarker ar = new NyARSingleDetectMarker(ap, code, 80.0);
+ NyARSingleDetectMarker ar = new NyARSingleDetectMarker(ap, code, 80.0, ra.getBufferReader().getBufferType(),NyARSingleDetectMarker.PF_NYARTOOLKIT);
NyARTransMatResult result_mat = new NyARTransMatResult();
ar.setContinueMode(false);
ar.detectMarkerLite(ra, 100);
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/SimpleLiteDirect3d/SimpleLiteD3d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/SimpleLiteDirect3d/SimpleLiteD3d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/SimpleLiteDirect3d/SimpleLiteD3d.cs (revision 304)
@@ -167,7 +167,7 @@
code.loadARPattFromFile(AR_CODE_FILE);

//1パターンのみを追跡するクラスを作成
- this._ar = new NyARSingleDetectMarker(ap, code, 80.0);
+ this._ar = new NyARSingleDetectMarker(ap, code, 80.0, this._raster.getBufferReader().getBufferType(), NyARSingleDetectMarker.PF_NYARTOOLKIT);

//Direct3d用のユーティリティ準備
this._utils = new NyARD3dUtil();
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarker.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarker.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/sample/SingleNyIdMarkerDirect3d/SingleNyIdMarker.cs (revision 304)
@@ -50,9 +50,9 @@
public int current_id = -1;

public MarkerProcessor(NyARParam i_cparam, int i_raster_format)
- : base(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format)
{
//アプリケーションフレームワークの初期化
+ initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format);
return;
}
/**
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/NyARToolkitCS.sandbox.csproj
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/NyARToolkitCS.sandbox.csproj (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/NyARToolkitCS.sandbox.csproj (revision 304)
@@ -48,11 +48,14 @@
<Compile Include="cs\x2\NyARFixedFloatRotTransOptimize_O2.cs" />
<Compile Include="cs\x2\NyARFixedFloatRotVector.cs" />
<Compile Include="cs\x2\NyARFixedFloatTransOffset.cs" />
- <Compile Include="cs\x2\NyARLabeling_ARToolKit_X2.cs" />
+ <Compile Include="cs\x2\NyARFixedFloatVertexCounter.cs" />
<Compile Include="cs\x2\NyARSingleDetectMarker_X2.cs" />
- <Compile Include="cs\x2\NyARSquareDetector_X2.cs" />
+ <Compile Include="cs\x2\NyARSquareDetector_ARToolKit_X2.cs" />
+ <Compile Include="cs\x2\NyARSquareDetector_Rle_X2.cs" />
<Compile Include="cs\x2\NyARTransMat_X2.cs" />
<Compile Include="cs\x2\NyMath.cs" />
+ <Compile Include="cs\x2\SingleARMarkerProcesser_X2.cs" />
+ <Compile Include="cs\x2\SquareContourDetector_X2.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARRasterFilter_ARTTh_Quad.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARRasterFilter_ARTTh_Quad.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARRasterFilter_ARTTh_Quad.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSquareDetector_Quad.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSquareDetector_Quad.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSquareDetector_Quad.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -55,12 +54,14 @@
private int _width;
private int _height;

- private INyARLabeling _labeling;
+ private NyARLabeling_ARToolKit _labeling;

private NyARLabelingImage _limage;

private OverlapChecker _overlap_checker = new OverlapChecker();
private NyARFixedFloatObserv2IdealMap _dist_factor;
+ private ContourPickup _cpickup=new ContourPickup();
+ private SquareContourDetector _sqconvertor;
/**
* 最大i_squre_max個のマーカーを検出するクラスを作成する。
*
@@ -70,9 +71,9 @@
{
this._width = i_size.w / 2;
this._height = i_size.h / 2;
- this._labeling = new NyARLabeling_ARToolKit_X2();
+ this._labeling = new NyARLabeling_ARToolKit();
this._limage = new NyARLabelingImage(this._width, this._height);
- this._labeling.attachDestination(this._limage);
+ this._sqconvertor = new SquareContourDetector(i_size, i_dist_factor_ref);

// 輪郭の最大長は画面に映りうる最大の長方形サイズ。
int number_of_coord = (this._width + this._height) * 2;
@@ -119,7 +120,7 @@
*/
public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
{
- INyARLabeling labeling_proc = this._labeling;
+
NyARLabelingImage limage = this._limage;

// 初期化
@@ -128,7 +129,7 @@
o_square_stack.clear();

// ラベリング
- labeling_proc.labeling(i_raster);
+ this._labeling.labeling(i_raster,limage);

// ラベル数が0ならここまで
int label_num = limage.getLabelStack().getLength();
@@ -138,12 +139,10 @@
}

NyARLabelingLabelStack stack = limage.getLabelStack();
+ stack.sortByArea();
NyARLabelingLabel[] labels = (NyARLabelingLabel[])stack.getArray();


- // ラベルを大きい順に整列
- stack.sortByArea();
-
// デカいラベルを読み飛ばし
int i;
for (i = 0; i < label_num; i++)
@@ -162,7 +161,6 @@
int coord_max = this._max_coord;
int[] mkvertex = this.__detectMarker_mkvertex;
OverlapChecker overlap = this._overlap_checker;
- int coord_num;
int label_area;
NyARLabelingLabel label_pt;

@@ -194,35 +192,22 @@
continue;
}

- // 輪郭を取得
- coord_num = limage.getContour(i, coord_max, xcoord, ycoord);
- if (coord_num == coord_max)
- {
- // 輪郭が大きすぎる。
- continue;
- }
- //頂点候補のインデクスを取得
- int vertex1 = scanVertex(xcoord, ycoord, coord_num);
+ // 輪郭を取得
+ int coord_num = _cpickup.getContour(limage,limage.getTopClipTangentX(label_pt),label_pt.clip_t, coord_max, xcoord, ycoord);
+ if (coord_num == coord_max) {
+ // 輪郭が大きすぎる。
+ continue;
+ }
+ //輪郭分析用に正規化する。
+ int vertex1 = SquareContourDetector.normalizeCoord(xcoord, ycoord, coord_num);

- // 頂点候補(vertex1)を先頭に並べなおした配列を作成する。
- normalizeCoord(xcoord, ycoord, vertex1, coord_num);
+ //ここから先が輪郭分析
+ NyARSquare square_ptr = o_square_stack.prePush();
+ if(!this._sqconvertor.coordToSquare(xcoord,ycoord,vertex1,coord_num,label_area,square_ptr)){
+ o_square_stack.pop();// 頂点の取得が出来なかったので破棄
+ continue;
+ }

- // 領域を準備する。
- NyARSquare square_ptr = (NyARSquare)o_square_stack.prePush();
-
- // 頂点情報を取得
- if (!getSquareVertex(xcoord, ycoord, vertex1, coord_num, label_area, mkvertex))
- {
- o_square_stack.pop();// 頂点の取得が出来なかったので破棄
- continue;
- }
- // マーカーを検出
- if (!getSquareLine(mkvertex, xcoord, ycoord, square_ptr))
- {
- // 矩形が成立しなかった。
- o_square_stack.pop();
- continue;
- }
// 検出済の矩形の属したラベルを重なりチェックに追加する。
overlap.push(label_pt);
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSingleDetectMarker_Quad.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSingleDetectMarker_Quad.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/quadx2/NyARSingleDetectMarker_Quad.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_X2.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_X2.cs (revision 304)
@@ -1,575 +0,0 @@
-/*
- * 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.Diagnostics;
-using System.Text;
-using jp.nyatla.nyartoolkit.cs.core;
-using jp.nyatla.nyartoolkit.cs.core2;
-using jp.nyatla.nyartoolkit.cs.utils;
-
-namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
-{
-
-
- /**
- * イメージから正方形候補を検出するクラス。
- * このクラスは、arDetectMarker2.cとの置き換えになります。
- *
- */
- public class NyARSquareDetector_X2 : INyARSquareDetector
- {
- private const int PCA_LENGTH = 20;
- private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
-
- private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
- private int _width;
- private int _height;
-
- private INyARLabeling _labeling;
-
- private NyARLabelingImage _limage;
-
- private OverlapChecker _overlap_checker = new OverlapChecker();
- private NyARFixedFloatObserv2IdealMap _dist_factor;
- private NyARFixedFloatPca2d _pca;
-
- /**
- * 最大i_squre_max個のマーカーを検出するクラスを作成する。
- *
- * @param i_param
- */
- public NyARSquareDetector_X2(NyARFixedFloatObserv2IdealMap i_dist_factor_ref, NyARIntSize i_size)
- {
- this._width = i_size.w;
- this._height = i_size.h;
- this._dist_factor = i_dist_factor_ref;
- this._labeling = new NyARLabeling_ARToolKit_X2();
- this._limage = new NyARLabelingImage(this._width, this._height);
- this._labeling.attachDestination(this._limage);
-
- // 輪郭の最大長は画面に映りうる最大の長方形サイズ。
- int number_of_coord = (this._width + this._height) * 2;
-
- // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
- this._max_coord = number_of_coord;
- this._xcoord = new int[number_of_coord * 2];
- this._ycoord = new int[number_of_coord * 2];
- //PCA
- this._pca = new NyARFixedFloatPca2d();
- this._xpos = new int[PCA_LENGTH];//最大辺長はthis._width+this._height
- this._ypos = new int[PCA_LENGTH];//最大辺長はthis._width+this._height
-
- }
-
- private int _max_coord;
- private int[] _xcoord;
- private int[] _ycoord;
-
- private void normalizeCoord(int[] i_coord_x, int[] i_coord_y, int i_index, int i_coord_num)
- {
- // vertex1を境界にして、後方に配列を連結
- Array.Copy(i_coord_x, 1, i_coord_x, i_coord_num, i_index);
- Array.Copy(i_coord_y, 1, i_coord_y, i_coord_num, i_index);
- }
-
- private int[] __detectMarker_mkvertex = new int[5];
-
- /**
- * arDetectMarker2を基にした関数
- * この関数はNyARSquare要素のうち、directionを除くパラメータを取得して返します。
- * directionの確定は行いません。
- * @param i_raster
- * 解析する2値ラスタイメージを指定します。
- * @param o_square_stack
- * 抽出した正方形候補を格納するリスト
- * @throws NyARException
- */
- public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
- {
- INyARLabeling labeling_proc = this._labeling;
- NyARLabelingImage limage = this._limage;
-
- // 初期化
-
- // マーカーホルダをリセット
- o_square_stack.clear();
-
- // ラベリング
- labeling_proc.labeling(i_raster);
-
- // ラベル数が0ならここまで
- int label_num = limage.getLabelStack().getLength();
- if (label_num < 1)
- {
- return;
- }
-
- NyARLabelingLabelStack stack = limage.getLabelStack();
- NyARLabelingLabel[] labels = (NyARLabelingLabel[])stack.getArray();
-
-
- // ラベルを大きい順に整列
- stack.sortByArea();
-
- // デカいラベルを読み飛ばし
- int i;
- for (i = 0; i < label_num; i++)
- {
- // 検査対象内のラベルサイズになるまで無視
- if (labels[i].area <= AR_AREA_MAX)
- {
- break;
- }
- }
-
- int xsize = this._width;
- int ysize = this._height;
- int[] xcoord = this._xcoord;
- int[] ycoord = this._ycoord;
- int coord_max = this._max_coord;
- int[] mkvertex = this.__detectMarker_mkvertex;
- OverlapChecker overlap = this._overlap_checker;
- int coord_num;
- int label_area;
- NyARLabelingLabel label_pt;
-
- //重なりチェッカの最大数を設定
- overlap.reset(label_num);
-
- for (; i < label_num; i++)
- {
- label_pt = labels[i];
- label_area = label_pt.area;
- // 検査対象サイズよりも小さくなったら終了
- if (label_area < AR_AREA_MIN)
- {
- break;
- }
- // クリップ領域が画面の枠に接していれば除外
- if (label_pt.clip_l == 1 || label_pt.clip_r == xsize - 2)
- {// if(wclip[i*4+0] == 1 || wclip[i*4+1] ==xsize-2){
- continue;
- }
- if (label_pt.clip_t == 1 || label_pt.clip_b == ysize - 2)
- {// if( wclip[i*4+2] == 1 || wclip[i*4+3] ==ysize-2){
- continue;
- }
- // 既に検出された矩形との重なりを確認
- if (!overlap.check(label_pt))
- {
- // 重なっているようだ。
- continue;
- }
-
- // 輪郭を取得
- coord_num = limage.getContour(i, coord_max, xcoord, ycoord);
- if (coord_num == coord_max)
- {
- // 輪郭が大きすぎる。
- continue;
- }
- //頂点候補のインデクスを取得
- int vertex1 = scanVertex(xcoord, ycoord, coord_num);
-
- // 頂点候補(vertex1)を先頭に並べなおした配列を作成する。
- normalizeCoord(xcoord, ycoord, vertex1, coord_num);
-
- // 領域を準備する。
- NyARSquare square_ptr = (NyARSquare)o_square_stack.prePush();
- // 頂点情報を取得
- if (!getSquareVertex(xcoord, ycoord, vertex1, coord_num, label_area, mkvertex))
- {
- o_square_stack.pop();// 頂点の取得が出来なかったので破棄
- continue;
- }
- // マーカーを検出
- if (!getSquareLine(mkvertex, xcoord, ycoord, square_ptr))
- {
- // 矩形が成立しなかった。
- o_square_stack.pop();
- continue;
- }
- // 検出済の矩形の属したラベルを重なりチェックに追加する。
- overlap.push(label_pt);
- }
- return;
- }
-
- /**
- * 辺からの対角線が最長になる点を対角線候補として返す。
- *
- * @param i_xcoord
- * @param i_ycoord
- * @param i_coord_num
- * @return
- */
- private int scanVertex(int[] i_xcoord, int[] i_ycoord, int i_coord_num)
- {
- int sx = i_xcoord[0];
- int sy = i_ycoord[0];
- int d = 0;
- int w, x, y;
- int ret = 0;
- for (int i = 1; i < i_coord_num; i++)
- {
- x = i_xcoord[i] - sx;
- y = i_ycoord[i] - sy;
- w = x * x + y * y;
- if (w > d)
- {
- d = w;
- ret = i;
- }
- // ここでうまく終了条件入れられないかな。
- }
- return ret;
- }
-
- private NyARFixedFloatVertexCounter __getSquareVertex_wv1 = new NyARFixedFloatVertexCounter();
-
- private NyARFixedFloatVertexCounter __getSquareVertex_wv2 = new NyARFixedFloatVertexCounter();
-
- /**
- * static int arDetectMarker2_check_square( int area, ARMarkerInfo2 *marker_info2, double factor ) 関数の代替関数 OPTIMIZED STEP [450->415] o_squareに頂点情報をセットします。
- *
- * @param i_x_coord
- * @param i_y_coord
- * @param i_vertex1_index
- * @param i_coord_num
- * @param i_area
- * @param o_vertex
- * 要素数はint[4]である事
- * @return
- */
- private bool getSquareVertex(int[] i_x_coord, int[] i_y_coord, int i_vertex1_index, int i_coord_num, int i_area, int[] o_vertex)
- {
- NyARFixedFloatVertexCounter wv1 = this.__getSquareVertex_wv1;
- NyARFixedFloatVertexCounter wv2 = this.__getSquareVertex_wv2;
- int end_of_coord = i_vertex1_index + i_coord_num - 1;
- int sx = i_x_coord[i_vertex1_index];// sx = marker_info2->x_coord[0];
- int sy = i_y_coord[i_vertex1_index];// sy = marker_info2->y_coord[0];
- int dmax = 0;
- int v1 = i_vertex1_index;
- for (int i = 1 + i_vertex1_index; i < end_of_coord; i++)
- {// for(i=1;i<marker_info2->coord_num-1;i++)
- // {
- int d = (i_x_coord[i] - sx) * (i_x_coord[i] - sx) + (i_y_coord[i] - sy) * (i_y_coord[i] - sy);
- if (d > dmax)
- {
- dmax = d;
- v1 = i;
- }
- }
- //final double thresh = (i_area / 0.75) * 0.01;
- long thresh_f16 = (i_area << 16) / 75;
-
- o_vertex[0] = i_vertex1_index;
-
- if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v1, thresh_f16))
- { // if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,0,v1,thresh,wv1,&wvnum1)<
- // 0 ) {
- return false;
- }
- if (!wv2.getVertex(i_x_coord, i_y_coord, v1, end_of_coord, thresh_f16))
- {// if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,v1,marker_info2->coord_num-1,thresh,wv2,&wvnum2)
- // < 0) {
- return false;
- }
-
- int v2;
- if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
- {// if(wvnum1 == 1 && wvnum2== 1) {
- o_vertex[1] = wv1.vertex[0];
- o_vertex[2] = v1;
- o_vertex[3] = wv2.vertex[0];
- }
- else if (wv1.number_of_vertex > 1 && wv2.number_of_vertex == 0)
- {// }else if( wvnum1 > 1 && wvnum2== 0) {
- //頂点位置を、起点から対角点の間の1/2にあると予想して、検索する。
- v2 = (v1 - i_vertex1_index) / 2 + i_vertex1_index;
- if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v2, thresh_f16))
- {
- return false;
- }
- if (!wv2.getVertex(i_x_coord, i_y_coord, v2, v1, thresh_f16))
- {
- return false;
- }
- if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
- {
- o_vertex[1] = wv1.vertex[0];
- o_vertex[2] = wv2.vertex[0];
- o_vertex[3] = v1;
- }
- else
- {
- return false;
- }
- }
- else if (wv1.number_of_vertex == 0 && wv2.number_of_vertex > 1)
- {
- //v2 = (v1-i_vertex1_index+ end_of_coord-i_vertex1_index) / 2+i_vertex1_index;
- v2 = (v1 + end_of_coord) / 2;
-
- if (!wv1.getVertex(i_x_coord, i_y_coord, v1, v2, thresh_f16))
- {
- return false;
- }
- if (!wv2.getVertex(i_x_coord, i_y_coord, v2, end_of_coord, thresh_f16))
- {
- return false;
- }
- if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
- {
- o_vertex[1] = v1;
- o_vertex[2] = wv1.vertex[0];
- o_vertex[3] = wv2.vertex[0];
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- o_vertex[4] = end_of_coord;
- return true;
- }
- private int[] _xpos;
- private int[] _ypos;
-
- private NyARI64Matrix22 __getSquareLine_evec = new NyARI64Matrix22();
- private NyARI64Point2d __getSquareLine_mean = new NyARI64Point2d();
- private NyARI64Point2d __getSquareLine_ev = new NyARI64Point2d();
- private NyARI64Linear[] __getSquareLine_i64liner = NyARI64Linear.createArray(4);
- /**
- * arGetLine(int x_coord[], int y_coord[], int coord_num,int vertex[], double line[4][3], double v[4][2]) arGetLine2(int x_coord[], int y_coord[], int
- * coord_num,int vertex[], double line[4][3], double v[4][2], double *dist_factor) の2関数の合成品です。 マーカーのvertex,lineを計算して、結果をo_squareに保管します。
- * Optimize:STEP[424->391]
- *
- * @param i_cparam
- * @return
- * @throws NyARException
- */
- private bool getSquareLine(int[] i_mkvertex, int[] i_xcoord, int[] i_ycoord, NyARSquare o_square)
- {
- NyARLinear[] l_line = o_square.line;
- NyARI64Matrix22 evec = this.__getSquareLine_evec;
- NyARI64Point2d mean = this.__getSquareLine_mean;
- NyARI64Point2d ev = this.__getSquareLine_ev;
- NyARI64Linear[] i64liner = this.__getSquareLine_i64liner;
-
- for (int i = 0; i < 4; i++)
- {
- // final double w1 = (double) (i_mkvertex[i + 1] - i_mkvertex[i] + 1) * 0.05 + 0.5;
- int w1 = ((((i_mkvertex[i + 1] - i_mkvertex[i] + 1) << 8) * 13) >> 8) + (1 << 7);
- int st = i_mkvertex[i] + (w1 >> 8);
- int ed = i_mkvertex[i + 1] - (w1 >> 8);
- int n = ed - st + 1;
- if (n < 2)
- {
- // nが2以下でmatrix.PCAを計算することはできないので、エラー
- return false;
- }
- //配列作成
- n=this._dist_factor.observ2IdealSampling(i_xcoord, i_ycoord, st, n, this._xpos, this._ypos,PCA_LENGTH);
-
- //主成分分析する。
- this._pca.pcaF16(this._xpos, this._ypos, n, evec, ev, mean);
- NyARI64Linear l_line_i = i64liner[i];
- l_line_i.run = evec.m01;// line[i][0] = evec->m[1];
- l_line_i.rise = -evec.m00;// line[i][1] = -evec->m[0];
- l_line_i.intercept = -((l_line_i.run * mean.x + l_line_i.rise * mean.y) >> 16);// line[i][2] = -(line[i][0]*mean->v[0] + line[i][1]*mean->v[1]);
- }
-
- NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
- NyARIntPoint2d[] l_imvertex = o_square.imvertex;
- for (int i = 0; i < 4; i++)
- {
- NyARI64Linear l_line_i = i64liner[i];
- NyARI64Linear l_line_2 = i64liner[(i + 3) % 4];
- long w1 = (l_line_2.run * l_line_i.rise - l_line_i.run * l_line_2.rise) >> 16;
- if (w1 == 0)
- {
- return false;
- }
- l_sqvertex[i].x = (double)((l_line_2.rise * l_line_i.intercept - l_line_i.rise * l_line_2.intercept) / w1) / 65536.0;
- l_sqvertex[i].y = (double)((l_line_i.run * l_line_2.intercept - l_line_2.run * l_line_i.intercept) / w1) / 65536.0;
- // 頂点インデクスから頂点座標を得て保存
- l_imvertex[i].x = i_xcoord[i_mkvertex[i]];
- l_imvertex[i].y = i_ycoord[i_mkvertex[i]];
- l_line[i].run = (double)l_line_i.run / 65536.0;
- l_line[i].rise = (double)l_line_i.rise / 65536.0;
- l_line[i].intercept = (double)l_line_i.intercept / 65536.0;
- }
- return true;
- }
- }
-
-
-
- /**
- * ラベル同士の重なり(内包関係)を調べるクラスです。
- * ラベルリストに内包するラベルを蓄積し、それにターゲットのラベルが内包されているか を確認します。
- */
- class OverlapChecker
- {
- private NyARLabelingLabel[] _labels = new NyARLabelingLabel[32];
-
- private int _length;
-
- /**
- * 最大i_max_label個のラベルを蓄積できるようにオブジェクトをリセットする
- *
- * @param i_max_label
- */
- public void reset(int i_max_label)
- {
- if (i_max_label > this._labels.Length)
- {
- this._labels = new NyARLabelingLabel[i_max_label];
- }
- this._length = 0;
- }
-
- /**
- * チェック対象のラベルを追加する。
- *
- * @param i_label_ref
- */
- public void push(NyARLabelingLabel i_label_ref)
- {
- this._labels[this._length] = i_label_ref;
- this._length++;
- }
-
- /**
- * 現在リストにあるラベルと重なっているかを返す。
- *
- * @param i_label
- * @return 何れかのラベルの内側にあるならばfalse,独立したラベルである可能性が高ければtrueです.
- */
- public bool check(NyARLabelingLabel i_label)
- {
- // 重なり処理かな?
- NyARLabelingLabel[] label_pt = this._labels;
- int px1 = (int)i_label.pos_x;
- int py1 = (int)i_label.pos_y;
- for (int i = this._length - 1; i >= 0; i--)
- {
- int px2 = (int)label_pt[i].pos_x;
- int py2 = (int)label_pt[i].pos_y;
- int d = (px1 - px2) * (px1 - px2) + (py1 - py2) * (py1 - py2);
- if (d < label_pt[i].area / 4)
- {
- // 対象外
- return false;
- }
- }
- // 対象
- return true;
- }
- }
- class NyARFixedFloatVertexCounter
- {
- public int[] vertex = new int[6];// 5まで削れる
-
- public int number_of_vertex;
-
- private long thresh_16f;
-
- private int[] x_coord;
-
- private int[] y_coord;
-
- public bool getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, long i_thresh)
- {
- this.number_of_vertex = 0;
- this.thresh_16f = i_thresh;
- this.x_coord = i_x_coord;
- this.y_coord = i_y_coord;
- return get_vertex(st, ed);
- }
-
- /**
- * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
- *
- * @param x_coord
- * @param y_coord
- * @param st
- * @param ed
- * @param thresh
- * @return
- */
- private bool get_vertex(int st, int ed)
- {
- int v1 = 0;
- int[] lx_coord = this.x_coord;
- int[] ly_coord = this.y_coord;
- int a = ly_coord[ed] - ly_coord[st];
- int b = lx_coord[st] - lx_coord[ed];
- int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
- long dmax = 0;
- for (int i = st + 1; i < ed; i++)
- {
- long d = a * lx_coord[i] + b * ly_coord[i] + c;
- if (d * d > dmax)
- {
- dmax = d * d;
- v1 = i;
- }
- }
- if ((dmax << 16) / (long)(a * a + b * b) > this.thresh_16f)
- {
- if (!get_vertex(st, v1))
- {
- return false;
- }
- if (number_of_vertex > 5)
- {
- return false;
- }
- vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
- number_of_vertex++;// (*vnum)++;
-
- if (!get_vertex(v1, ed))
- {
- return false;
- }
- }
- return true;
- }
- }
-
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARLabeling_ARToolKit_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARLabeling_ARToolKit_X2.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARLabeling_ARToolKit_X2.cs (revision 304)
@@ -1,441 +0,0 @@
-/*
- * 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.utils;
-
-namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
-{
- /**
- * 計算部から浮動小数点計算を除外したNyARLabeling_ARToolKit
- * NyARLabeling_ARToolKitと同じ処理をするけど、エリア計算にintを使う。
- * 画面サイズが1600x1600を超えると挙動が怪しくなる。
- *
- */
- public class NyARLabeling_ARToolKit_X2 : INyARLabeling
- {
- private const int WORK_SIZE = 1024 * 32;// #define WORK_SIZE 1024*32
-
- private NyARWorkHolder work_holder = new NyARWorkHolder(WORK_SIZE);
-
- private NyARIntSize _dest_size;
-
- private INyARLabelingImage _out_image;
-
- public void attachDestination(INyARLabelingImage i_destination_image)
- {
- // サイズチェック
- NyARIntSize size = i_destination_image.getSize();
- this._out_image = i_destination_image;
-
- // NyLabelingImageのイメージ初期化(枠書き)
- int[][] img = (int[][])i_destination_image.getBufferReader().getBuffer();
- for (int i = 0; i < size.w; i++)
- {
- img[0][i] = 0;
- img[size.h - 1][i] = 0;
- }
- for (int i = 0; i < size.h; i++)
- {
- img[i][0] = 0;
- img[i][size.w - 1] = 0;
- }
-
- // サイズ(参照値)を保存
- this._dest_size = size;
- }
-
- public INyARLabelingImage getAttachedDestination()
- {
- return this._out_image;
- }
-
- /**
- * static ARInt16 *labeling2( ARUint8 *image, int thresh,int *label_num, int **area, double **pos, int **clip,int **label_ref, int LorR ) 関数の代替品
- * ラスタimageをラベリングして、結果を保存します。 Optimize:STEP[1514->1493]
- *
- * @param i_raster
- * @throws NyARException
- */
- public void labeling(NyARBinRaster i_raster)
- {
- int m, n; /* work */
- int i, j, k;
- INyARLabelingImage out_image = this._out_image;
-
- // サイズチェック
- NyARIntSize in_size = i_raster.getSize();
- this._dest_size.isEqualSize(in_size);
-
- int lxsize = in_size.w;// lxsize = arUtil_c.arImXsize;
- int lysize = in_size.h;// lysize = arUtil_c.arImYsize;
- int[][] label_img = (int[][])out_image.getBufferReader().getBuffer();
-
- // 枠作成はインスタンスを作った直後にやってしまう。
-
- // ラベリング情報のリセット(ラベリングインデックスを使用)
- out_image.reset(true);
-
- int[] label_idxtbl = out_image.getIndexArray();
-
- int[] work2_pt;
- int wk_max = 0;
-
- int label_pixel;
- int[][] raster_buf = (int[][])i_raster.getBufferReader().getBuffer();
- int[] line_ptr;
- int[][] work2 = this.work_holder.work2;
- int[] label_img_pt0, label_img_pt1;
- for (j = 1; j < lysize - 1; j++)
- {// for (int j = 1; j < lysize - 1;j++, pnt += poff*2, pnt2 += 2) {
- line_ptr = raster_buf[j];
- label_img_pt0 = label_img[j];
- label_img_pt1 = label_img[j - 1];
- for (i = 1; i < lxsize - 1; i++)
- {// for(int i = 1; i < lxsize-1;i++, pnt+=poff, pnt2++) {
- // RGBの合計値が閾値より小さいかな?
- if (line_ptr[i] == 0)
- {
- // pnt1 = ShortPointer.wrap(pnt2, -lxsize);//pnt1 =&(pnt2[-lxsize]);
- if (label_img_pt1[i] > 0)
- {// if( *pnt1 > 0 ) {
- label_pixel = label_img_pt1[i];// *pnt2 = *pnt1;
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
- }
- else if (label_img_pt1[i + 1] > 0)
- {// }else if(*(pnt1+1) > 0 ) {
- if (label_img_pt1[i - 1] > 0)
- {// if( *(pnt1-1) > 0 ) {
- m = label_idxtbl[label_img_pt1[i + 1] - 1];// m =work[*(pnt1+1)-1];
- n = label_idxtbl[label_img_pt1[i - 1] - 1];// n =work[*(pnt1-1)-1];
- if (m > n)
- {
- label_pixel = n;// *pnt2 = n;
- // wk=IntPointer.wrap(work, 0);//wk =
- // &(work[0]);
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == m)
- {// if( *wk == m )
- label_idxtbl[k] = n;// *wk = n;
- }
- }
- }
- else if (m < n)
- {
- label_pixel = m;// *pnt2 = m;
- // wk=IntPointer.wrap(work,0);//wk = &(work[0]);
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == n)
- {// if( *wk == n ){
- label_idxtbl[k] = m;// *wk = m;
- }
- }
- }
- else
- {
- label_pixel = m;// *pnt2 = m;
- }
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;
- work2_pt[1] += i;
- work2_pt[2] += j;
- work2_pt[6] = j;
- }
- else if ((label_img_pt0[i - 1]) > 0)
- {// }else if(*(pnt2-1) > 0) {
- m = label_idxtbl[(label_img_pt1[i + 1]) - 1];// m =work[*(pnt1+1)-1];
- n = label_idxtbl[label_img_pt0[i - 1] - 1];// n =work[*(pnt2-1)-1];
- if (m > n)
- {
-
- label_pixel = n;// *pnt2 = n;
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == m)
- {// if( *wk == m ){
- label_idxtbl[k] = n;// *wk = n;
- }
- }
- }
- else if (m < n)
- {
- label_pixel = m;// *pnt2 = m;
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == n)
- {// if( *wk == n ){
- label_idxtbl[k] = m;// *wk = m;
- }
- }
- }
- else
- {
- label_pixel = m;// *pnt2 = m;
- }
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- }
- else
- {
-
- label_pixel = label_img_pt1[i + 1];// *pnt2 =
- // *(pnt1+1);
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- if (work2_pt[3] > i)
- {// if(
- // work2[((*pnt2)-1)*7+3] >
- // i ){
- work2_pt[3] = i;// work2[((*pnt2)-1)*7+3] = i;
- }
- work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
- }
- }
- else if ((label_img_pt1[i - 1]) > 0)
- {// }else if(
- // *(pnt1-1) > 0 ) {
- label_pixel = label_img_pt1[i - 1];// *pnt2 =
- // *(pnt1-1);
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- if (work2_pt[4] < i)
- {// if( work2[((*pnt2)-1)*7+4] <i ){
- work2_pt[4] = i;// work2[((*pnt2)-1)*7+4] = i;
- }
- work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
- }
- else if (label_img_pt0[i - 1] > 0)
- {// }else if(*(pnt2-1) > 0) {
- label_pixel = label_img_pt0[i - 1];// *pnt2 =*(pnt2-1);
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- if (work2_pt[4] < i)
- {// if( work2[((*pnt2)-1)*7+4] <i ){
- work2_pt[4] = i;// work2[((*pnt2)-1)*7+4] = i;
- }
- }
- else
- {
- // 現在地までの領域を予約
- this.work_holder.reserv(wk_max);
- wk_max++;
- label_idxtbl[wk_max - 1] = wk_max;
- label_pixel = wk_max;// work[wk_max-1] = *pnt2 = wk_max;
- work2_pt = work2[wk_max - 1];
- work2_pt[0] = 1;
- work2_pt[1] = i;
- work2_pt[2] = j;
- work2_pt[3] = i;
- work2_pt[4] = i;
- work2_pt[5] = j;
- work2_pt[6] = j;
- }
- label_img_pt0[i] = label_pixel;
- }
- else
- {
- label_img_pt0[i] = 0;// *pnt2 = 0;
- }
- }
- }
- // インデックステーブルとラベル数の計算
- int wlabel_num = 1;// *label_num = *wlabel_num = j - 1;
-
- for (i = 0; i < wk_max; i++)
- {// for(int i = 1; i <= wk_max; i++,wk++) {
- label_idxtbl[i] = (label_idxtbl[i] == i + 1) ? wlabel_num++ : label_idxtbl[label_idxtbl[i] - 1];// *wk=(*wk==i)?j++:work[(*wk)-1];
- }
- wlabel_num -= 1;// *label_num = *wlabel_num = j - 1;
- if (wlabel_num == 0)
- {// if( *label_num == 0 ) {
- // 発見数0
- out_image.getLabelStack().clear();
- return;
- }
- // ラベルの整理
- updateLabelStackLarge(out_image.getLabelStack(), label_idxtbl, in_size, work2, wk_max, wlabel_num);
-
- return;
- }
- private int[][] __updateLabelStackLarge_temp = ArrayUtils.newInt2dArray(64, 7);//new int[64][7];/*area,x,y,l,r,t,b*/
-
- /* 構造が変わるから、ハイスピード版実装するときに使う。 */
- private void updateLabelStackLarge(NyARLabelingLabelStack i_stack, int[] i_lindex, NyARIntSize i_size, int[][] i_work, int i_work_max, int i_number_of_label)
- {
- //計算用のワークを確保
- int[][] temp = this.__updateLabelStackLarge_temp;
- if (temp.Length < i_number_of_label)
- {
- temp = ArrayUtils.newInt2dArray(i_number_of_label + 64, 7);//=new int[i_number_of_label+64][7];
- this.__updateLabelStackLarge_temp = temp;
- }
-
- // ラベルバッファを予約
- i_stack.reserv(i_number_of_label);
- // エリアと重心、クリップ領域を計算
- NyARLabelingLabel[] labels = (NyARLabelingLabel[])i_stack.getArray();
- for (int i = 0; i < i_number_of_label; i++)
- {
- int[] temp_ptr = temp[i];
- temp_ptr[0] = 0;//area
- temp_ptr[1] = 0;//x
- temp_ptr[2] = 0;//y
- temp_ptr[3] = i_size.w;//l
- temp_ptr[4] = 0;//r
- temp_ptr[5] = i_size.h;//t
- temp_ptr[6] = 0;//b
- }
- //計算!
-
- for (int i = 0; i < i_work_max; i++)
- {
- int[] temp_ptr = temp[i_lindex[i] - 1];
- int[] work2_pt = i_work[i];
- temp_ptr[0] += work2_pt[0];
- temp_ptr[1] += work2_pt[1];
- temp_ptr[2] += work2_pt[2];
- if (temp_ptr[3] > work2_pt[3])
- {
- temp_ptr[3] = work2_pt[3];
- }
- if (temp_ptr[4] < work2_pt[4])
- {
- temp_ptr[4] = work2_pt[4];
- }
- if (temp_ptr[5] > work2_pt[5])
- {
- temp_ptr[5] = work2_pt[5];
- }
- if (temp_ptr[6] < work2_pt[6])
- {
- temp_ptr[6] = work2_pt[6];
- }
- }
- //ストア
- for (int i = 0; i < i_number_of_label; i++)
- {// for(int i = 0; i < *label_num; i++ ) {
- NyARLabelingLabel label_pt = labels[i];
- int[] temp_ptr = temp[i];
- label_pt.id = i + 1;
- label_pt.area = temp_ptr[0];
- label_pt.pos_x = (double)temp_ptr[1] / label_pt.area;
- label_pt.pos_y = (double)temp_ptr[2] / label_pt.area;
- label_pt.clip_l = temp_ptr[3];
- label_pt.clip_r = temp_ptr[4];
- label_pt.clip_t = temp_ptr[5];
- label_pt.clip_b = temp_ptr[6];
- }
- return;
- }
- }
-
- /**
- * NyARLabeling_O2のworkとwork2を可変長にするためのクラス
- *
- *
- */
- class NyARWorkHolder
- {
- private const int ARRAY_APPEND_STEP = 256;
-
- public int[] work;
-
- public int[][] work2;
-
- private int allocate_size;
-
- /**
- * 最大i_holder_size個の動的割り当てバッファを準備する。
- *
- * @param i_holder_size
- */
- public NyARWorkHolder(int i_holder_size)
- {
- // ポインタだけははじめに確保しておく
- this.work = new int[i_holder_size];
- this.work2 = new int[i_holder_size][];
- this.allocate_size = 0;
- }
-
- /**
- * i_indexで指定した番号までのバッファを準備する。
- *
- * @param i_index
- */
- public void reserv(int i_index)
- {
- // アロケート済みなら即リターン
- if (this.allocate_size > i_index)
- {
- return;
- }
- // 要求されたインデクスは範囲外
- if (i_index >= this.work.Length)
- {
- throw new NyARException();
- }
- // 追加アロケート範囲を計算
- int range = i_index + ARRAY_APPEND_STEP;
- if (range >= this.work.Length)
- {
- range = this.work.Length;
- }
- // アロケート
- for (int i = this.allocate_size; i < range; i++)
- {
- this.work2[i] = new int[8];
- }
- this.allocate_size = range;
- }
- }
-
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/SquareContourDetector_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/SquareContourDetector_X2.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/SquareContourDetector_X2.cs (revision 304)
@@ -0,0 +1,271 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.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.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
+{
+ public class SquareContourDetector_X2
+ {
+ private const int PCA_LENGTH = 20;
+ private int[] _xpos = new int[PCA_LENGTH];
+ private int[] _ypos = new int[PCA_LENGTH];
+ private int[] __detectMarker_mkvertex = new int[5];
+ private NyARFixedFloatVertexCounter __getSquareVertex_wv1 = new NyARFixedFloatVertexCounter();
+ private NyARFixedFloatVertexCounter __getSquareVertex_wv2 = new NyARFixedFloatVertexCounter();
+ private NyARFixedFloatPca2d _pca;
+ private NyARI64Matrix22 __getSquareLine_evec = new NyARI64Matrix22();
+ private NyARI64Point2d __getSquareLine_mean = new NyARI64Point2d();
+ private NyARI64Point2d __getSquareLine_ev = new NyARI64Point2d();
+ private NyARI64Linear[] __getSquareLine_i64liner = NyARI64Linear.createArray(4);
+ private NyARFixedFloatObserv2IdealMap _dist_factor;
+ public SquareContourDetector_X2(NyARIntSize i_size, NyARCameraDistortionFactor i_distfactor_ref)
+ {
+ //歪み計算テーブルを作ると、8*width/height*2の領域を消費します。
+ //領域を取りたくない場合は、i_dist_factor_refの値をそのまま使ってください。
+ this._dist_factor = new NyARFixedFloatObserv2IdealMap(i_distfactor_ref, i_size);
+
+
+ // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
+ this._pca = new NyARFixedFloatPca2d();
+ return;
+ }
+
+ public bool coordToSquare(int[] i_xcoord, int[] i_ycoord, int i_st_index, int i_coord_num, int i_label_area, NyARSquare o_square)
+ {
+
+ int[] mkvertex = this.__detectMarker_mkvertex;
+
+ // 頂点情報を取得
+ if (!getSquareVertex(i_xcoord, i_ycoord, i_st_index, i_coord_num, i_label_area, mkvertex))
+ {
+ // 頂点の取得が出来なかったので破棄
+ return false;
+ }
+ // マーカーを検出
+ if (!getSquareLine(mkvertex, i_xcoord, i_ycoord, o_square))
+ {
+ // 矩形が成立しなかった。
+ return false;
+ }
+ return true;
+ }
+
+ private bool getSquareLine(int[] i_mkvertex, int[] i_xcoord, int[] i_ycoord, NyARSquare o_square)
+ {
+ NyARLinear[] l_line = o_square.line;
+ NyARI64Matrix22 evec = this.__getSquareLine_evec;
+ NyARI64Point2d mean = this.__getSquareLine_mean;
+ NyARI64Point2d ev = this.__getSquareLine_ev;
+ NyARI64Linear[] i64liner = this.__getSquareLine_i64liner;
+
+ for (int i = 0; i < 4; i++)
+ {
+ // final double w1 = (double) (i_mkvertex[i + 1] - i_mkvertex[i] + 1) * 0.05 + 0.5;
+ int w1 = ((((i_mkvertex[i + 1] - i_mkvertex[i] + 1) << 8) * 13) >> 8) + (1 << 7);
+ int st = i_mkvertex[i] + (w1 >> 8);
+ int ed = i_mkvertex[i + 1] - (w1 >> 8);
+ int n = ed - st + 1;
+ if (n < 2)
+ {
+ // nが2以下でmatrix.PCAを計算することはできないので、エラー
+ return false;
+ }
+ //配列作成
+ n = this._dist_factor.observ2IdealSampling(i_xcoord, i_ycoord, st, n, this._xpos, this._ypos, PCA_LENGTH);
+ //主成分分析する。
+ this._pca.pcaF16(this._xpos, this._ypos, n, evec, ev, mean);
+ NyARI64Linear l_line_i = i64liner[i];
+ l_line_i.run = evec.m01;// line[i][0] = evec->m[1];
+ l_line_i.rise = -evec.m00;// line[i][1] = -evec->m[0];
+ l_line_i.intercept = -((l_line_i.run * mean.x + l_line_i.rise * mean.y) >> 16);// line[i][2] = -(line[i][0]*mean->v[0] + line[i][1]*mean->v[1]);
+ }
+
+ NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
+ NyARIntPoint2d[] l_imvertex = o_square.imvertex;
+ for (int i = 0; i < 4; i++)
+ {
+ NyARI64Linear l_line_i = i64liner[i];
+ NyARI64Linear l_line_2 = i64liner[(i + 3) % 4];
+ long w1 = (l_line_2.run * l_line_i.rise - l_line_i.run * l_line_2.rise) >> 16;
+ if (w1 == 0)
+ {
+ return false;
+ }
+ l_sqvertex[i].x = (double)((l_line_2.rise * l_line_i.intercept - l_line_i.rise * l_line_2.intercept) / w1) / 65536.0;
+ l_sqvertex[i].y = (double)((l_line_i.run * l_line_2.intercept - l_line_2.run * l_line_i.intercept) / w1) / 65536.0;
+ // 頂点インデクスから頂点座標を得て保存
+ l_imvertex[i].x = i_xcoord[i_mkvertex[i]];
+ l_imvertex[i].y = i_ycoord[i_mkvertex[i]];
+ l_line[i].run = (double)l_line_i.run / 65536.0;
+ l_line[i].rise = (double)l_line_i.rise / 65536.0;
+ l_line[i].intercept = (double)l_line_i.intercept / 65536.0;
+ }
+ return true;
+ }
+ private bool getSquareVertex(int[] i_x_coord, int[] i_y_coord, int i_vertex1_index, int i_coord_num, int i_area, int[] o_vertex)
+ {
+ NyARFixedFloatVertexCounter wv1 = this.__getSquareVertex_wv1;
+ NyARFixedFloatVertexCounter wv2 = this.__getSquareVertex_wv2;
+ int end_of_coord = i_vertex1_index + i_coord_num - 1;
+ int sx = i_x_coord[i_vertex1_index];// sx = marker_info2->x_coord[0];
+ int sy = i_y_coord[i_vertex1_index];// sy = marker_info2->y_coord[0];
+ int dmax = 0;
+ int v1 = i_vertex1_index;
+ for (int i = 1 + i_vertex1_index; i < end_of_coord; i++)
+ {// for(i=1;i<marker_info2->coord_num-1;i++)
+ // {
+ int d = (i_x_coord[i] - sx) * (i_x_coord[i] - sx) + (i_y_coord[i] - sy) * (i_y_coord[i] - sy);
+ if (d > dmax)
+ {
+ dmax = d;
+ v1 = i;
+ }
+ }
+ //final double thresh = (i_area / 0.75) * 0.01;
+ long thresh_f16 = (i_area << 16) / 75;
+
+ o_vertex[0] = i_vertex1_index;
+
+ if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v1, thresh_f16))
+ { // if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,0,v1,thresh,wv1,&wvnum1)<
+ // 0 ) {
+ return false;
+ }
+ if (!wv2.getVertex(i_x_coord, i_y_coord, v1, end_of_coord, thresh_f16))
+ {// if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,v1,marker_info2->coord_num-1,thresh,wv2,&wvnum2)
+ // < 0) {
+ return false;
+ }
+
+ int v2;
+ if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
+ {// if(wvnum1 == 1 && wvnum2== 1) {
+ o_vertex[1] = wv1.vertex[0];
+ o_vertex[2] = v1;
+ o_vertex[3] = wv2.vertex[0];
+ }
+ else if (wv1.number_of_vertex > 1 && wv2.number_of_vertex == 0)
+ {// }else if( wvnum1 > 1 && wvnum2== 0) {
+ //頂点位置を、起点から対角点の間の1/2にあると予想して、検索する。
+ v2 = (v1 - i_vertex1_index) / 2 + i_vertex1_index;
+ if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v2, thresh_f16))
+ {
+ return false;
+ }
+ if (!wv2.getVertex(i_x_coord, i_y_coord, v2, v1, thresh_f16))
+ {
+ return false;
+ }
+ if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
+ {
+ o_vertex[1] = wv1.vertex[0];
+ o_vertex[2] = wv2.vertex[0];
+ o_vertex[3] = v1;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (wv1.number_of_vertex == 0 && wv2.number_of_vertex > 1)
+ {
+ //v2 = (v1-i_vertex1_index+ end_of_coord-i_vertex1_index) / 2+i_vertex1_index;
+ v2 = (v1 + end_of_coord) / 2;
+
+ if (!wv1.getVertex(i_x_coord, i_y_coord, v1, v2, thresh_f16))
+ {
+ return false;
+ }
+ if (!wv2.getVertex(i_x_coord, i_y_coord, v2, end_of_coord, thresh_f16))
+ {
+ return false;
+ }
+ if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
+ {
+ o_vertex[1] = v1;
+ o_vertex[2] = wv1.vertex[0];
+ o_vertex[3] = wv2.vertex[0];
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ o_vertex[4] = end_of_coord;
+ return true;
+ }
+
+ /**
+ * 輪郭線の矩形検出開始ポイントを特定して、座標を並べ替えます。
+ * 輪郭線の先頭から、対角線が最長になる点を1点検索し、それより前の区間をバッファの後方に接続します。
+ * 戻り値は対角線が最長になった点です。関数終了後、返却値+i_coord_numの要素が有効になります。
+ * @param i_xcoord
+ * @param i_ycoord
+ * @param i_coord_num
+ * @return
+ */
+ public static int normalizeCoord(int[] i_coord_x, int[] i_coord_y, int i_coord_num)
+ {
+ //
+ int sx = i_coord_x[0];
+ int sy = i_coord_y[0];
+ int d = 0;
+ int w, x, y;
+ int ret = 0;
+ for (int i = 1; i < i_coord_num; i++)
+ {
+ x = i_coord_x[i] - sx;
+ y = i_coord_y[i] - sy;
+ w = x * x + y * y;
+ if (w > d)
+ {
+ d = w;
+ ret = i;
+ }
+ // ここでうまく終了条件入れられないかな。
+ }
+ // vertex1を境界にして、後方に配列を連結
+ Array.Copy(i_coord_x, 1, i_coord_x, i_coord_num, ret);
+ Array.Copy(i_coord_y, 1, i_coord_y, i_coord_num, ret);
+ return ret;
+ }
+
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatVertexCounter.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatVertexCounter.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatVertexCounter.cs (revision 304)
@@ -0,0 +1,108 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
+{
+ public class NyARFixedFloatVertexCounter
+ {
+ public int[] vertex = new int[6];// 5まで削れる
+
+ public int number_of_vertex;
+
+ private long thresh_16f;
+
+ private int[] x_coord;
+
+ private int[] y_coord;
+
+ public bool getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, long i_thresh)
+ {
+ this.number_of_vertex = 0;
+ this.thresh_16f = i_thresh;
+ this.x_coord = i_x_coord;
+ this.y_coord = i_y_coord;
+ return get_vertex(st, ed);
+ }
+
+ /**
+ * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
+ *
+ * @param x_coord
+ * @param y_coord
+ * @param st
+ * @param ed
+ * @param thresh
+ * @return
+ */
+ private bool get_vertex(int st, int ed)
+ {
+ int v1 = 0;
+ int[] lx_coord = this.x_coord;
+ int[] ly_coord = this.y_coord;
+ int a = ly_coord[ed] - ly_coord[st];
+ int b = lx_coord[st] - lx_coord[ed];
+ int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
+ long dmax = 0;
+ for (int i = st + 1; i < ed; i++)
+ {
+ long d = a * lx_coord[i] + b * ly_coord[i] + c;
+ if (d * d > dmax)
+ {
+ dmax = d * d;
+ v1 = i;
+ }
+ }
+ if ((dmax << 16) / (long)(a * a + b * b) > this.thresh_16f)
+ {
+ if (!get_vertex(st, v1))
+ {
+ return false;
+ }
+ if (number_of_vertex > 5)
+ {
+ return false;
+ }
+ vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
+ number_of_vertex++;// (*vnum)++;
+
+ if (!get_vertex(v1, ed))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatObserv2IdealMap.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatObserv2IdealMap.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatObserv2IdealMap.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSingleDetectMarker_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSingleDetectMarker_X2.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSingleDetectMarker_X2.cs (revision 304)
@@ -1,5 +1,5 @@
/*
- * PROJECT: NyARToolkit
+ * PROJECT: NyARToolkitCS
* --------------------------------------------------------------------------------
* This work is based on the original ARToolKit developed by
* Hirokazu Kato
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -75,30 +74,31 @@
* ARコードの物理サイズを、ミリメートルで指定します。
* @throws NyARException
*/
- public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width)
+ public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width, int i_input_raster_type)
{
NyARIntSize scr_size = i_param.getScreenSize();
- NyARFixedFloatObserv2IdealMap dist_map = new NyARFixedFloatObserv2IdealMap(i_param.getDistortionFactor(), scr_size);
-
// 解析オブジェクトを作る
- this._square_detect = new NyARSquareDetector_X2(dist_map, scr_size);
- this._transmat = new NyARTransMat_X2(i_param);
+ //this._square_detect = new NyARSquareDetector_ARToolKit(i_param.getDistortionFactor(), scr_size);
+ this._square_detect = new NyARSquareDetector_Rle(i_param.getDistortionFactor(), scr_size);
+ this._transmat = new NyARTransMat(i_param);
this._marker_width = i_marker_width;
int cw = i_code.getWidth();
int ch = i_code.getHeight();
// 評価パターンのホルダを作る
- this._patt = new NyARColorPatt_O3(cw, ch);
+ //this._patt = new NyARColorPatt_O3(cw, ch);
+ this._patt = new NyARColorPatt_Perspective_O2(cw, ch,2,25);
// 評価器を作る。
this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);
//2値画像バッファを作る
this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
//差分データインスタンスの作成
this._deviation_data = new NyARMatchPattDeviationColorData(cw, ch);
+ this._tobin_filter= new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);
return;
}

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

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatIdeal2Observ.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatIdeal2Observ.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatIdeal2Observ.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_ARToolKit_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_ARToolKit_X2.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_ARToolKit_X2.cs (revision 304)
@@ -0,0 +1,189 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Diagnostics;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.core2;
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
+{
+
+
+ /**
+ * イメージから正方形候補を検出するクラス。
+ * このクラスは、arDetectMarker2.cとの置き換えになります。
+ *
+ */
+ public class NyARSquareDetector_ARToolKit_X2 : INyARSquareDetector
+ {
+ private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
+
+ private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
+ private int _width;
+ private int _height;
+
+ private NyARLabeling_ARToolKit _labeling;
+
+ private NyARLabelingImage _limage;
+
+ private LabelOverlapChecker<NyARLabelingLabel> _overlap_checker = new LabelOverlapChecker<NyARLabelingLabel>(32);
+ private SquareContourDetector_X2 _sqconvertor;
+ private ContourPickup _cpickup=new ContourPickup();
+
+ /**
+ * 最大i_squre_max個のマーカーを検出するクラスを作成する。
+ *
+ * @param i_param
+ */
+ public NyARSquareDetector_ARToolKit_X2(NyARCameraDistortionFactor i_dist_factor_ref, NyARIntSize i_size)
+ {
+ this._width = i_size.w;
+ this._height = i_size.h;
+ this._labeling = new NyARLabeling_ARToolKit();
+ this._sqconvertor = new SquareContourDetector_X2(i_size, i_dist_factor_ref);
+ this._limage = new NyARLabelingImage(this._width, this._height);
+
+
+ // 輪郭の最大長は画面に映りうる最大の長方形サイズ。
+ int number_of_coord = (this._width + this._height) * 2;
+
+ // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
+ this._max_coord = number_of_coord;
+ this._xcoord = new int[number_of_coord * 2];
+ this._ycoord = new int[number_of_coord * 2];
+ }
+
+ private int _max_coord;
+ private int[] _xcoord;
+ private int[] _ycoord;
+
+ /**
+ * arDetectMarker2を基にした関数
+ * この関数はNyARSquare要素のうち、directionを除くパラメータを取得して返します。
+ * directionの確定は行いません。
+ * @param i_raster
+ * 解析する2値ラスタイメージを指定します。
+ * @param o_square_stack
+ * 抽出した正方形候補を格納するリスト
+ * @throws NyARException
+ */
+ public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
+ {
+ NyARLabelingImage limage = this._limage;
+
+ // 初期化
+
+ // マーカーホルダをリセット
+ o_square_stack.clear();
+ // ラベリング
+ this._labeling.labeling(i_raster, this._limage);
+
+ // ラベル数が0ならここまで(Labeling内部でソートするようにした。)
+ int label_num = this._labeling.labeling(i_raster, limage);
+ if (label_num < 1) {
+ return;
+ }
+ NyARLabelingLabelStack stack = limage.getLabelStack();
+ //ラベルをソートしておく
+ stack.sortByArea();
+ NyARLabelingLabel[] labels = stack.getArray();
+
+ int i;
+ for (i = 0; i < label_num; i++)
+ {
+ // 検査対象内のラベルサイズになるまで無視
+ if (labels[i].area <= AR_AREA_MAX)
+ {
+ break;
+ }
+ }
+
+ int xsize = this._width;
+ int ysize = this._height;
+ int[] xcoord = this._xcoord;
+ int[] ycoord = this._ycoord;
+ int coord_max = this._max_coord;
+ LabelOverlapChecker<NyARLabelingLabel> overlap = this._overlap_checker;
+ int label_area;
+ NyARLabelingLabel label_pt;
+
+ //重なりチェッカの最大数を設定
+ overlap.setMaxLabels(label_num);
+
+ for (; i < label_num; i++) {
+ label_pt = labels[i];
+ label_area = label_pt.area;
+ // 検査対象サイズよりも小さくなったら終了
+ if (label_area < AR_AREA_MIN)
+ {
+ break;
+ }
+ // クリップ領域が画面の枠に接していれば除外
+ if (label_pt.clip_l == 1 || label_pt.clip_r == xsize - 2)
+ {// if(wclip[i*4+0] == 1 || wclip[i*4+1] ==xsize-2){
+ continue;
+ }
+ if (label_pt.clip_t == 1 || label_pt.clip_b == ysize - 2)
+ {// if( wclip[i*4+2] == 1 || wclip[i*4+3] ==ysize-2){
+ continue;
+ }
+
+ // 既に検出された矩形との重なりを確認
+ if (!overlap.check(label_pt)) {
+ // 重なっているようだ。
+ continue;
+ }
+
+ // 輪郭を取得
+ int coord_num = _cpickup.getContour(limage, limage.getTopClipTangentX(label_pt), label_pt.clip_t, coord_max, xcoord, ycoord);
+ if (coord_num == coord_max)
+ {
+ // 輪郭が大きすぎる。
+ continue;
+ }
+ //輪郭分析用に正規化する。
+ int vertex1 = SquareContourDetector.normalizeCoord(xcoord, ycoord, coord_num);
+
+ //ここから先が輪郭分析
+ NyARSquare square_ptr = o_square_stack.prePush();
+ if(!this._sqconvertor.coordToSquare(xcoord,ycoord,vertex1,coord_num,label_area,square_ptr)){
+ o_square_stack.pop();// 頂点の取得が出来なかったので破棄
+ continue;
+ }
+ // 検出済の矩形の属したラベルを重なりチェックに追加する。
+ overlap.push(label_pt);
+ }
+ return;
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotVector.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotVector.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotVector.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloat16Mat.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloat16Mat.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloat16Mat.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatPca2d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatPca2d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatPca2d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotMatrix.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotMatrix.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotMatrix.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatFitVecCalculator.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatFitVecCalculator.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatFitVecCalculator.cs (revision 304)
@@ -1,4 +1,34 @@
-using System;
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using jp.nyatla.nyartoolkit.cs.core;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARTransMat_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARTransMat_X2.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARTransMat_X2.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -216,9 +215,6 @@

NyARFixedFloat16Point3d angle=i_rot.refAngle();

- o_result.angle.x = (double)angle.x / NyMath.FIXEDFLOAT16_1;
- o_result.angle.y = (double)angle.y / NyMath.FIXEDFLOAT16_1;
- o_result.angle.z = (double)angle.z / NyMath.FIXEDFLOAT16_1;
o_result.has_value = true;
return;
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotTransOptimize_O2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotTransOptimize_O2.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatRotTransOptimize_O2.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatTransOffset.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatTransOffset.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARFixedFloatTransOffset.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_Rle_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_Rle_X2.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyARSquareDetector_Rle_X2.cs (revision 304)
@@ -0,0 +1,168 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Diagnostics;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.core2;
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
+{
+
+
+ /**
+ * イメージから正方形候補を検出するクラス。
+ * このクラスは、arDetectMarker2.cとの置き換えになります。
+ *
+ */
+ public class NyARSquareDetector_Rle_X2 : INyARSquareDetector
+ {
+ private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
+
+ private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
+ private int _width;
+ private int _height;
+
+ private NyARLabeling_Rle _labeling;
+
+
+ private LabelOverlapChecker<RleLabelFragmentInfoStack.RleLabelFragmentInfo> _overlap_checker = new LabelOverlapChecker<RleLabelFragmentInfoStack.RleLabelFragmentInfo>(32);
+ private SquareContourDetector_X2 _sqconvertor;
+ private ContourPickup _cpickup=new ContourPickup();
+ private RleLabelFragmentInfoStack _stack;
+
+ /**
+ * 最大i_squre_max個のマーカーを検出するクラスを作成する。
+ *
+ * @param i_param
+ */
+ public NyARSquareDetector_Rle_X2(NyARCameraDistortionFactor i_dist_factor_ref, NyARIntSize i_size)
+ {
+ this._width = i_size.w;
+ this._height = i_size.h;
+ this._labeling = new NyARLabeling_Rle(this._width,this._height);
+ this._sqconvertor = new SquareContourDetector_X2(i_size, i_dist_factor_ref);
+ this._stack = new RleLabelFragmentInfoStack(i_size.w * i_size.h * 2048 / (320 * 240) + 32);//検出可能な最大ラベル数
+
+
+ // 輪郭の最大長は画面に映りうる最大の長方形サイズ。
+ int number_of_coord = (this._width + this._height) * 2;
+
+ // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
+ this._max_coord = number_of_coord;
+ this._xcoord = new int[number_of_coord * 2];
+ this._ycoord = new int[number_of_coord * 2];
+ }
+
+ private int _max_coord;
+ private int[] _xcoord;
+ private int[] _ycoord;
+
+ /**
+ * arDetectMarker2を基にした関数
+ * この関数はNyARSquare要素のうち、directionを除くパラメータを取得して返します。
+ * directionの確定は行いません。
+ * @param i_raster
+ * 解析する2値ラスタイメージを指定します。
+ * @param o_square_stack
+ * 抽出した正方形候補を格納するリスト
+ * @throws NyARException
+ */
+ public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
+ {
+ RleLabelFragmentInfoStack flagment=this._stack;
+ LabelOverlapChecker<RleLabelFragmentInfoStack.RleLabelFragmentInfo> overlap = this._overlap_checker;
+
+ // 初期化
+
+ // マーカーホルダをリセット
+ o_square_stack.clear();
+ this._labeling.labeling(i_raster, 0, i_raster.getHeight(), flagment);
+
+ // ラベル数が0ならここまで(Labeling内部でソートするようにした。)
+ int label_num=this._labeling.labeling(i_raster, 0, i_raster.getHeight(), flagment);
+ if (label_num < 1) {
+ return;
+ }
+ //ラベルをソートしておく
+ flagment.sortByArea();
+
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo[] labels = flagment.getArray();
+
+ int xsize = this._width;
+ int ysize = this._height;
+ int[] xcoord = this._xcoord;
+ int[] ycoord = this._ycoord;
+ int coord_max = this._max_coord;
+
+ //重なりチェッカの最大数を設定
+ overlap.setMaxLabels(label_num);
+
+ for (int i=0; i < label_num; i++) {
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo label_pt=labels[i];
+ int label_area = label_pt.area;
+
+ // クリップ領域が画面の枠に接していれば除外
+ if (label_pt.clip_l == 0 || label_pt.clip_r == xsize-1){
+ continue;
+ }
+ if (label_pt.clip_t == 0 || label_pt.clip_b == ysize-1){
+ continue;
+ }
+ // 既に検出された矩形との重なりを確認
+ if (!overlap.check(label_pt)) {
+ // 重なっているようだ。
+ continue;
+ }
+
+ // 輪郭を取得
+ int coord_num = _cpickup.getContour(i_raster,label_pt.entry_x,label_pt.clip_t, coord_max, xcoord, ycoord);
+ if (coord_num == coord_max) {
+ // 輪郭が大きすぎる。
+ continue;
+ }
+ //輪郭分析用に正規化する。
+ int vertex1 = SquareContourDetector_X2.normalizeCoord(xcoord, ycoord, coord_num);
+
+ //ここから先が輪郭分析
+ NyARSquare square_ptr = o_square_stack.prePush();
+ if(!this._sqconvertor.coordToSquare(xcoord,ycoord,vertex1,coord_num,label_area,square_ptr)){
+ o_square_stack.pop();// 頂点の取得が出来なかったので破棄
+ continue;
+ }
+ // 検出済の矩形の属したラベルを重なりチェックに追加する。
+ overlap.push(label_pt);
+ }
+ return;
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyMath.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyMath.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/NyMath.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/SingleARMarkerProcesser_X2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/SingleARMarkerProcesser_X2.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS.sandbox/cs/x2/SingleARMarkerProcesser_X2.cs (revision 304)
@@ -0,0 +1,395 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.core2;
+
+namespace jp.nyatla.nyartoolkit.cs.sandbox.x2
+{
+ /**
+ * このクラスは、同時に1個のマーカを処理することのできる、アプリケーションプロセッサです。
+ * マーカの出現・移動・消滅を、イベントで通知することができます。
+ * クラスには複数のマーカを登録できます。一つのマーカが見つかると、プロセッサは継続して同じマーカを
+ * 1つだけ認識し続け、見失うまでの間は他のマーカを認識しません。
+ *
+ * イベントは、 OnEnter→OnUpdate[n]→OnLeaveの順で発生します。
+ * マーカが見つかるとまずOnEnterが1度発生して、何番のマーカが発見されたかがわかります。
+ * 次にOnUpdateにより、現在の変換行列が連続して渡されます。最後にマーカを見失うと、OnLeave
+ * イベントが発生します。
+ *
+ */
+ public abstract class SingleARMarkerProcesser_X2
+ {
+ /**
+ * [[STRAGE CLASS]]
+ * selectARCodeIndexFromListが値を返す時に使う変数型です。
+ */
+
+ private class TResult_selectARCodeIndex
+ {
+ public int direction;
+
+ public double confidence;
+
+ public int code_index;
+ }
+ /**オーナーが自由に使えるタグ変数です。
+ */
+ public object tag;
+
+ private int _lost_delay_count = 0;
+
+ private int _lost_delay = 5;
+
+ private INyARSquareDetector _square_detect;
+
+ protected NyARTransMat_X2 _transmat;
+
+ private double _marker_width;
+
+ private NyARMatchPatt_Color_WITHOUT_PCA[] _match_patt;
+
+ private NyARSquareStack _square_list = new NyARSquareStack(100);
+
+ private NyARColorPatt_Perspective_O2 _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;
+
+ protected int _current_arcode_index = -1;
+
+ private NyARMatchPattDeviationColorData _deviation_data;
+ private NyARRasterThresholdAnalyzer_SlidePTile _threshold_detect;
+
+
+ protected SingleARMarkerProcesser_X2()
+ {
+ return;
+ }
+
+
+ protected void initInstance(NyARParam i_param,int i_raster_type)
+ {
+ NyARIntSize scr_size = i_param.getScreenSize();
+ // 解析オブジェクトを作る
+ this._square_detect = new NyARSquareDetector_Rle_X2(i_param.getDistortionFactor(), scr_size);
+ this._transmat = new NyARTransMat_X2(i_param);
+ this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(110,i_raster_type);
+
+ // 2値画像バッファを作る
+ this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ this._threshold_detect = new NyARRasterThresholdAnalyzer_SlidePTile(15, i_raster_type, 4);
+ return;
+ }
+ /*自動・手動の設定が出来ないので、コメントアウト
+ public void setThreshold(int i_threshold)
+ {
+ this._threshold = i_threshold;
+ return;
+ }*/
+
+ /**検出するマーカコードの配列を指定します。 検出状態でこの関数を実行すると、
+ * オブジェクト状態に強制リセットがかかります。
+ */
+ public void setARCodeTable(NyARCode[] i_ref_code_table, int i_code_resolution, double i_marker_width)
+ {
+ if (this._current_arcode_index != -1)
+ {
+ // 強制リセット
+ reset(true);
+ }
+ // 検出するマーカセット、情報、検出器を作り直す。
+ this._patt = new NyARColorPatt_Perspective_O2(i_code_resolution, i_code_resolution,4,25);
+ this._deviation_data = new NyARMatchPattDeviationColorData(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)
+ {
+ // 強制書き換えでなければイベントコール
+ this.onLeaveHandler();
+ }
+ // カレントマーカをリセット
+ this._current_arcode_index = -1;
+ return;
+ }
+
+ public void detectMarker(INyARRgbRaster i_raster)
+ {
+ // サイズチェック
+ if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h))
+ {
+ throw new NyARException();
+ }
+
+ // コードテーブルが無ければここで終わり
+ if (this._match_patt == null)
+ {
+ return;
+ }
+
+ // ラスタを(1/4の画像の)2値イメージに変換する.
+ this._tobin_filter.setThreshold(this._threshold);
+ this._tobin_filter.doFilter(i_raster, this._bin_raster);
+
+ NyARSquareStack square_stack = this._square_list;
+ // スクエアコードを探す
+ 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のリストから、最も一致するコード番号を検索します。
+ */
+ private bool selectARCodeIndexFromList(INyARRgbRaster i_raster, NyARSquare i_square, TResult_selectARCodeIndex o_result)
+ {
+ // 現在コードテーブルはアクティブ?
+ if (this._match_patt == null)
+ {
+ return false;
+ }
+ // 評価基準になるパターンをイメージから切り出す
+ 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();
+
+ /**新規マーカ検索 現在認識中のマーカがないものとして、最も認識しやすいマーカを1個認識します。
+ */
+ 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))
+ {
+ // 見つからない。
+ 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;
+ }
+ // 認識状態を更新
+ bool is_id_found=updateStatus(this._square_list.getItem(square_index), code_index, cf, dir);
+ //閾値フィードバック(detectExistMarkerにもあるよ)
+ if(!is_id_found){
+ //マーカがなければ、探索+DualPTailで基準輝度検索
+ this._threshold_detect.analyzeRaster(i_raster);
+ this._threshold=(this._threshold+this._threshold_detect.getThreshold())/2;
+ }
+ }
+
+ /**マーカの継続認識 現在認識中のマーカを優先して認識します。
+ * (注)この機能はたぶん今後いろいろ発展するからNewと混ぜないこと。
+ */
+ 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))
+ {
+ // 見つからない。
+ 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;
+ }
+ // 認識状態を更新
+ bool is_id_found=updateStatus(this._square_list.getItem(square_index), code_index, cf, dir);
+ //閾値フィードバック(detectExistMarkerにもあるよ)
+ if (!is_id_found)
+ {
+ //マーカがなければ、探索+DualPTailで基準輝度検索
+ this._threshold_detect.analyzeRaster(i_raster);
+ this._threshold = (this._threshold + this._threshold_detect.getThreshold()) / 2;
+ }
+
+ }
+
+ private NyARTransMatResult __NyARSquare_result = new NyARTransMatResult();
+
+ /**オブジェクトのステータスを更新し、必要に応じてハンドル関数を駆動します。
+ */
+ private bool 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)
+ {// 未認識から未認識の遷移
+ // なにもしないよーん
+ return false;
+ }
+ 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;
+ return true;
+ }
+ }
+ 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();
+ }
+ return false;
+ }
+ 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;
+ return true;
+ }
+ else
+ {// 異なるコードの認識→今はサポートしない。
+ throw new NyARException();
+ }
+ }
+ }
+
+ protected abstract void onEnterHandler(int i_code);
+
+ protected abstract void onLeaveHandler();
+
+ protected abstract void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result);
+ }
+
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/NyARToolkitCS.csproj
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/NyARToolkitCS.csproj (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/NyARToolkitCS.csproj (revision 304)
@@ -49,13 +49,15 @@
<Compile Include="cs\core2\types\NyARI64Linear.cs" />
<Compile Include="cs\core2\types\NyARI64Point2d.cs" />
<Compile Include="cs\core2\types\NyARI64Point3d.cs" />
- <Compile Include="cs\core\INyARSquareDetector.cs" />
- <Compile Include="cs\core\labeling\INyARLabeling.cs" />
- <Compile Include="cs\core\labeling\INyARLabelingImage.cs" />
- <Compile Include="cs\core\labeling\NyARLabelingImage.cs" />
- <Compile Include="cs\core\labeling\NyARLabelingLabel.cs" />
- <Compile Include="cs\core\labeling\NyARLabelingLabelStack.cs" />
- <Compile Include="cs\core\labeling\NyARLabeling_ARToolKit.cs" />
+ <Compile Include="cs\core\labeling\artoolkit\NyARLabelingImage.cs" />
+ <Compile Include="cs\core\labeling\artoolkit\NyARLabelingLabel.cs" />
+ <Compile Include="cs\core\labeling\artoolkit\NyARLabelingLabelStack.cs" />
+ <Compile Include="cs\core\labeling\artoolkit\NyARLabeling_ARToolKit.cs" />
+ <Compile Include="cs\core\labeling\LabelOverlapChecker.cs" />
+ <Compile Include="cs\core\labeling\NyARLabelInfo.cs" />
+ <Compile Include="cs\core\labeling\NyARLabelInfoStack.cs" />
+ <Compile Include="cs\core\labeling\rlelabeling\NyARLabeling_Rle.cs" />
+ <Compile Include="cs\core\labeling\rlelabeling\RleLabelFragmentInfoStack.cs" />
<Compile Include="cs\core\match\INyARMatchPatt.cs" />
<Compile Include="cs\core\match\NyARMatchPattDeviationBlackWhiteData.cs" />
<Compile Include="cs\core\match\NyARMatchPattDeviationColorData.cs" />
@@ -63,8 +65,6 @@
<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" />
- <Compile Include="cs\core\NyARSquareStack.cs" />
<Compile Include="cs\core\param\INyARCameraDistortionFactor.cs" />
<Compile Include="cs\core\param\NyARCameraDistortionFactor.cs" />
<Compile Include="cs\core\param\NyARObserv2IdealMap.cs" />
@@ -77,6 +77,7 @@
<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\pickup\NyARColorPatt_Perspective_O2.cs" />
<Compile Include="cs\core\rasterfilter\INyARRasterFilter.cs" />
<Compile Include="cs\core\rasterfilter\INyARRasterFilter_GsToBin.cs" />
<Compile Include="cs\core\rasterfilter\INyARRasterFilter_RgbToGs.cs" />
@@ -85,7 +86,7 @@
<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_GRAY_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" />
@@ -98,17 +99,29 @@
<Compile Include="cs\core\raster\rgb\NyARRgbRaster_BGRA.cs" />
<Compile Include="cs\core\raster\rgb\NyARRgbRaster_Blank.cs" />
<Compile Include="cs\core\raster\rgb\NyARRgbRaster_RGB.cs" />
- <Compile Include="cs\core\transmat\fitveccalc\NyARFitVecCalculator.cs" />
+ <Compile Include="cs\core\squaredetect\ContourPickup.cs" />
+ <Compile Include="cs\core\squaredetect\INyARSquareDetector.cs" />
+ <Compile Include="cs\core\squaredetect\NyARSquare.cs" />
+ <Compile Include="cs\core\squaredetect\NyARSquareDetector_ARToolKit.cs" />
+ <Compile Include="cs\core\squaredetect\NyARSquareDetector_Rle.cs" />
+ <Compile Include="cs\core\squaredetect\NyARSquareStack.cs" />
+ <Compile Include="cs\core\squaredetect\NyARVertexCounter.cs" />
+ <Compile Include="cs\core\squaredetect\SquareContourDetector.cs" />
<Compile Include="cs\core\transmat\INyARTransMat.cs" />
<Compile Include="cs\core\transmat\NyARTransMat.cs" />
<Compile Include="cs\core\transmat\NyARTransMatResult.cs" />
+ <Compile Include="cs\core\transmat\NyARTransMat_ARToolKit.cs" />
<Compile Include="cs\core\transmat\NyARTransOffset.cs" />
- <Compile Include="cs\core\transmat\optimize\INyARRotTransOptimize.cs" />
- <Compile Include="cs\core\transmat\optimize\NyARRotTransOptimize.cs" />
+ <Compile Include="cs\core\transmat\optimize\artoolkit\INyARRotTransOptimize.cs" />
+ <Compile Include="cs\core\transmat\optimize\artoolkit\NyARRotTransOptimize.cs" />
+ <Compile Include="cs\core\transmat\optimize\NyARPartialDifferentiationOptimize.cs" />
<Compile Include="cs\core\transmat\rotmatrix\NyARRotMatrix.cs" />
<Compile Include="cs\core\transmat\rotmatrix\NyARRotMatrix_ARToolKit.cs" />
- <Compile Include="cs\core\transmat\rotmatrix\NyARRotMatrix_NyARToolKit.cs" />
+ <Compile Include="cs\core\transmat\rotmatrix\NyARRotMatrix_ARToolKit_O2.cs" />
<Compile Include="cs\core\transmat\rotmatrix\NyARRotVector.cs" />
+ <Compile Include="cs\core\transmat\solver\INyARTransportVectorSolver.cs" />
+ <Compile Include="cs\core\transmat\solver\NyARTransportVectorSolver.cs" />
+ <Compile Include="cs\core\transmat\solver\NyARTransportVectorSolver_ARToolKit.cs" />
<Compile Include="cs\core\types\matrix\INyARDoubleMatrix.cs" />
<Compile Include="cs\core\types\matrix\NyARDoubleMatrix22.cs" />
<Compile Include="cs\core\types\matrix\NyARDoubleMatrix33.cs" />
@@ -123,19 +136,17 @@
<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\NyAREquationSolver.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" />
<Compile Include="cs\core\NyARVersion.cs" />
<Compile Include="cs\core\NyARVec.cs" />
<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" />
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/processor/SingleARMarkerProcesser.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/processor/SingleARMarkerProcesser.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/processor/SingleARMarkerProcesser.cs (revision 304)
@@ -7,34 +7,33 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using jp.nyatla.nyartoolkit.cs.core;
+using jp.nyatla.nyartoolkit.cs.core2;

-
namespace jp.nyatla.nyartoolkit.cs.processor
{
/**
@@ -72,9 +71,9 @@

private int _lost_delay = 5;

- private NyARSquareDetector _square_detect;
+ private INyARSquareDetector _square_detect;

- protected NyARTransMat _transmat;
+ protected INyARTransMat _transmat;

private double _marker_width;

@@ -82,7 +81,7 @@

private NyARSquareStack _square_list = new NyARSquareStack(100);

- private NyARColorPatt_O3 _patt = null;
+ private NyARColorPatt_Perspective_O2 _patt = null;

private double _cf_threshold_new = 0.30;

@@ -92,35 +91,43 @@
// [AR]検出結果の保存用
private NyARBinRaster _bin_raster;

- private NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110);
+ private NyARRasterFilter_ARToolkitThreshold _tobin_filter;

protected int _current_arcode_index = -1;

private NyARMatchPattDeviationColorData _deviation_data;
+ private NyARRasterThresholdAnalyzer_SlidePTile _threshold_detect;


- public SingleARMarkerProcesser(NyARParam i_param)
- {
- NyARIntSize scr_size = i_param.getScreenSize();
- // 解析オブジェクトを作る
- 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);
+ protected SingleARMarkerProcesser()
+ {
+ return;
+ }

- // 2値画像バッファを作る
- this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+
+ protected void initInstance(NyARParam i_param,int i_raster_type)
+ {
+ NyARIntSize scr_size = i_param.getScreenSize();
+ // 解析オブジェクトを作る
+ this._square_detect = new NyARSquareDetector_Rle(i_param.getDistortionFactor(), scr_size);
+ this._transmat = new NyARTransMat(i_param);
+ this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(110,i_raster_type);
+
+ // 2値画像バッファを作る
+ this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
+ this._threshold_detect = new NyARRasterThresholdAnalyzer_SlidePTile(15, i_raster_type, 4);
return;
- }
-
+ }
+ /*自動・手動の設定が出来ないので、コメントアウト
public void setThreshold(int i_threshold)
{
this._threshold = i_threshold;
return;
- }
+ }*/

- /**検出するマーカコードの配列を指定します。 検出状態でこの関数を実行すると、
- * オブジェクト状態に強制リセットがかかります。
- */
+ /**検出するマーカコードの配列を指定します。 検出状態でこの関数を実行すると、
+ * オブジェクト状態に強制リセットがかかります。
+ */
public void setARCodeTable(NyARCode[] i_ref_code_table, int i_code_resolution, double i_marker_width)
{
if (this._current_arcode_index != -1)
@@ -129,7 +136,8 @@
reset(true);
}
// 検出するマーカセット、情報、検出器を作り直す。
- this._patt = new NyARColorPatt_O3(i_code_resolution, i_code_resolution);
+ this._patt = new NyARColorPatt_Perspective_O2(i_code_resolution, i_code_resolution,4,25);
+ this._deviation_data = new NyARMatchPattDeviationColorData(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];
@@ -155,7 +163,7 @@
public void detectMarker(INyARRgbRaster i_raster)
{
// サイズチェック
- if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize().w / 2, i_raster.getSize().h / 2))
+ if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h))
{
throw new NyARException();
}
@@ -260,7 +268,13 @@
dir = detect_result.direction;
}
// 認識状態を更新
- updateStatus((NyARSquare)this._square_list.getItem(square_index), code_index, cf, dir);
+ bool is_id_found=updateStatus(this._square_list.getItem(square_index), code_index, cf, dir);
+ //閾値フィードバック(detectExistMarkerにもあるよ)
+ if(!is_id_found){
+ //マーカがなければ、探索+DualPTailで基準輝度検索
+ this._threshold_detect.analyzeRaster(i_raster);
+ this._threshold=(this._threshold+this._threshold_detect.getThreshold())/2;
+ }
}

/**マーカの継続認識 現在認識中のマーカを優先して認識します。
@@ -302,21 +316,30 @@
square_index = i;
}
// 認識状態を更新
- updateStatus((NyARSquare)this._square_list.getItem(square_index), code_index, cf, dir);
+ bool is_id_found=updateStatus(this._square_list.getItem(square_index), code_index, cf, dir);
+ //閾値フィードバック(detectExistMarkerにもあるよ)
+ if (!is_id_found)
+ {
+ //マーカがなければ、探索+DualPTailで基準輝度検索
+ this._threshold_detect.analyzeRaster(i_raster);
+ this._threshold = (this._threshold + this._threshold_detect.getThreshold()) / 2;
+ }
+
}

private NyARTransMatResult __NyARSquare_result = new NyARTransMatResult();

/**オブジェクトのステータスを更新し、必要に応じてハンドル関数を駆動します。
*/
- private void updateStatus(NyARSquare i_square, int i_code_index, double i_cf, int i_dir)
+ private bool 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)
{// 未認識から未認識の遷移
- // なにもしないよーん。
+ // なにもしないよーん
+ return false;
}
else
{// 未認識から認識の遷移
@@ -329,6 +352,7 @@
// OnUpdate
this.onUpdateHandler(i_square, result);
this._lost_delay_count = 0;
+ return true;
}
}
else
@@ -342,6 +366,7 @@
this._current_arcode_index = -1;
this.onLeaveHandler();
}
+ return false;
}
else if (i_code_index == this._current_arcode_index)
{// 同じARCodeの再認識
@@ -351,13 +376,13 @@
// OnUpdate
this.onUpdateHandler(i_square, result);
this._lost_delay_count = 0;
+ return true;
}
else
{// 異なるコードの認識→今はサポートしない。
throw new NyARException();
}
}
- return;
}

protected abstract void onEnterHandler(int i_code);
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/processor/SingleNyIdMarkerProcesser.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/processor/SingleNyIdMarkerProcesser.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/processor/SingleNyIdMarkerProcesser.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -52,8 +51,8 @@
private int _lost_delay_count = 0;
private int _lost_delay = 5;

- private NyARSquareDetector _square_detect;
- protected NyARTransMat _transmat;
+ private INyARSquareDetector _square_detect;
+ protected INyARTransMat _transmat;
private double _marker_width=100;

private NyARSquareStack _square_list = new NyARSquareStack(100);
@@ -66,16 +65,20 @@
// [AR]検出結果の保存用
private NyARBinRaster _bin_raster;

- private NyARRasterFilter_ARToolkitThreshold _tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110);

+ private NyARRasterFilter_ARToolkitThreshold _tobin_filter;
private NyIdMarkerPickup _id_pickup = new NyIdMarkerPickup();


- protected SingleNyIdMarkerProcesser(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format)
+ protected SingleNyIdMarkerProcesser()
{
+ return;
+ }
+ protected void initInstance(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format)
+ {
NyARIntSize scr_size = i_param.getScreenSize();
// 解析オブジェクトを作る
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
+ this._square_detect = new NyARSquareDetector_Rle(i_param.getDistortionFactor(), scr_size);
this._transmat = new NyARTransMat(i_param);
this._encoder=i_encoder;

@@ -85,10 +88,13 @@
this._is_active=false;
this._data_temp=i_encoder.createDataInstance();
this._data_current=i_encoder.createDataInstance();
+ this._tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110,i_raster_format);
this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,i_raster_format,4);
return;
+
}

+
public void setMarkerWidth(int i_width)
{
this._marker_width=i_width;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/NyObjectStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/NyObjectStack.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/NyObjectStack.cs (revision 304)
@@ -1,39 +1,39 @@
/*
* PROJECT: NyARToolkitCS
* --------------------------------------------------------------------------------
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
+using System.Diagnostics;
namespace jp.nyatla.nyartoolkit.cs.utils
{
/**
* オンデマンド割り当てをするオブジェクト配列。
* 配列には実体を格納します。
*/
- public abstract class NyObjectStack
+ public abstract class NyObjectStack<T>
{
private const int ARRAY_APPEND_STEP = 64;

- protected object[] _items;
+ protected T[] _items;

private int _allocated_size;

@@ -44,20 +44,22 @@
*
* @param i_array
*/
- public NyObjectStack(object[] i_array)
+ protected NyObjectStack(int i_length)
{
// ポインタだけははじめに確保しておく
- this._items = i_array;
+ this._items = new T[i_length];
// アロケート済サイズと、使用中個数をリセット
this._allocated_size = 0;
this._length = 0;
}
+
+ protected abstract T createElement();

/**
* ポインタを1進めて、その要素を予約し、その要素へのポインタを返します。
* 特定型に依存させるときには、継承したクラスでこの関数をオーバーライドしてください。
*/
- virtual public object prePush()
+ virtual public T prePush()
{
// 必要に応じてアロケート
if (this._length >= this._allocated_size)
@@ -78,28 +80,34 @@
this._allocated_size = range;
}
// 使用領域を+1して、予約した領域を返す。
- object ret = this._items[this._length];
+ T ret = this._items[this._length];
this._length++;
return ret;
}
- /**
- * 見かけ上の要素数を1減らして、最後尾のアイテムを返します。
- * @return
- */
- virtual public object pop()
- {
- if (this._length < 1)
- {
- throw new NyARException();
- }
- this._length--;
- return this.getItem(this._length);
- }
- /**
- * 0~i_number_of_item-1までの領域を予約します。
- * 予約すると、見かけ上の要素数は0にリセットされます。
- * @param i_number_of_reserv
- */
+ public T pop()
+ {
+ Debug.Assert(this._length>=1);
+ this._length--;
+ return this._items[this._length];
+ }
+ /**
+ * 見かけ上の要素数をi_count個減らします。
+ * @param i_count
+ * @return
+ * NULLを返します。
+ */
+ public void pops(int i_count)
+ {
+ Debug.Assert(this._length>=i_count);
+ this._length-=i_count;
+ return;
+ }
+
+ /**
+ * 0~i_number_of_item-1までの領域を予約します。
+ * 予約済の領域よりも小さい場合には、現在の長さを調整します。
+ * @param i_number_of_reserv
+ */
virtual public void reserv(int i_number_of_item)
{
// 必要に応じてアロケート
@@ -130,26 +138,23 @@
*
* @return
*/
- virtual protected object[] getArray()
+ virtual public T[] getArray()
{
return this._items;
}
- virtual protected object getItem(int i_index)
+ virtual public T getItem(int i_index)
{
return this._items[i_index];
}

+ protected void onReservRequest(int i_start, int i_end, T[] i_buffer)
+ {
+ for (int i = i_start; i < i_end; i++){
+ i_buffer[i] = createElement();
+ }
+ return;
+ }
/**
- * この関数を継承先クラスで実装して下さい。
- * i_bufferの配列の、i_start番目からi_end-1番目までの要素に、オブジェクトを割り当てて下さい。
- *
- * @param i_start
- * @param i_end
- * @param i_buffer
- */
- protected abstract void onReservRequest(int i_start, int i_end, object[] i_buffer);
-
- /**
* 配列の見かけ上の要素数を返却します。
* @return
*/
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/DoubleValue.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/DoubleValue.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/DoubleValue.cs (revision 304)
@@ -1,26 +1,25 @@
/*
* PROJECT: NyARToolkitCS
* --------------------------------------------------------------------------------
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.utils
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/IntValue.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/IntValue.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils/IntValue.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.utils
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils.cs/ArrayUtils.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils.cs/ArrayUtils.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/utils.cs/ArrayUtils.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -34,7 +33,19 @@
using System.Text;

namespace jp.nyatla.nyartoolkit.cs.utils
-{
+{/*
+ public class Array2<T> where T : new()
+ {
+ public T[] createArray(int i_length)
+ {
+ T[] ret = new T[i_length];
+ for (int i = 0; i < i_length; i++)
+ {
+ ret[i]=new T();
+ }
+ return ret;
+ }
+ }*/
public class ArrayUtils
{
public static double[][] newDouble2dArray(int i_r, int i_c)
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPickup.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPickup.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPickup.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPattern.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPattern.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerPattern.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerData_RawBit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerData_RawBit.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/NyIdMarkerData_RawBit.cs (revision 304)
@@ -1,4 +1,29 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * 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;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerData.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerData.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerData.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerDataEncoder.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerDataEncoder.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/data/INyIdMarkerDataEncoder.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerParam.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerParam.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/nyidmarker/NyIdMarkerParam.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquareStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquareStack.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquareStack.cs (revision 304)
@@ -1,66 +0,0 @@
-/*
- * 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 jp.nyatla.nyartoolkit.cs.utils;
-
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- public class NyARSquareStack : NyObjectStack
- {
- public NyARSquareStack(int i_length): base(new NyARSquare[i_length])
- {
-
-
- }
-
- override protected void onReservRequest(int i_start, int i_end, object[] i_buffer)
- {
- for (int i = i_start; i < i_end; i++)
- {
- i_buffer[i] = new NyARSquare();
- }
- }
-
- new public NyARSquare[] getArray()
- {
- return (NyARSquare[])this._items;
- }
- new public NyARSquare getItem(int i_index)
- {
- return (NyARSquare)this._items[i_index];
- }
-
- new public NyARSquare prePush()
- {
- return (NyARSquare)base.prePush();
- }
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquareDetector.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquareDetector.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquareDetector.cs (revision 304)
@@ -1,497 +0,0 @@
-/*
- * 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.Diagnostics;
-namespace jp.nyatla.nyartoolkit.cs.core
-{
-
- /**
- * イメージから正方形候補を検出するクラス。
- * このクラスは、arDetectMarker2.cとの置き換えになります。
- *
- */
- public class NyARSquareDetector : INyARSquareDetector
- {
- private const double VERTEX_FACTOR = 1.0;// 線検出のファクタ
-
- private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
-
- private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
- private int _width;
- private int _height;
-
- private NyARLabeling_ARToolKit _labeling;
-
- private NyARLabelingImage _limage;
-
- private OverlapChecker _overlap_checker = new OverlapChecker();
- private NyARObserv2IdealMap _dist_factor;
- private double[] _xpos;
- private double[] _ypos;
-
- /**
- * 最大i_squre_max個のマーカーを検出するクラスを作成する。
- *
- * @param i_param
- */
- public NyARSquareDetector(NyARCameraDistortionFactor i_dist_factor_ref, NyARIntSize i_size)
- {
- this._width = i_size.w;
- this._height = i_size.h;
- //歪み計算テーブルを作ると、8*width/height*2の領域を消費します。
- //領域を取りたくない場合は、i_dist_factor_refの値をそのまま使ってください。
- this._dist_factor = new NyARObserv2IdealMap(i_dist_factor_ref, i_size);
- this._labeling = new NyARLabeling_ARToolKit();
- this._limage = new NyARLabelingImage(this._width, this._height);
- this._labeling.attachDestination(this._limage);
-
- // 輪郭の最大長は画面に映りうる最大の長方形サイズ。
- int number_of_coord = (this._width + this._height) * 2;
-
- // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
- this._max_coord = number_of_coord;
- this._xcoord = new int[number_of_coord * 2];
- this._ycoord = new int[number_of_coord * 2];
- //PCA(最大頂点数は対角線長さ以上)
- this._pca = new NyARPca2d_MatrixPCA_O2();
- this._xpos = new double[this._width + this._height];//最大辺長はthis._width+this._height
- this._ypos = new double[this._width + this._height];//最大辺長はthis._width+this._height
- return;
- }
-
- private int _max_coord;
- private int[] _xcoord;
- private int[] _ycoord;
-
- private void normalizeCoord(int[] i_coord_x, int[] i_coord_y, int i_index, int i_coord_num)
- {
- // vertex1を境界にして、後方に配列を連結
- Array.Copy(i_coord_x, 1, i_coord_x, i_coord_num, i_index);
- Array.Copy(i_coord_y, 1, i_coord_y, i_coord_num, i_index);
- }
-
- private int[] __detectMarker_mkvertex = new int[5];
-
- /**
- * ARMarkerInfo2 *arDetectMarker2( ARInt16 *limage, int label_num, int *label_ref,int *warea, double *wpos, int *wclip,int area_max, int area_min, double
- * factor, int *marker_num ) 関数の代替品 ラベリング情報からマーカー一覧を作成してo_marker_listを更新します。 関数はo_marker_listに重なりを除外したマーカーリストを作成します。
- *
- * @param i_raster
- * 解析する2値ラスタイメージを指定します。
- * @param o_square_stack
- * 抽出した正方形候補を格納するリスト
- * @throws NyARException
- */
- public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
- {
- INyARLabeling labeling_proc = this._labeling;
- NyARLabelingImage limage = this._limage;
-
- // 初期化
-
- // マーカーホルダをリセット
- o_square_stack.clear();
-
- // ラベリング
- labeling_proc.labeling(i_raster);
-
- // ラベル数が0ならここまで
- int label_num = limage.getLabelStack().getLength();
- if (label_num < 1)
- {
- return;
- }
-
- NyARLabelingLabelStack stack = limage.getLabelStack();
- NyARLabelingLabel[] labels = stack.getArray();
-
-
- // ラベルを大きい順に整列
- stack.sortByArea();
-
- // デカいラベルを読み飛ばし
- int i;
- for (i = 0; i < label_num; i++)
- {
- // 検査対象内のラベルサイズになるまで無視
- if (labels[i].area <= AR_AREA_MAX)
- {
- break;
- }
- }
-
- int xsize = this._width;
- int ysize = this._height;
- int[] xcoord = this._xcoord;
- int[] ycoord = this._ycoord;
- int coord_max = this._max_coord;
- int[] mkvertex = this.__detectMarker_mkvertex;
- OverlapChecker overlap = this._overlap_checker;
- int coord_num;
- int label_area;
- NyARLabelingLabel label_pt;
-
- //重なりチェッカの最大数を設定
- overlap.reset(label_num);
- int vertex1;
- for (; i < label_num; i++)
- {
- label_pt = labels[i];
- label_area = label_pt.area;
- // 検査対象サイズよりも小さくなったら終了
- if (label_area < AR_AREA_MIN)
- {
- break;
- }
- // クリップ領域が画面の枠に接していれば除外
- if (label_pt.clip_l == 1 || label_pt.clip_r == xsize - 2)
- {// if(wclip[i*4+0] == 1 || wclip[i*4+1] ==xsize-2){
- continue;
- }
- if (label_pt.clip_t == 1 || label_pt.clip_b == ysize - 2)
- {// if( wclip[i*4+2] == 1 || wclip[i*4+3] ==ysize-2){
- continue;
- }
- // 既に検出された矩形との重なりを確認
- if (!overlap.check(label_pt))
- {
- // 重なっているようだ。
- continue;
- }
-
- // 輪郭を取得
- coord_num = limage.getContour(i, coord_max, xcoord, ycoord);
- if (coord_num == coord_max)
- {
- // 輪郭が大きすぎる。
- continue;
- }
- //頂点候補のインデクスを取得
- vertex1 = scanVertex(xcoord, ycoord, coord_num);
-
- // 頂点候補(vertex1)を先頭に並べなおした配列を作成する。
- normalizeCoord(xcoord, ycoord, vertex1, coord_num);
-
- // 領域を準備する。
- NyARSquare square_ptr = o_square_stack.prePush();
-
- // 頂点情報を取得
- if (!getSquareVertex(xcoord, ycoord, vertex1, coord_num, label_area, mkvertex))
- {
- o_square_stack.pop();// 頂点の取得が出来なかったので破棄
- continue;
- }
- if (!getSquareLine(mkvertex, xcoord, ycoord, square_ptr))
- {
- // 矩形が成立しなかった。
- o_square_stack.pop();
- continue;
- }
- // 検出済の矩形の属したラベルを重なりチェックに追加する。
- overlap.push(label_pt);
- }
- return;
- }
-
- /**
- * 辺からの対角線が最長になる点を対角線候補として返す。
- *
- * @param i_xcoord
- * @param i_ycoord
- * @param i_coord_num
- * @return
- */
- private int scanVertex(int[] i_xcoord, int[] i_ycoord, int i_coord_num)
- {
- int sx = i_xcoord[0];
- int sy = i_ycoord[0];
- int d = 0;
- int w, x, y;
- int ret = 0;
- for (int i = 1; i < i_coord_num; i++)
- {
- x = i_xcoord[i] - sx;
- y = i_ycoord[i] - sy;
- w = x * x + y * y;
- if (w > d)
- {
- d = w;
- ret = i;
- }
- // ここでうまく終了条件入れられないかな。
- }
- return ret;
- }
-
- private NyARVertexCounter __getSquareVertex_wv1 = new NyARVertexCounter();
-
- private NyARVertexCounter __getSquareVertex_wv2 = new NyARVertexCounter();
-
- /**
- * static int arDetectMarker2_check_square( int area, ARMarkerInfo2 *marker_info2, double factor ) 関数の代替関数 OPTIMIZED STEP [450->415] o_squareに頂点情報をセットします。
- *
- * @param i_x_coord
- * @param i_y_coord
- * @param i_vertex1_index
- * @param i_coord_num
- * @param i_area
- * @param o_vertex
- * 要素数はint[4]である事
- * @return
- */
- private bool getSquareVertex(int[] i_x_coord, int[] i_y_coord, int i_vertex1_index, int i_coord_num, int i_area, int[] o_vertex)
- {
- NyARVertexCounter wv1 = this.__getSquareVertex_wv1;
- NyARVertexCounter wv2 = this.__getSquareVertex_wv2;
- int end_of_coord = i_vertex1_index + i_coord_num - 1;
- int sx = i_x_coord[i_vertex1_index];// sx = marker_info2->x_coord[0];
- int sy = i_y_coord[i_vertex1_index];// sy = marker_info2->y_coord[0];
- int dmax = 0;
- int v1 = i_vertex1_index;
- int d;
- for (int i = 1 + i_vertex1_index; i < end_of_coord; i++)
- {// for(i=1;i<marker_info2->coord_num-1;i++)
- // {
- d = (i_x_coord[i] - sx) * (i_x_coord[i] - sx) + (i_y_coord[i] - sy) * (i_y_coord[i] - sy);
- if (d > dmax)
- {
- dmax = d;
- v1 = i;
- }
- }
- double thresh = (i_area / 0.75) * 0.01 * VERTEX_FACTOR;
-
- o_vertex[0] = i_vertex1_index;
-
- if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v1, thresh))
- { // if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,0,v1,thresh,wv1,&wvnum1)<
- // 0 ) {
- return false;
- }
- if (!wv2.getVertex(i_x_coord, i_y_coord, v1, end_of_coord, thresh))
- {// if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,v1,marker_info2->coord_num-1,thresh,wv2,&wvnum2)
- // < 0) {
- return false;
- }
-
- int v2;
- if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
- {// if(wvnum1 == 1 && wvnum2== 1) {
- o_vertex[1] = wv1.vertex[0];
- o_vertex[2] = v1;
- o_vertex[3] = wv2.vertex[0];
- }
- else if (wv1.number_of_vertex > 1 && wv2.number_of_vertex == 0)
- {// }else if( wvnum1 > 1 && wvnum2== 0) {
- //頂点位置を、起点から対角点の間の1/2にあると予想して、検索する。
- v2 = (v1 - i_vertex1_index) / 2 + i_vertex1_index;
- if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v2, thresh))
- {
- return false;
- }
- if (!wv2.getVertex(i_x_coord, i_y_coord, v2, v1, thresh))
- {
- return false;
- }
- if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
- {
- o_vertex[1] = wv1.vertex[0];
- o_vertex[2] = wv2.vertex[0];
- o_vertex[3] = v1;
- }
- else
- {
- return false;
- }
- }
- else if (wv1.number_of_vertex == 0 && wv2.number_of_vertex > 1)
- {
- //v2 = (v1-i_vertex1_index+ end_of_coord-i_vertex1_index) / 2+i_vertex1_index;
- v2 = (v1 + end_of_coord) / 2;
-
- if (!wv1.getVertex(i_x_coord, i_y_coord, v1, v2, thresh))
- {
- return false;
- }
- if (!wv2.getVertex(i_x_coord, i_y_coord, v2, end_of_coord, thresh))
- {
- return false;
- }
- if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
- {
- o_vertex[1] = v1;
- o_vertex[2] = wv1.vertex[0];
- o_vertex[3] = wv2.vertex[0];
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- o_vertex[4] = end_of_coord;
- return true;
- }
-
- private INyARPca2d _pca;
- private NyARDoubleMatrix22 __getSquareLine_evec=new NyARDoubleMatrix22();
- private NyARDoublePoint2d __getSquareLine_mean=new NyARDoublePoint2d();
- private NyARDoublePoint2d __getSquareLine_ev=new NyARDoublePoint2d();
-
- /**
- * arGetLine(int x_coord[], int y_coord[], int coord_num,int vertex[], double line[4][3], double v[4][2]) arGetLine2(int x_coord[], int y_coord[], int
- * coord_num,int vertex[], double line[4][3], double v[4][2], double *dist_factor) の2関数の合成品です。 マーカーのvertex,lineを計算して、結果をo_squareに保管します。
- * Optimize:STEP[424->391]
- *
- * @param i_cparam
- * @return
- * @throws NyARException
- */
- private bool getSquareLine(int[] i_mkvertex, int[] i_xcoord, int[] i_ycoord, NyARSquare o_square)
- {
- NyARLinear[] l_line = o_square.line;
- NyARObserv2IdealMap dist_factor = this._dist_factor;
- NyARDoubleMatrix22 evec = this.__getSquareLine_evec;
- NyARDoublePoint2d mean = this.__getSquareLine_mean;
- NyARDoublePoint2d ev = this.__getSquareLine_ev;
-
-
- for (int i = 0; i < 4; i++)
- {
- double w1 = (double)(i_mkvertex[i + 1] - i_mkvertex[i] + 1) * 0.05 + 0.5;
- int st = (int)(i_mkvertex[i] + w1);
- int ed = (int)(i_mkvertex[i + 1] - w1);
- int n = ed - st + 1;
- if (n < 2)
- {
- // nが2以下でmatrix.PCAを計算することはできないので、エラー
- return false;
- }
- //配列作成
- this._dist_factor.observ2IdealBatch(i_xcoord, i_ycoord, st, n, this._xpos, this._ypos);
-
- //主成分分析する。
- this._pca.pca(this._xpos, this._ypos, n, evec, ev, mean);
- NyARLinear l_line_i = l_line[i];
- l_line_i.run = evec.m01;// line[i][0] = evec->m[1];
- l_line_i.rise = -evec.m00;// line[i][1] = -evec->m[0];
- l_line_i.intercept = -(l_line_i.run * mean.x + l_line_i.rise * mean.y);// line[i][2] = -(line[i][0]*mean->v[0] + line[i][1]*mean->v[1]);
- }
-
- NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
- NyARIntPoint2d[] l_imvertex = o_square.imvertex;
- for (int i = 0; i < 4; i++)
- {
- NyARLinear l_line_i = l_line[i];
- NyARLinear l_line_2 = l_line[(i + 3) % 4];
- double w1 = l_line_2.run * l_line_i.rise - l_line_i.run * l_line_2.rise;
- if (w1 == 0.0)
- {
- return false;
- }
- l_sqvertex[i].x = (l_line_2.rise * l_line_i.intercept - l_line_i.rise * l_line_2.intercept) / w1;
- l_sqvertex[i].y = (l_line_i.run * l_line_2.intercept - l_line_2.run * l_line_i.intercept) / w1;
- // 頂点インデクスから頂点座標を得て保存
- l_imvertex[i].x = i_xcoord[i_mkvertex[i]];
- l_imvertex[i].y = i_ycoord[i_mkvertex[i]];
- }
- return true;
- }
- }
-
-
- /**
- * ラベル同士の重なり(内包関係)を調べるクラスです。 ラベルリストに内包するラベルを蓄積し、それにターゲットのラベルが内包されているか を確認します。
- */
- class OverlapChecker
- {
- private NyARLabelingLabel[] _labels = new NyARLabelingLabel[32];
-
- private int _length;
-
- /**
- * 最大i_max_label個のラベルを蓄積できるようにオブジェクトをリセットする
- *
- * @param i_max_label
- */
- public void reset(int i_max_label)
- {
- if (i_max_label > this._labels.Length)
- {
- this._labels = new NyARLabelingLabel[i_max_label];
- }
- this._length = 0;
- }
-
- /**
- * チェック対象のラベルを追加する。
- *
- * @param i_label_ref
- */
- public void push(NyARLabelingLabel i_label_ref)
- {
- this._labels[this._length] = i_label_ref;
- this._length++;
- }
-
- /**
- * 現在リストにあるラベルと重なっているかを返す。
- *
- * @param i_label
- * @return 何れかのラベルの内側にあるならばfalse,独立したラベルである可能性が高ければtrueです.
- */
- public bool check(NyARLabelingLabel i_label)
- {
- // 重なり処理かな?
- NyARLabelingLabel[] label_pt = this._labels;
- int px1 = (int)i_label.pos_x;
- int py1 = (int)i_label.pos_y;
- int px2, py2, d;
- for (int i = this._length - 1; i >= 0; i--)
- {
- px2 = (int)label_pt[i].pos_x;
- py2 = (int)label_pt[i].pos_y;
- d = (px1 - px2) * (px1 - px2) + (py1 - py2) * (py1 - py2);
- if (d < label_pt[i].area / 4)
- {
- // 対象外
- return false;
- }
- }
- // 対象
- return true;
- }
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquare.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquare.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARSquare.cs (revision 304)
@@ -1,54 +0,0 @@
-/*
- * 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>
- *
- */
-
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- /**
- * ARMarkerInfoに相当するクラス。 矩形情報を保持します。
- *
- */
- public class NyARSquare
- {
- 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.line[i] = new NyARLinear();
- }
- }
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/INyARSquareDetector.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/INyARSquareDetector.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/INyARSquareDetector.cs (revision 304)
@@ -1,38 +0,0 @@
-/*
- * 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>
- *
- */
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- public interface INyARSquareDetector
- {
- void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack);
- }
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVertexCounter.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVertexCounter.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVertexCounter.cs (revision 304)
@@ -1,115 +0,0 @@
-/*
- * 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
-{
- /**
- * get_vertex関数を切り離すためのクラス
- *
- */
- public class NyARVertexCounter
- {
- public int[] vertex = new int[10];// 5まで削れる
-
- public int number_of_vertex;
-
- private double thresh;
-
- private int[] x_coord;
-
- private int[] y_coord;
-
- public bool getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, double i_thresh)
- {
- this.number_of_vertex = 0;
- this.thresh = i_thresh;
- this.x_coord = i_x_coord;
- this.y_coord = i_y_coord;
- return get_vertex(st, ed);
- }
-
- /**
- * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
- *
- * @param x_coord
- * @param y_coord
- * @param st
- * @param ed
- * @param thresh
- * @return
- */
- private bool get_vertex(int st, int ed)
- {
- //メモ:座標値は65536を超えなければint32で扱って大丈夫なので変更。
- //dmaxは4乗なのでやるとしてもint64じゃないとマズイ
- int v1 = 0;
- int[] lx_coord = this.x_coord;
- int[] ly_coord = this.y_coord;
- int a = ly_coord[ed] - ly_coord[st];
- int b = lx_coord[st] - lx_coord[ed];
- int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
- double dmax = 0;
- for (int i = st + 1; i < ed; i++)
- {
- double d = a * lx_coord[i] + b * ly_coord[i] + c;
- if (d * d > dmax)
- {
- dmax = d * d;
- v1 = i;
- }
- }
- if (dmax / (double)(a * a + b * b) > thresh)
- {
- if (!get_vertex(st, v1))
- {
- return false;
- }
- if (number_of_vertex > 5)
- {
- return false;
- }
- vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
- number_of_vertex++;// (*vnum)++;
-
- if (!get_vertex(v1, ed))
- {
- return false;
- }
- }
- return true;
- }
-
- }
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARMat.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARMat.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARMat.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVersion.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVersion.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVersion.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkitCS is C# version NyARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GLAY_8.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GLAY_8.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GLAY_8.cs (revision 304)
@@ -1,68 +0,0 @@
-/*
- * 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: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_X8R8G8B8_32.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -69,6 +68,14 @@
}
return;
}
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ this._ref_buf[i_x + i_y * this._size.w]=((i_rgb[0]<<16)&0xff)|((i_rgb[1]<<8)&0xff)|((i_rgb[2])&0xff);
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
}

}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARBufferReader.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARBufferReader.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARBufferReader.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
@@ -63,6 +62,10 @@
* byte[]で、R8G8B8X8の32ビットで画素が格納されている。
*/
public const int BUFFERFORMAT_BYTE1D_B8G8R8X8_32 = BYTE1D | 0x0101;
+ /**
+ * byte[]で、X8R8G8B8の32ビットで画素が格納されている。
+ */
+ public const int BUFFERFORMAT_BYTE1D_X8R8G8B8_32 = BYTE1D|0x0102;

/**
* byte[]で、RGB565の16ビット(little/big endian)で画素が格納されている。
@@ -83,7 +86,7 @@
/**
* int[][]で0-255のグレイスケール画像
*/
- public const int BUFFERFORMAT_INT2D_GLAY_8 = INT2D | 0x0001;
+ public const int BUFFERFORMAT_INT2D_GRAY_8 = INT2D | 0x0001;
/**
* int[][]で0/1の2値画像
*/
@@ -96,7 +99,7 @@
/**
* int[]で0-255のグレイスケール画像
*/
- public const int BUFFERFORMAT_INT1D_GLAY_8 = INT1D | 0x0001;
+ public const int BUFFERFORMAT_INT1D_GRAY_8 = INT1D | 0x0001;
/**
* int[]で0/1の2値画像
*/
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GRAY_8.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GRAY_8.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_INT1D_GRAY_8.cs (revision 304)
@@ -0,0 +1,76 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARRgbPixelReader_INT1D_GRAY_8 : INyARRgbPixelReader
+ {
+ protected int[] _ref_buf;
+
+ private NyARIntSize _size;
+
+ public NyARRgbPixelReader_INT1D_GRAY_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;
+ }
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ NyARException.notImplement();
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
+
+ }
+
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARRgbPixelReader.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARRgbPixelReader.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/INyARRgbPixelReader.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
@@ -56,6 +55,23 @@
* yのインデックス配列
*/
void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] i_intrgb);
+ /**
+ * 1ピクセルを設定します。
+ * @param i_x
+ * @param i_y
+ * @param i_rgb
+ * @throws NyARException
+ */
+ void setPixel(int i_x, int i_y, int[] i_rgb);
+ /**
+ * 複数のピクセル値をint配列から設定します。
+ * @param i_x
+ * @param i_y
+ * @param i_num
+ * @param i_intrgb
+ * @throws NyARException
+ */
+ void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb);
}

}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARBufferReader.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARBufferReader.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARBufferReader.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_RGB24.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_RGB24.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterreader/NyARRgbPixelReader_RGB24.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
@@ -72,5 +71,13 @@
}
return;
}
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ NyARException.notImplement();
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
}
}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/

@@ -66,7 +65,7 @@
o_evec.m10 = evec_array[1][0];
o_evec.m11 = evec_array[1][1];
o_ev.x = ev_array[0];
- o_ev.x = ev_array[1];
+ o_ev.y = ev_array[1];
o_mean.x = mean_array[0];
o_mean.y = mean_array[1];
return;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA_O2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA_O2.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/NyARPca2d_MatrixPCA_O2.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/INyARPca2d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/INyARPca2d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pca2d/INyARPca2d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareDetector_ARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareDetector_ARToolKit.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareDetector_ARToolKit.cs (revision 304)
@@ -0,0 +1,199 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Diagnostics;
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+
+ /**
+ * イメージから正方形候補を検出するクラス。
+ * このクラスは、arDetectMarker2.cとの置き換えになります。
+ *
+ */
+ public class NyARSquareDetector_ARToolKit : INyARSquareDetector
+ {
+ private const double VERTEX_FACTOR = 1.0;// 線検出のファクタ
+
+ private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
+
+ private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
+ private int _width;
+ private int _height;
+
+ private NyARLabeling_ARToolKit _labeling;
+
+ private NyARLabelingImage _limage;
+
+ private LabelOverlapChecker<NyARLabelingLabel> _overlap_checker = new LabelOverlapChecker<NyARLabelingLabel>(32);
+ private SquareContourDetector _sqconvertor;
+ private ContourPickup _cpickup=new ContourPickup();
+
+ /**
+ * 最大i_squre_max個のマーカーを検出するクラスを作成する。
+ *
+ * @param i_param
+ */
+ public NyARSquareDetector_ARToolKit(NyARCameraDistortionFactor i_dist_factor_ref, NyARIntSize i_size)
+ {
+ this._width = i_size.w;
+ this._height = i_size.h;
+ //歪み計算テーブルを作ると、8*width/height*2の領域を消費します。
+ this._labeling = new NyARLabeling_ARToolKit();
+ this._sqconvertor = new SquareContourDetector(i_size, i_dist_factor_ref);
+
+ this._limage = new NyARLabelingImage(this._width, this._height);
+
+ // 輪郭の最大長は画面に映りうる最大の長方形サイズ。
+ int number_of_coord = (this._width + this._height) * 2;
+
+ // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
+ this._max_coord = number_of_coord;
+ this._xcoord = new int[number_of_coord * 2];
+ this._ycoord = new int[number_of_coord * 2];
+ return;
+ }
+
+ private int _max_coord;
+ private int[] _xcoord;
+ private int[] _ycoord;
+
+
+ /**
+ * ARMarkerInfo2 *arDetectMarker2( ARInt16 *limage, int label_num, int *label_ref,int *warea, double *wpos, int *wclip,int area_max, int area_min, double
+ * factor, int *marker_num ) 関数の代替品 ラベリング情報からマーカー一覧を作成してo_marker_listを更新します。 関数はo_marker_listに重なりを除外したマーカーリストを作成します。
+ *
+ * @param i_raster
+ * 解析する2値ラスタイメージを指定します。
+ * @param o_square_stack
+ * 抽出した正方形候補を格納するリスト
+ * @throws NyARException
+ */
+ public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
+ {
+ NyARLabelingImage limage = this._limage;
+
+ // 初期化
+
+ // マーカーホルダをリセット
+ o_square_stack.clear();
+
+ // ラベリング
+ this._labeling.labeling(i_raster, this._limage);
+
+ // ラベル数が0ならここまで
+ int label_num = limage.getLabelStack().getLength();
+ if (label_num < 1)
+ {
+ return;
+ }
+
+ NyARLabelingLabelStack stack = limage.getLabelStack();
+ //ラベルをソートしておく
+ stack.sortByArea();
+ //
+ NyARLabelingLabel[] labels = stack.getArray();
+
+
+
+ // デカいラベルを読み飛ばし
+ int i;
+ for (i = 0; i < label_num; i++)
+ {
+ // 検査対象内のラベルサイズになるまで無視
+ if (labels[i].area <= AR_AREA_MAX)
+ {
+ break;
+ }
+ }
+
+ int xsize = this._width;
+ int ysize = this._height;
+ int[] xcoord = this._xcoord;
+ int[] ycoord = this._ycoord;
+ int coord_max = this._max_coord;
+ LabelOverlapChecker<NyARLabelingLabel> overlap = this._overlap_checker;
+ int label_area;
+ NyARLabelingLabel label_pt;
+
+ //重なりチェッカの最大数を設定
+ overlap.setMaxLabels(label_num);
+
+ for (; i < label_num; i++)
+ {
+ label_pt = labels[i];
+ label_area = label_pt.area;
+ // 検査対象サイズよりも小さくなったら終了
+ if (label_area < AR_AREA_MIN)
+ {
+ break;
+ }
+ // クリップ領域が画面の枠に接していれば除外
+ if (label_pt.clip_l == 1 || label_pt.clip_r == xsize - 2)
+ {// if(wclip[i*4+0] == 1 || wclip[i*4+1] ==xsize-2){
+ continue;
+ }
+ if (label_pt.clip_t == 1 || label_pt.clip_b == ysize - 2)
+ {// if( wclip[i*4+2] == 1 || wclip[i*4+3] ==ysize-2){
+ continue;
+ }
+ // 既に検出された矩形との重なりを確認
+ if (!overlap.check(label_pt))
+ {
+ // 重なっているようだ。
+ continue;
+ }
+
+ // 輪郭を取得
+ int coord_num = _cpickup.getContour(limage, limage.getTopClipTangentX(label_pt), label_pt.clip_t, coord_max, xcoord, ycoord);
+ if (coord_num == coord_max)
+ {
+ // 輪郭が大きすぎる。
+ continue;
+ }
+ //頂点候補のインデクスを取得
+ // 頂点候補(vertex1)を先頭に並べなおした配列を作成する。
+ int vertex1 = SquareContourDetector.normalizeCoord(xcoord, ycoord, coord_num);
+
+ // 領域を準備する。
+ NyARSquare square_ptr = o_square_stack.prePush();
+ if (!this._sqconvertor.coordToSquare(xcoord, ycoord, vertex1, coord_num, label_area, square_ptr))
+ {
+ o_square_stack.pop();// 頂点の取得が出来なかったので破棄
+ continue;
+ }
+ // 検出済の矩形の属したラベルを重なりチェックに追加する。
+ overlap.push(label_pt);
+ }
+ return;
+ }
+ }
+
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/INyARSquareDetector.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/INyARSquareDetector.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/INyARSquareDetector.cs (revision 304)
@@ -0,0 +1,37 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public interface INyARSquareDetector
+ {
+ void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack);
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareStack.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareStack.cs (revision 304)
@@ -0,0 +1,46 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARSquareStack : NyObjectStack<NyARSquare>
+ {
+ public NyARSquareStack(int i_length): base(i_length)
+ {
+ }
+ protected override NyARSquare createElement()
+ {
+ return new NyARSquare();
+ }
+
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/SquareContourDetector.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/SquareContourDetector.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/SquareContourDetector.cs (revision 304)
@@ -0,0 +1,265 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class SquareContourDetector
+ {
+ private const double VERTEX_FACTOR = 1.0;// 線検出のファクタ
+ private double[] _xpos;
+ private double[] _ypos;
+ private int[] __detectMarker_mkvertex = new int[5];
+ private NyARVertexCounter __getSquareVertex_wv1 = new NyARVertexCounter();
+ private NyARVertexCounter __getSquareVertex_wv2 = new NyARVertexCounter();
+ private INyARPca2d _pca;
+ private NyARDoubleMatrix22 __getSquareLine_evec = new NyARDoubleMatrix22();
+ private NyARDoublePoint2d __getSquareLine_mean = new NyARDoublePoint2d();
+ private NyARDoublePoint2d __getSquareLine_ev = new NyARDoublePoint2d();
+ private NyARObserv2IdealMap _dist_factor;
+ public SquareContourDetector(NyARIntSize i_size, NyARCameraDistortionFactor i_distfactor_ref)
+ {
+ //歪み計算テーブルを作ると、8*width/height*2の領域を消費します。
+ //領域を取りたくない場合は、i_dist_factor_refの値をそのまま使ってください。
+ this._dist_factor = new NyARObserv2IdealMap(i_distfactor_ref, i_size);
+
+
+ // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
+ this._pca = new NyARPca2d_MatrixPCA_O2();
+ this._xpos = new double[i_size.w + i_size.h];//最大辺長はthis._width+this._height
+ this._ypos = new double[i_size.w + i_size.h];//最大辺長はthis._width+this._height
+ return;
+ }
+
+ public bool coordToSquare(int[] i_xcoord, int[] i_ycoord, int i_st_index, int i_coord_num, int i_label_area, NyARSquare o_square)
+ {
+
+ int[] mkvertex = this.__detectMarker_mkvertex;
+
+ // 頂点情報を取得
+ if (!getSquareVertex(i_xcoord, i_ycoord, i_st_index, i_coord_num, i_label_area, mkvertex))
+ {
+ // 頂点の取得が出来なかったので破棄
+ return false;
+ }
+ // マーカーを検出
+ if (!getSquareLine(mkvertex, i_xcoord, i_ycoord, o_square))
+ {
+ // 矩形が成立しなかった。
+ return false;
+ }
+ return true;
+ }
+
+ private bool getSquareLine(int[] i_mkvertex, int[] i_xcoord, int[] i_ycoord, NyARSquare o_square)
+ {
+ NyARLinear[] l_line = o_square.line;
+ NyARDoubleMatrix22 evec = this.__getSquareLine_evec;
+ NyARDoublePoint2d mean = this.__getSquareLine_mean;
+ NyARDoublePoint2d ev = this.__getSquareLine_ev;
+
+
+ for (int i = 0; i < 4; i++)
+ {
+ double w1 = (double)(i_mkvertex[i + 1] - i_mkvertex[i] + 1) * 0.05 + 0.5;
+ int st = (int)(i_mkvertex[i] + w1);
+ int ed = (int)(i_mkvertex[i + 1] - w1);
+ int n = ed - st + 1;
+ if (n < 2)
+ {
+ // nが2以下でmatrix.PCAを計算することはできないので、エラー
+ return false;
+ }
+ //配列作成
+ this._dist_factor.observ2IdealBatch(i_xcoord, i_ycoord, st, n, this._xpos, this._ypos);
+
+ //主成分分析する。
+ this._pca.pca(this._xpos, this._ypos, n, evec, ev, mean);
+ NyARLinear l_line_i = l_line[i];
+ l_line_i.run = evec.m01;// line[i][0] = evec->m[1];
+ l_line_i.rise = -evec.m00;// line[i][1] = -evec->m[0];
+ l_line_i.intercept = -(l_line_i.run * mean.x + l_line_i.rise * mean.y);// line[i][2] = -(line[i][0]*mean->v[0] + line[i][1]*mean->v[1]);
+ }
+
+ NyARDoublePoint2d[] l_sqvertex = o_square.sqvertex;
+ NyARIntPoint2d[] l_imvertex = o_square.imvertex;
+ for (int i = 0; i < 4; i++)
+ {
+ NyARLinear l_line_i = l_line[i];
+ NyARLinear l_line_2 = l_line[(i + 3) % 4];
+ double w1 = l_line_2.run * l_line_i.rise - l_line_i.run * l_line_2.rise;
+ if (w1 == 0.0)
+ {
+ return false;
+ }
+ l_sqvertex[i].x = (l_line_2.rise * l_line_i.intercept - l_line_i.rise * l_line_2.intercept) / w1;
+ l_sqvertex[i].y = (l_line_i.run * l_line_2.intercept - l_line_2.run * l_line_i.intercept) / w1;
+ // 頂点インデクスから頂点座標を得て保存
+ l_imvertex[i].x = i_xcoord[i_mkvertex[i]];
+ l_imvertex[i].y = i_ycoord[i_mkvertex[i]];
+ }
+ return true;
+ }
+ private bool getSquareVertex(int[] i_x_coord, int[] i_y_coord, int i_vertex1_index, int i_coord_num, int i_area, int[] o_vertex)
+ {
+ NyARVertexCounter wv1 = this.__getSquareVertex_wv1;
+ NyARVertexCounter wv2 = this.__getSquareVertex_wv2;
+ int end_of_coord = i_vertex1_index + i_coord_num - 1;
+ int sx = i_x_coord[i_vertex1_index];// sx = marker_info2->x_coord[0];
+ int sy = i_y_coord[i_vertex1_index];// sy = marker_info2->y_coord[0];
+ int dmax = 0;
+ int v1 = i_vertex1_index;
+ for (int i = 1 + i_vertex1_index; i < end_of_coord; i++)
+ {// for(i=1;i<marker_info2->coord_num-1;i++)
+ // {
+ int d = (i_x_coord[i] - sx) * (i_x_coord[i] - sx) + (i_y_coord[i] - sy) * (i_y_coord[i] - sy);
+ if (d > dmax)
+ {
+ dmax = d;
+ v1 = i;
+ }
+ }
+ double thresh = (i_area / 0.75) * 0.01 * VERTEX_FACTOR;
+
+ o_vertex[0] = i_vertex1_index;
+
+ if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v1, thresh))
+ { // if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,0,v1,thresh,wv1,&wvnum1)<
+ // 0 ) {
+ return false;
+ }
+ if (!wv2.getVertex(i_x_coord, i_y_coord, v1, end_of_coord, thresh))
+ {// if(get_vertex(marker_info2->x_coord,marker_info2->y_coord,v1,marker_info2->coord_num-1,thresh,wv2,&wvnum2)
+ // < 0) {
+ return false;
+ }
+
+ int v2;
+ if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
+ {// if(wvnum1 == 1 && wvnum2== 1) {
+ o_vertex[1] = wv1.vertex[0];
+ o_vertex[2] = v1;
+ o_vertex[3] = wv2.vertex[0];
+ }
+ else if (wv1.number_of_vertex > 1 && wv2.number_of_vertex == 0)
+ {// }else if( wvnum1 > 1 && wvnum2== 0) {
+ //頂点位置を、起点から対角点の間の1/2にあると予想して、検索する。
+ v2 = (v1 - i_vertex1_index) / 2 + i_vertex1_index;
+ if (!wv1.getVertex(i_x_coord, i_y_coord, i_vertex1_index, v2, thresh))
+ {
+ return false;
+ }
+ if (!wv2.getVertex(i_x_coord, i_y_coord, v2, v1, thresh))
+ {
+ return false;
+ }
+ if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
+ {
+ o_vertex[1] = wv1.vertex[0];
+ o_vertex[2] = wv2.vertex[0];
+ o_vertex[3] = v1;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if (wv1.number_of_vertex == 0 && wv2.number_of_vertex > 1)
+ {
+ //v2 = (v1-i_vertex1_index+ end_of_coord-i_vertex1_index) / 2+i_vertex1_index;
+ v2 = (v1 + end_of_coord) / 2;
+
+ if (!wv1.getVertex(i_x_coord, i_y_coord, v1, v2, thresh))
+ {
+ return false;
+ }
+ if (!wv2.getVertex(i_x_coord, i_y_coord, v2, end_of_coord, thresh))
+ {
+ return false;
+ }
+ if (wv1.number_of_vertex == 1 && wv2.number_of_vertex == 1)
+ {
+ o_vertex[1] = v1;
+ o_vertex[2] = wv1.vertex[0];
+ o_vertex[3] = wv2.vertex[0];
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ o_vertex[4] = end_of_coord;
+ return true;
+ }
+
+ /**
+ * 輪郭線の矩形検出開始ポイントを特定して、座標を並べ替えます。
+ * 輪郭線の先頭から、対角線が最長になる点を1点検索し、それより前の区間をバッファの後方に接続します。
+ * 戻り値は対角線が最長になった点です。関数終了後、返却値+i_coord_numの要素が有効になります。
+ * @param i_xcoord
+ * @param i_ycoord
+ * @param i_coord_num
+ * @return
+ */
+ public static int normalizeCoord(int[] i_coord_x, int[] i_coord_y, int i_coord_num)
+ {
+ //
+ int sx = i_coord_x[0];
+ int sy = i_coord_y[0];
+ int d = 0;
+ int w, x, y;
+ int ret = 0;
+ for (int i = 1; i < i_coord_num; i++)
+ {
+ x = i_coord_x[i] - sx;
+ y = i_coord_y[i] - sy;
+ w = x * x + y * y;
+ if (w > d)
+ {
+ d = w;
+ ret = i;
+ }
+ // ここでうまく終了条件入れられないかな。
+ }
+ // vertex1を境界にして、後方に配列を連結
+ Array.Copy(i_coord_x, 1, i_coord_x, i_coord_num, ret);
+ Array.Copy(i_coord_y, 1, i_coord_y, i_coord_num, ret);
+ return ret;
+ }
+
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/ContourPickup.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/ContourPickup.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/ContourPickup.cs (revision 304)
@@ -0,0 +1,283 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class ContourPickup
+ {
+ //巡回参照できるように、テーブルを二重化
+ // 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
+ protected static int[] _getContour_xdir = { 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1 };
+ protected static int[] _getContour_ydir = { -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0 };
+
+ /**
+ * ラスタのエントリポイントから辿れる輪郭線を配列に返します。
+ * @param i_raster
+ * @param i_entry_x
+ * @param i_entry_y
+ * @param i_array_size
+ * @param o_coord_x
+ * @param o_coord_y
+ * @return
+ * 輪郭線の長さを返します。
+ * @throws NyARException
+ */
+ public int getContour(NyARBinRaster i_raster, int i_entry_x, int i_entry_y, int i_array_size, int[] o_coord_x, int[] o_coord_y)
+ {
+ int[] xdir = _getContour_xdir;// static int xdir[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
+ int[] ydir = _getContour_ydir;// static int ydir[8] = {-1,-1, 0, 1, 1, 1, 0,-1};
+
+ int[] i_buf=(int[])i_raster.getBufferReader().getBuffer();
+ int width=i_raster.getWidth();
+ int height=i_raster.getHeight();
+ //クリップ領域の上端に接しているポイントを得る。
+
+
+ int coord_num = 1;
+ o_coord_x[0] = i_entry_x;
+ o_coord_y[0] = i_entry_y;
+ int dir = 5;
+
+ int c = i_entry_x;
+ int r = i_entry_y;
+ for (;;) {
+ dir = (dir + 5) % 8;//dirの正規化
+ //ここは頑張ればもっと最適化できると思うよ。
+ //4隅以外の境界接地の場合に、境界チェックを省略するとかね。
+ if(c>=1 && c<width-1 && r>=1 && r<height-1){
+ for(;;){//gotoのエミュレート用のfor文
+ //境界に接していないとき
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir])*width+(c + xdir[dir])] == 0) {
+ break;
+ }
+/*
+ try{
+ BufferedImage b=new BufferedImage(width,height,ColorSpace.TYPE_RGB);
+ NyARRasterImageIO.copy(i_raster, b);
+ ImageIO.write(b,"png",new File("bug.png"));
+ }catch(Exception e){
+
+ }*/
+ //8方向全て調べたけどラベルが無いよ?
+ throw new NyARException();
+ }
+ }else{
+ //境界に接しているとき
+ int i;
+ for (i = 0; i < 8; i++){
+ int x=c + xdir[dir];
+ int y=r + ydir[dir];
+ //境界チェック
+ if(x>=0 && x<width && y>=0 && y<height){
+ if (i_buf[(y)*width+(x)] == 0) {
+ break;
+ }
+ }
+ dir++;//倍長テーブルを参照するので問題なし
+ }
+ if (i == 8) {
+ //8方向全て調べたけどラベルが無いよ?
+ throw new NyARException();// return(-1);
+ }
+ }
+
+ dir=dir% 8;//dirの正規化
+
+ // xcoordとycoordをc,rにも保存
+ c = c + xdir[dir];
+ r = r + ydir[dir];
+ o_coord_x[coord_num] = c;
+ o_coord_y[coord_num] = r;
+ // 終了条件判定
+ if (c == i_entry_x && r == i_entry_y){
+ coord_num++;
+ break;
+ }
+ coord_num++;
+ if (coord_num == i_array_size) {
+ //輪郭が末端に達した
+ return coord_num;
+ }
+ }
+ return coord_num;
+ }
+ public int getContour(NyARLabelingImage i_raster, int i_entry_x, int i_entry_y, int i_array_size, int[] o_coord_x, int[] o_coord_y)
+ {
+ int[] xdir = _getContour_xdir;// static int xdir[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
+ int[] ydir = _getContour_ydir;// static int ydir[8] = {-1,-1, 0, 1, 1, 1, 0,-1};
+
+ int[] i_buf = (int[])i_raster.getBufferReader().getBuffer();
+ int width = i_raster.getWidth();
+ int height = i_raster.getHeight();
+ //クリップ領域の上端に接しているポイントを得る。
+ int sx = i_entry_x;
+ int sy = i_entry_y;
+
+ int coord_num = 1;
+ o_coord_x[0] = sx;
+ o_coord_y[0] = sy;
+ int dir = 5;
+
+ int c = o_coord_x[0];
+ int r = o_coord_y[0];
+ for (; ; )
+ {
+ dir = (dir + 5) % 8;//dirの正規化
+ //ここは頑張ればもっと最適化できると思うよ。
+ //4隅以外の境界接地の場合に、境界チェックを省略するとかね。
+ if (c >= 1 && c < width - 1 && r >= 1 && r < height - 1)
+ {
+ for (; ; )
+ {//gotoのエミュレート用のfor文
+ //境界に接していないとき
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ dir++;
+ if (i_buf[(r + ydir[dir]) * width + (c + xdir[dir])] > 0)
+ {
+ break;
+ }
+ //8方向全て調べたけどラベルが無いよ?
+ throw new NyARException();
+ }
+ }
+ else
+ {
+ //境界に接しているとき
+ int i;
+ for (i = 0; i < 8; i++)
+ {
+ int x = c + xdir[dir];
+ int y = r + ydir[dir];
+ //境界チェック
+ if (x >= 0 && x < width && y >= 0 && y < height)
+ {
+ if (i_buf[(y) * width + (x)] > 0)
+ {
+ break;
+ }
+ }
+ dir++;//倍長テーブルを参照するので問題なし
+ }
+ if (i == 8)
+ {
+ //8方向全て調べたけどラベルが無いよ?
+ throw new NyARException();// return(-1);
+ }
+ }
+
+ dir = dir % 8;//dirの正規化
+
+ // xcoordとycoordをc,rにも保存
+ c = c + xdir[dir];
+ r = r + ydir[dir];
+ o_coord_x[coord_num] = c;
+ o_coord_y[coord_num] = r;
+ // 終了条件判定
+ if (c == sx && r == sy)
+ {
+ coord_num++;
+ break;
+ }
+ coord_num++;
+ if (coord_num == i_array_size)
+ {
+ //輪郭が末端に達した
+ return coord_num;
+ }
+ }
+ return coord_num;
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareDetector_Rle.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareDetector_Rle.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquareDetector_Rle.cs (revision 304)
@@ -0,0 +1,177 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARSquareDetector_Rle : INyARSquareDetector
+ {
+ private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
+ private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
+ private int _width;
+ private int _height;
+
+ private NyARLabeling_Rle _labeling;
+
+ private LabelOverlapChecker<RleLabelFragmentInfoStack.RleLabelFragmentInfo> _overlap_checker = new LabelOverlapChecker<RleLabelFragmentInfoStack.RleLabelFragmentInfo>(32);
+ private SquareContourDetector _sqconvertor;
+ private ContourPickup _cpickup = new ContourPickup();
+ private RleLabelFragmentInfoStack _stack;
+
+ private int _max_coord;
+ private int[] _xcoord;
+ private int[] _ycoord;
+ /**
+ * 最大i_squre_max個のマーカーを検出するクラスを作成する。
+ *
+ * @param i_param
+ */
+ public NyARSquareDetector_Rle(NyARCameraDistortionFactor i_dist_factor_ref, NyARIntSize i_size)
+ {
+ this._width = i_size.w;
+ this._height = i_size.h;
+ //ラベリングのサイズを指定したいときはsetAreaRangeを使ってね。
+ this._labeling = new NyARLabeling_Rle(this._width, this._height);
+ this._labeling.setAreaRange(AR_AREA_MAX, AR_AREA_MIN);
+ this._sqconvertor = new SquareContourDetector(i_size, i_dist_factor_ref);
+ this._stack = new RleLabelFragmentInfoStack(i_size.w * i_size.h * 2048 / (320 * 240) + 32);//検出可能な最大ラベル数
+
+
+ // 輪郭の最大長は画面に映りうる最大の長方形サイズ。
+ int number_of_coord = (this._width + this._height) * 2;
+
+ // 輪郭バッファは頂点変換をするので、輪郭バッファの2倍取る。
+ this._max_coord = number_of_coord;
+ this._xcoord = new int[number_of_coord * 2];
+ this._ycoord = new int[number_of_coord * 2];
+ return;
+ }
+
+ /**
+ * arDetectMarker2を基にした関数
+ * この関数はNyARSquare要素のうち、directionを除くパラメータを取得して返します。
+ * directionの確定は行いません。
+ * @param i_raster
+ * 解析する2値ラスタイメージを指定します。
+ * @param o_square_stack
+ * 抽出した正方形候補を格納するリスト
+ * @throws NyARException
+ */
+ public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack)
+ {
+ RleLabelFragmentInfoStack flagment = this._stack;
+ LabelOverlapChecker<RleLabelFragmentInfoStack.RleLabelFragmentInfo> overlap = this._overlap_checker;
+
+ // マーカーホルダをリセット
+ o_square_stack.clear();
+
+ // ラベル数が0ならここまで
+ int label_num = this._labeling.labeling(i_raster, 0, i_raster.getHeight(), flagment);
+ if (label_num < 1)
+ {
+ return;
+ }
+ //ラベルをソートしておく
+ flagment.sortByArea();
+ //ラベルリストを取得
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo[] labels = flagment.getArray();
+
+
+ int xsize = this._width;
+ int ysize = this._height;
+ int[] xcoord = this._xcoord;
+ int[] ycoord = this._ycoord;
+ int coord_max = this._max_coord;
+
+ //重なりチェッカの最大数を設定
+ overlap.setMaxLabels(label_num);
+
+ for (int i=0; i < label_num; i++)
+ {
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo label_pt = labels[i];
+ int label_area = label_pt.area;
+ // 検査対象サイズよりも小さくなったら終了
+ if (label_pt.area < AR_AREA_MIN)
+ {
+ break;
+ }
+
+ // クリップ領域が画面の枠に接していれば除外
+ if (label_pt.clip_l == 0 || label_pt.clip_r == xsize - 1)
+ {
+ continue;
+ }
+ if (label_pt.clip_t == 0 || label_pt.clip_b == ysize - 1)
+ {
+ continue;
+ }
+ // 既に検出された矩形との重なりを確認
+ if (!overlap.check(label_pt))
+ {
+ // 重なっているようだ。
+ continue;
+ }
+
+ // 輪郭を取得
+ int coord_num = _cpickup.getContour(i_raster, label_pt.entry_x, label_pt.clip_t, coord_max, xcoord, ycoord);
+ if (coord_num == coord_max)
+ {
+ // 輪郭が大きすぎる。
+ continue;
+ }
+ //輪郭分析用に正規化する。
+ int vertex1 = SquareContourDetector.normalizeCoord(xcoord, ycoord, coord_num);
+
+ //ここから先が輪郭分析
+ NyARSquare square_ptr = o_square_stack.prePush();
+ if (!this._sqconvertor.coordToSquare(xcoord, ycoord, vertex1, coord_num, label_area, square_ptr))
+ {
+ o_square_stack.pop();// 頂点の取得が出来なかったので破棄
+ continue;
+ }
+ // 検出済の矩形の属したラベルを重なりチェックに追加する。
+ overlap.push(label_pt);
+ }
+ return;
+ }
+ /**
+ * デバック用API
+ * @return
+ */
+ public RleLabelFragmentInfoStack _getFragmentStack()
+ {
+ return this._stack;
+ }
+
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARVertexCounter.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARVertexCounter.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARVertexCounter.cs (revision 304)
@@ -0,0 +1,114 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * get_vertex関数を切り離すためのクラス
+ *
+ */
+ public class NyARVertexCounter
+ {
+ public int[] vertex = new int[10];// 5まで削れる
+
+ public int number_of_vertex;
+
+ private double thresh;
+
+ private int[] x_coord;
+
+ private int[] y_coord;
+
+ public bool getVertex(int[] i_x_coord, int[] i_y_coord, int st, int ed, double i_thresh)
+ {
+ this.number_of_vertex = 0;
+ this.thresh = i_thresh;
+ this.x_coord = i_x_coord;
+ this.y_coord = i_y_coord;
+ return get_vertex(st, ed);
+ }
+
+ /**
+ * static int get_vertex( int x_coord[], int y_coord[], int st, int ed,double thresh, int vertex[], int *vnum) 関数の代替関数
+ *
+ * @param x_coord
+ * @param y_coord
+ * @param st
+ * @param ed
+ * @param thresh
+ * @return
+ */
+ private bool get_vertex(int st, int ed)
+ {
+ //メモ:座標値は65536を超えなければint32で扱って大丈夫なので変更。
+ //dmaxは4乗なのでやるとしてもint64じゃないとマズイ
+ int v1 = 0;
+ int[] lx_coord = this.x_coord;
+ int[] ly_coord = this.y_coord;
+ int a = ly_coord[ed] - ly_coord[st];
+ int b = lx_coord[st] - lx_coord[ed];
+ int c = lx_coord[ed] * ly_coord[st] - ly_coord[ed] * lx_coord[st];
+ double dmax = 0;
+ for (int i = st + 1; i < ed; i++)
+ {
+ double d = a * lx_coord[i] + b * ly_coord[i] + c;
+ if (d * d > dmax)
+ {
+ dmax = d * d;
+ v1 = i;
+ }
+ }
+ if (dmax / (double)(a * a + b * b) > thresh)
+ {
+ if (!get_vertex(st, v1))
+ {
+ return false;
+ }
+ if (number_of_vertex > 5)
+ {
+ return false;
+ }
+ vertex[number_of_vertex] = v1;// vertex[(*vnum)] = v1;
+ number_of_vertex++;// (*vnum)++;
+
+ if (!get_vertex(v1, ed))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquare.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquare.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/squaredetect/NyARSquare.cs (revision 304)
@@ -0,0 +1,53 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * ARMarkerInfoに相当するクラス。 矩形情報を保持します。
+ *
+ */
+ public class NyARSquare
+ {
+ 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.line[i] = new NyARLinear();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat_ARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat_ARToolKit.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat_ARToolKit.cs (revision 304)
@@ -0,0 +1,262 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+/**
+ * This class calculates ARMatrix from square information and holds it. --
+ * 変換行列を計算して、結果を保持するクラス。
+ *
+ */
+public class NyARTransMat_ARToolKit : INyARTransMat
+{
+ private const int AR_GET_TRANS_MAT_MAX_LOOP_COUNT = 5;// #define AR_GET_TRANS_MAT_MAX_LOOP_COUNT 5
+ private const double AR_GET_TRANS_MAT_MAX_FIT_ERROR = 1.0;// #define AR_GET_TRANS_MAT_MAX_FIT_ERROR 1.0
+ 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_ARToolKit _rotmatrix;
+ protected INyARRotTransOptimize _mat_optimize;
+ protected INyARTransportVectorSolver _transsolver;
+ private NyARCameraDistortionFactor _ref_dist_factor;
+ /**
+ * 派生クラスで自分でメンバオブジェクトを指定したい場合はこちらを使う。
+ *
+ */
+ protected NyARTransMat_ARToolKit()
+ {
+ //_calculator,_rotmatrix,_mat_optimizeをコンストラクタの終了後に
+ //作成して割り当ててください。
+ return;
+ }
+ public NyARTransMat_ARToolKit(NyARParam i_param)
+ {
+ NyARCameraDistortionFactor dist=i_param.getDistortionFactor();
+ NyARPerspectiveProjectionMatrix pmat=i_param.getPerspectiveProjectionMatrix();
+ this._transsolver = new NyARTransportVectorSolver_ARToolKit(pmat);
+ //互換性が重要な時は、NyARRotMatrix_ARToolKitを使うこと。
+ //理屈はNyARRotMatrix_ARToolKit_O2もNyARRotMatrix_ARToolKitも同じだけど、少しだけ値がずれる。
+ this._rotmatrix = new NyARRotMatrix_ARToolKit_O2(pmat);
+ this._mat_optimize = new NyARRotTransOptimize_O2(pmat);
+ this._ref_dist_factor = dist;
+
+ }
+
+ public void setCenter(double i_x, double i_y)
+ {
+ this._center.x= i_x;
+ this._center.y= i_y;
+ }
+
+
+
+
+ /**
+ * 頂点順序をi_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)
+ {
+ //頂点順序を考慮した矩形の頂点情報
+ 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 NyARDoublePoint2d[] __transMat_vertex_2d = NyARDoublePoint2d.createArray(4);
+ private NyARDoublePoint3d[] __transMat_vertex_3d = NyARDoublePoint3d.createArray(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);
+
+ //平行移動量計算機に、2D座標系をセット
+ NyARDoublePoint2d[] vertex_2d=this.__transMat_vertex_2d;
+ NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;
+ this._ref_dist_factor.ideal2ObservBatch(sqvertex_ref, vertex_2d,4);
+ this._transsolver.set2dVertex(vertex_2d,4);
+
+ //基準矩形の3D座標系を作成
+ this._offset.setSquare(i_width,this._center);
+
+ //回転行列を計算
+ this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);
+
+ //回転後の3D座標系から、平行移動量を計算
+ this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);
+ this._transsolver.solveTransportVector(vertex_3d,trans);
+
+ //計算結果の最適化(平行移動量と回転行列の最適化)
+ this.optimize(this._rotmatrix, trans, this._transsolver, this._offset.vertex, vertex_2d);
+
+ // マトリクスの保存
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);
+ return;
+ }
+
+ /*
+ * (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;
+
+ // io_result_convが初期値なら、transMatで計算する。
+ if (!io_result_conv.has_value) {
+ this.transMat(i_square, i_direction, i_width, io_result_conv);
+ return;
+ }
+
+ //計算用に頂点情報を初期化(順番調整)
+ initVertexOrder(i_square, i_direction, sqvertex_ref,linear_ref);
+
+
+ //平行移動量計算機に、2D座標系をセット
+ NyARDoublePoint2d[] vertex_2d=this.__transMat_vertex_2d;
+ NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;
+ this._ref_dist_factor.ideal2ObservBatch(sqvertex_ref, vertex_2d,4);
+ this._transsolver.set2dVertex(vertex_2d,4);
+
+ //基準矩形の3D座標系を作成
+ this._offset.setSquare(i_width,this._center);
+
+ //回転行列を計算
+ this._rotmatrix.initRotByPrevResult(io_result_conv);
+
+ //回転後の3D座標系から、平行移動量を計算
+ this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);
+ this._transsolver.solveTransportVector(vertex_3d,trans);
+
+ //計算結果の最適化(平行移動量と回転行列の最適化)
+ double err=this.optimize(this._rotmatrix, trans, this._transsolver, this._offset.vertex, vertex_2d);
+
+ // マトリクスの保存
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans, io_result_conv);
+
+ // エラー値が許容範囲でなければTransMatをやり直し
+ if (err > AR_GET_TRANS_CONT_MAT_MAX_FIT_ERROR) {
+ // rotationを矩形情報で初期化
+ this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);
+ //回転行列の平行移動量の計算
+ this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);
+ this._transsolver.solveTransportVector(vertex_3d,trans);
+ //計算結果の最適化(this._rotmatrix,trans)
+ double err2=this.optimize(this._rotmatrix, trans, this._transsolver, this._offset.vertex, vertex_2d);
+ //エラー値が低かったら値を差換え
+ if (err2 < err) {
+ // 良い値が取れたら、差換え
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans, io_result_conv);
+ }
+ }
+ return;
+ }
+ private double optimize(NyARRotMatrix_ARToolKit io_rotmat,NyARDoublePoint3d io_transvec,INyARTransportVectorSolver i_solver,NyARDoublePoint3d[] i_offset_3d,NyARDoublePoint2d[] i_2d_vertex)
+ {
+ NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;
+ double err = -1;
+ // ループを抜けるタイミングをARToolKitと合わせるために変なことしてます。
+ for (int i = 0;; i++) {
+ // <arGetTransMat3>
+ err = this._mat_optimize.modifyMatrix(io_rotmat, io_transvec, i_offset_3d, i_2d_vertex);
+ io_rotmat.getPoint3dBatch(i_offset_3d,vertex_3d,4);
+ i_solver.solveTransportVector(vertex_3d, io_transvec);
+
+ err = this._mat_optimize.modifyMatrix(io_rotmat, io_transvec, i_offset_3d, i_2d_vertex);
+ // //</arGetTransMat3>
+ if (err < AR_GET_TRANS_MAT_MAX_FIT_ERROR || i == AR_GET_TRANS_MAT_MAX_LOOP_COUNT - 1) {
+ break;
+ }
+ io_rotmat.getPoint3dBatch(i_offset_3d,vertex_3d,4);
+ i_solver.solveTransportVector(vertex_3d, io_transvec);
+ }
+ return err;
+ }
+ /**
+ * パラメータで変換行列を更新します。
+ *
+ * @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.has_value = true;
+ return;
+ }
+}
+
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/INyARRotTransOptimize.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/INyARRotTransOptimize.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/INyARRotTransOptimize.cs (revision 304)
@@ -1,38 +0,0 @@
-/*
- * 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>
- *
- */
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- public interface INyARRotTransOptimize
- {
- double optimize(NyARRotMatrix io_rotmat, NyARDoublePoint3d io_transvec, NyARFitVecCalculator i_calculator);
- }
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/NyARRotTransOptimize.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/NyARRotTransOptimize.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/NyARRotTransOptimize.cs (revision 304)
@@ -1,268 +0,0 @@
-/*
- * 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 jp.nyatla.nyartoolkit.cs.utils;
-
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- /**
- * 基本姿勢と実画像を一致するように、角度を微調整→平行移動量を再計算
- * を繰り返して、変換行列を最適化する。
- *
- */
- public class NyARRotTransOptimize_O2 : INyARRotTransOptimize
- {
- private static int AR_GET_TRANS_MAT_MAX_LOOP_COUNT = 5;// #define AR_GET_TRANS_MAT_MAX_LOOP_COUNT 5
- private static double AR_GET_TRANS_MAT_MAX_FIT_ERROR = 1.0;// #define AR_GET_TRANS_MAT_MAX_FIT_ERROR 1.0
- private NyARPerspectiveProjectionMatrix _projection_mat_ref;
- public NyARRotTransOptimize_O2(NyARPerspectiveProjectionMatrix i_projection_mat_ref)
- {
- this._projection_mat_ref = i_projection_mat_ref;
- return;
- }
-
- public double optimize(NyARRotMatrix io_rotmat, NyARDoublePoint3d io_transvec, NyARFitVecCalculator i_calculator)
- {
- NyARDoublePoint2d[] fit_vertex = i_calculator.getFitSquare();
- NyARDoublePoint3d[] offset_square = i_calculator.getOffsetVertex().vertex;
-
- double err = -1;
- /*ループを抜けるタイミングをARToolKitと合わせるために変なことしてます。*/
- for (int i = 0; ; i++)
- {
- // <arGetTransMat3>
- err = modifyMatrix(io_rotmat, io_transvec, offset_square, fit_vertex);
- i_calculator.calculateTransfer(io_rotmat, io_transvec);
- err = modifyMatrix(io_rotmat, io_transvec, offset_square, fit_vertex);
- // //</arGetTransMat3>
- if (err < AR_GET_TRANS_MAT_MAX_FIT_ERROR || i == AR_GET_TRANS_MAT_MAX_LOOP_COUNT - 1)
- {
- break;
- }
- i_calculator.calculateTransfer(io_rotmat, io_transvec);
- }
- return err;
- }
-
- private double[][] __modifyMatrix_double1D = ArrayUtils.newDouble2dArray(8, 3);
- /**
- * arGetRot計算を階層化したModifyMatrix 896
- *
- * @param trans
- * @param i_vertex3d
- * [m][3]
- * @param i_vertex2d
- * [n][2]
- * @return
- * @throws NyARException
- */
- private double modifyMatrix(NyARRotMatrix io_rot, NyARDoublePoint3d trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d)
- {
- double factor;
- double a2, b2, c2;
- double h, x, y;
- double err, minerr = 0;
- int t1, t2, t3;
- int best_idx = 0;
-
- factor = 10.0 * Math.PI / 180.0;
- double rot0, rot1, rot2;
- double combo00, combo01, combo02, combo03, combo10, combo11, combo12, combo13, combo20, combo21, combo22, combo23;
- double combo02_2, combo02_5, combo02_8, combo02_11;
- double combo22_2, combo22_5, combo22_8, combo22_11;
- double combo12_2, combo12_5, combo12_8, combo12_11;
- // vertex展開
- double VX00, VX01, VX02, VX10, VX11, VX12, VX20, VX21, VX22, VX30, VX31, VX32;
- VX00 = i_vertex3d[0].x;
- VX01 = i_vertex3d[0].y;
- VX02 = i_vertex3d[0].z;
- VX10 = i_vertex3d[1].x;
- VX11 = i_vertex3d[1].y;
- VX12 = i_vertex3d[1].z;
- VX20 = i_vertex3d[2].x;
- VX21 = i_vertex3d[2].y;
- VX22 = i_vertex3d[2].z;
- VX30 = i_vertex3d[3].x;
- VX31 = i_vertex3d[3].y;
- VX32 = i_vertex3d[3].z;
- double P2D00, P2D01, P2D10, P2D11, P2D20, P2D21, P2D30, P2D31;
- P2D00 = i_vertex2d[0].x;
- P2D01 = i_vertex2d[0].y;
- P2D10 = i_vertex2d[1].x;
- P2D11 = i_vertex2d[1].y;
- P2D20 = i_vertex2d[2].x;
- P2D21 = i_vertex2d[2].y;
- P2D30 = i_vertex2d[3].x;
- P2D31 = i_vertex2d[3].y;
- NyARPerspectiveProjectionMatrix prjmat = this._projection_mat_ref;
- double CP0 = prjmat.m00, CP1 = prjmat.m01, CP2 = prjmat.m02, CP4 = prjmat.m10, CP5 = prjmat.m11, CP6 = prjmat.m12, CP8 = prjmat.m20, CP9 = prjmat.m21, CP10 = prjmat.m22;
- combo03 = CP0 * trans.x + CP1 * trans.y + CP2 * trans.z + prjmat.m03;
- combo13 = CP4 * trans.x + CP5 * trans.y + CP6 * trans.z + prjmat.m13;
- combo23 = CP8 * trans.x + CP9 * trans.y + CP10 * trans.z + prjmat.m23;
- double CACA, SASA, SACA, CA, SA;
- double CACACB, SACACB, SASACB, CASB, SASB;
- double SACASC, SACACBSC, SACACBCC, SACACC;
- double[][] double1D = this.__modifyMatrix_double1D;
-
- double[] a_factor = double1D[1];
- double[] sinb = double1D[2];
- double[] cosb = double1D[3];
- double[] b_factor = double1D[4];
- double[] sinc = double1D[5];
- double[] cosc = double1D[6];
- double[] c_factor = double1D[7];
- double w, w2;
- double wsin, wcos;
-
- NyARDoublePoint3d angle = io_rot.refAngle();
- a2 = angle.x;
- b2 = angle.y;
- c2 = angle.z;
-
- // comboの3行目を先に計算
- for (int i = 0; i < 10; i++)
- {
- minerr = 1000000000.0;
- // sin-cosテーブルを計算(これが外に出せるとは…。)
- for (int j = 0; j < 3; j++)
- {
- w2 = factor * (j - 1);
- w = a2 + w2;
- a_factor[j] = w;
- w = b2 + w2;
- b_factor[j] = w;
- sinb[j] = Math.Sin(w);
- cosb[j] = Math.Cos(w);
- w = c2 + w2;
- c_factor[j] = w;
- sinc[j] = Math.Sin(w);
- cosc[j] = Math.Cos(w);
- }
- //
- for (t1 = 0; t1 < 3; t1++)
- {
- SA = Math.Sin(a_factor[t1]);
- CA = Math.Cos(a_factor[t1]);
- // Optimize
- CACA = CA * CA;
- SASA = SA * SA;
- SACA = SA * CA;
- for (t2 = 0; t2 < 3; t2++)
- {
- wsin = sinb[t2];
- wcos = cosb[t2];
- CACACB = CACA * wcos;
- SACACB = SACA * wcos;
- SASACB = SASA * wcos;
- CASB = CA * wsin;
- SASB = SA * wsin;
- // comboの計算1
- combo02 = CP0 * CASB + CP1 * SASB + CP2 * wcos;
- combo12 = CP4 * CASB + CP5 * SASB + CP6 * wcos;
- combo22 = CP8 * CASB + CP9 * SASB + CP10 * wcos;
-
- combo02_2 = combo02 * VX02 + combo03;
- combo02_5 = combo02 * VX12 + combo03;
- combo02_8 = combo02 * VX22 + combo03;
- combo02_11 = combo02 * VX32 + combo03;
- combo12_2 = combo12 * VX02 + combo13;
- combo12_5 = combo12 * VX12 + combo13;
- combo12_8 = combo12 * VX22 + combo13;
- combo12_11 = combo12 * VX32 + combo13;
- combo22_2 = combo22 * VX02 + combo23;
- combo22_5 = combo22 * VX12 + combo23;
- combo22_8 = combo22 * VX22 + combo23;
- combo22_11 = combo22 * VX32 + combo23;
- for (t3 = 0; t3 < 3; t3++)
- {
- wsin = sinc[t3];
- wcos = cosc[t3];
- SACASC = SACA * wsin;
- SACACC = SACA * wcos;
- SACACBSC = SACACB * wsin;
- SACACBCC = SACACB * wcos;
-
- rot0 = CACACB * wcos + SASA * wcos + SACACBSC - SACASC;
- rot1 = SACACBCC - SACACC + SASACB * wsin + CACA * wsin;
- rot2 = -CASB * wcos - SASB * wsin;
- combo00 = CP0 * rot0 + CP1 * rot1 + CP2 * rot2;
- combo10 = CP4 * rot0 + CP5 * rot1 + CP6 * rot2;
- combo20 = CP8 * rot0 + CP9 * rot1 + CP10 * rot2;
-
- rot0 = -CACACB * wsin - SASA * wsin + SACACBCC - SACACC;
- rot1 = -SACACBSC + SACASC + SASACB * wcos + CACA * wcos;
- rot2 = CASB * wsin - SASB * wcos;
- combo01 = CP0 * rot0 + CP1 * rot1 + CP2 * rot2;
- combo11 = CP4 * rot0 + CP5 * rot1 + CP6 * rot2;
- combo21 = CP8 * rot0 + CP9 * rot1 + CP10 * rot2;
- //
- err = 0.0;
- h = combo20 * VX00 + combo21 * VX01 + combo22_2;
- x = P2D00 - (combo00 * VX00 + combo01 * VX01 + combo02_2) / h;
- y = P2D01 - (combo10 * VX00 + combo11 * VX01 + combo12_2) / h;
- err += x * x + y * y;
- h = combo20 * VX10 + combo21 * VX11 + combo22_5;
- x = P2D10 - (combo00 * VX10 + combo01 * VX11 + combo02_5) / h;
- y = P2D11 - (combo10 * VX10 + combo11 * VX11 + combo12_5) / h;
- err += x * x + y * y;
- h = combo20 * VX20 + combo21 * VX21 + combo22_8;
- x = P2D20 - (combo00 * VX20 + combo01 * VX21 + combo02_8) / h;
- y = P2D21 - (combo10 * VX20 + combo11 * VX21 + combo12_8) / h;
- err += x * x + y * y;
- h = combo20 * VX30 + combo21 * VX31 + combo22_11;
- x = P2D30 - (combo00 * VX30 + combo01 * VX31 + combo02_11) / h;
- y = P2D31 - (combo10 * VX30 + combo11 * VX31 + combo12_11) / h;
- err += x * x + y * y;
- if (err < minerr)
- {
- minerr = err;
- a2 = a_factor[t1];
- b2 = b_factor[t2];
- c2 = c_factor[t3];
- best_idx = t1 + t2 * 3 + t3 * 9;
- }
- }
- }
- }
- if (best_idx == (1 + 3 + 9))
- {
- factor *= 0.5;
- }
- }
- io_rot.setAngle(a2, b2, c2);
- /* printf("factor = %10.5f\n", factor*180.0/MD_PI); */
- return minerr / 4;
- }
-
-
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/NyARPartialDifferentiationOptimize.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/NyARPartialDifferentiationOptimize.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/NyARPartialDifferentiationOptimize.cs (revision 304)
@@ -0,0 +1,399 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkit is C# version ARToolkit class library.
+ * Copyright (C)2008-2009 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/
+ * <airmail(at)ebony.plala.or.jp>
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class TSinCosValue
+ {
+ public double cos_val;
+ public double sin_val;
+ public static TSinCosValue[] createArray(int i_size)
+ {
+ TSinCosValue[] result = new TSinCosValue[i_size];
+ for (int i = 0; i < i_size; i++)
+ {
+ result[i] = new TSinCosValue();
+ }
+ return result;
+ }
+ }
+
+ /**
+ * 基本姿勢と実画像を一致するように、角度を微調整→平行移動量を再計算 を繰り返して、変換行列を最適化する。
+ *
+ */
+ public class NyARPartialDifferentiationOptimize
+ {
+ private NyARPerspectiveProjectionMatrix _projection_mat_ref;
+
+ public NyARPartialDifferentiationOptimize(NyARPerspectiveProjectionMatrix i_projection_mat_ref)
+ {
+ this._projection_mat_ref = i_projection_mat_ref;
+ return;
+ }
+
+ public void sincos2Rotation_ZXY(TSinCosValue[] i_sincos, NyARDoubleMatrix33 i_rot_matrix)
+ {
+ double sina = i_sincos[0].sin_val;
+ double cosa = i_sincos[0].cos_val;
+ double sinb = i_sincos[1].sin_val;
+ double cosb = i_sincos[1].cos_val;
+ double sinc = i_sincos[2].sin_val;
+ double cosc = i_sincos[2].cos_val;
+ i_rot_matrix.m00 = cosc * cosb - sinc * sina * sinb;
+ i_rot_matrix.m01 = -sinc * cosa;
+ i_rot_matrix.m02 = cosc * sinb + sinc * sina * cosb;
+ i_rot_matrix.m10 = sinc * cosb + cosc * sina * sinb;
+ i_rot_matrix.m11 = cosc * cosa;
+ i_rot_matrix.m12 = sinc * sinb - cosc * sina * cosb;
+ i_rot_matrix.m20 = -cosa * sinb;
+ i_rot_matrix.m21 = sina;
+ i_rot_matrix.m22 = cosb * cosa;
+ }
+
+ private void rotation2Sincos_ZXY(NyARDoubleMatrix33 i_rot_matrix, TSinCosValue[] o_out, NyARDoublePoint3d o_ang)
+ {
+ double x, y, z;
+ double sina = i_rot_matrix.m21;
+ if (sina >= 1.0)
+ {
+ x = Math.PI / 2;
+ y = 0;
+ z = Math.Atan2(-i_rot_matrix.m10, i_rot_matrix.m00);
+ }
+ else if (sina <= -1.0)
+ {
+ x = -Math.PI / 2;
+ y = 0;
+ z = Math.Atan2(-i_rot_matrix.m10, i_rot_matrix.m00);
+ }
+ else
+ {
+ x = Math.Asin(sina);
+ y = Math.Atan2(-i_rot_matrix.m20, i_rot_matrix.m22);
+ z = Math.Atan2(-i_rot_matrix.m01, i_rot_matrix.m11);
+ }
+ o_ang.x = x;
+ o_ang.y = y;
+ o_ang.z = z;
+ o_out[0].sin_val = Math.Sin(x);
+ o_out[0].cos_val = Math.Cos(x);
+ o_out[1].sin_val = Math.Sin(y);
+ o_out[1].cos_val = Math.Cos(y);
+ o_out[2].sin_val = Math.Sin(z);
+ o_out[2].cos_val = Math.Cos(z);
+ return;
+ }
+
+ /*
+ * 射影変換式 基本式 ox=(cosc * cosb - sinc * sina * sinb)*ix+(-sinc * cosa)*iy+(cosc * sinb + sinc * sina * cosb)*iz+i_trans.x; oy=(sinc * cosb + cosc * sina *
+ * sinb)*ix+(cosc * cosa)*iy+(sinc * sinb - cosc * sina * cosb)*iz+i_trans.y; oz=(-cosa * sinb)*ix+(sina)*iy+(cosb * cosa)*iz+i_trans.z;
+ *
+ * double ox=(cosc * cosb)*ix+(-sinc * sina * sinb)*ix+(-sinc * cosa)*iy+(cosc * sinb)*iz + (sinc * sina * cosb)*iz+i_trans.x; double oy=(sinc * cosb)*ix
+ * +(cosc * sina * sinb)*ix+(cosc * cosa)*iy+(sinc * sinb)*iz+(- cosc * sina * cosb)*iz+i_trans.y; double oz=(-cosa * sinb)*ix+(sina)*iy+(cosb *
+ * cosa)*iz+i_trans.z;
+ *
+ * sina,cosaについて解く cx=(cp00*(-sinc*sinb*ix+sinc*cosb*iz)+cp01*(cosc*sinb*ix-cosc*cosb*iz)+cp02*(iy))*sina
+ * +(cp00*(-sinc*iy)+cp01*((cosc*iy))+cp02*(-sinb*ix+cosb*iz))*cosa
+ * +(cp00*(i_trans.x+cosc*cosb*ix+cosc*sinb*iz)+cp01*((i_trans.y+sinc*cosb*ix+sinc*sinb*iz))+cp02*(i_trans.z));
+ * cy=(cp11*(cosc*sinb*ix-cosc*cosb*iz)+cp12*(iy))*sina +(cp11*((cosc*iy))+cp12*(-sinb*ix+cosb*iz))*cosa
+ * +(cp11*((i_trans.y+sinc*cosb*ix+sinc*sinb*iz))+cp12*(i_trans.z)); ch=(iy)*sina +(-sinb*ix+cosb*iz)*cosa +i_trans.z; sinb,cosb hx=(cp00*(-sinc *
+ * sina*ix+cosc*iz)+cp01*(cosc * sina*ix+sinc*iz)+cp02*(-cosa*ix))*sinb +(cp01*(sinc*ix-cosc * sina*iz)+cp00*(cosc*ix+sinc * sina*iz)+cp02*(cosa*iz))*cosb
+ * +(cp00*(i_trans.x+(-sinc*cosa)*iy)+cp01*(i_trans.y+(cosc * cosa)*iy)+cp02*(i_trans.z+(sina)*iy)); double hy=(cp11*(cosc *
+ * sina*ix+sinc*iz)+cp12*(-cosa*ix))*sinb +(cp11*(sinc*ix-cosc * sina*iz)+cp12*(cosa*iz))*cosb +(cp11*(i_trans.y+(cosc *
+ * cosa)*iy)+cp12*(i_trans.z+(sina)*iy)); double h =((-cosa*ix)*sinb +(cosa*iz)*cosb +i_trans.z+(sina)*iy); パラメータ返還式 L=2*Σ(d[n]*e[n]+a[n]*b[n])
+ * J=2*Σ(d[n]*f[n]+a[n]*c[n])/L K=2*Σ(-e[n]*f[n]+b[n]*c[n])/L M=Σ(-e[n]^2+d[n]^2-b[n]^2+a[n]^2)/L 偏微分式 +J*cos(x) +K*sin(x) -sin(x)^2 +cos(x)^2
+ * +2*M*cos(x)*sin(x)
+ */
+ private double optimizeParamX(TSinCosValue i_angle_y, TSinCosValue i_angle_z, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d, int i_number_of_vertex, double i_hint_angle)
+ {
+ NyARPerspectiveProjectionMatrix cp = this._projection_mat_ref;
+ double sinb = i_angle_y.sin_val;
+ double cosb = i_angle_y.cos_val;
+ double sinc = i_angle_z.sin_val;
+ double cosc = i_angle_z.cos_val;
+ double L, J, K, M, N, O;
+ L = J = K = M = N = O = 0;
+ for (int i = 0; i < i_number_of_vertex; i++)
+ {
+ double ix, iy, iz;
+ ix = i_vertex3d[i].x;
+ iy = i_vertex3d[i].y;
+ iz = i_vertex3d[i].z;
+
+ double cp00 = cp.m00;
+ double cp01 = cp.m01;
+ double cp02 = cp.m02;
+ double cp11 = cp.m11;
+ double cp12 = cp.m12;
+
+ double X0 = (cp00 * (-sinc * sinb * ix + sinc * cosb * iz) + cp01 * (cosc * sinb * ix - cosc * cosb * iz) + cp02 * (iy));
+ double X1 = (cp00 * (-sinc * iy) + cp01 * ((cosc * iy)) + cp02 * (-sinb * ix + cosb * iz));
+ double X2 = (cp00 * (i_trans.x + cosc * cosb * ix + cosc * sinb * iz) + cp01 * ((i_trans.y + sinc * cosb * ix + sinc * sinb * iz)) + cp02 * (i_trans.z));
+ double Y0 = (cp11 * (cosc * sinb * ix - cosc * cosb * iz) + cp12 * (iy));
+ double Y1 = (cp11 * ((cosc * iy)) + cp12 * (-sinb * ix + cosb * iz));
+ double Y2 = (cp11 * ((i_trans.y + sinc * cosb * ix + sinc * sinb * iz)) + cp12 * (i_trans.z));
+ double H0 = (iy);
+ double H1 = (-sinb * ix + cosb * iz);
+ double H2 = i_trans.z;
+
+ double VX = i_vertex2d[i].x;
+ double VY = i_vertex2d[i].y;
+
+ double a, b, c, d, e, f;
+ a = (VX * H0 - X0);
+ b = (VX * H1 - X1);
+ c = (VX * H2 - X2);
+ d = (VY * H0 - Y0);
+ e = (VY * H1 - Y1);
+ f = (VY * H2 - Y2);
+
+ L += d * e + a * b;
+ N += d * d + a * a;
+ J += d * f + a * c;
+ M += e * e + b * b;
+ K += e * f + b * c;
+ O += f * f + c * c;
+
+ }
+ L *= 2;
+ J *= 2;
+ K *= 2;
+
+ return getMinimumErrorAngleFromParam(L, J, K, M, N, O, i_hint_angle);
+
+
+ }
+
+ private double optimizeParamY(TSinCosValue i_angle_x, TSinCosValue i_angle_z, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d, int i_number_of_vertex, double i_hint_angle)
+ {
+ NyARPerspectiveProjectionMatrix cp = this._projection_mat_ref;
+ double sina = i_angle_x.sin_val;
+ double cosa = i_angle_x.cos_val;
+ double sinc = i_angle_z.sin_val;
+ double cosc = i_angle_z.cos_val;
+ double L, J, K, M, N, O;
+ L = J = K = M = N = O = 0;
+ for (int i = 0; i < i_number_of_vertex; i++)
+ {
+ double ix, iy, iz;
+ ix = i_vertex3d[i].x;
+ iy = i_vertex3d[i].y;
+ iz = i_vertex3d[i].z;
+
+ double cp00 = cp.m00;
+ double cp01 = cp.m01;
+ double cp02 = cp.m02;
+ double cp11 = cp.m11;
+ double cp12 = cp.m12;
+
+ double X0 = (cp00 * (-sinc * sina * ix + cosc * iz) + cp01 * (cosc * sina * ix + sinc * iz) + cp02 * (-cosa * ix));
+ double X1 = (cp01 * (sinc * ix - cosc * sina * iz) + cp00 * (cosc * ix + sinc * sina * iz) + cp02 * (cosa * iz));
+ double X2 = (cp00 * (i_trans.x + (-sinc * cosa) * iy) + cp01 * (i_trans.y + (cosc * cosa) * iy) + cp02 * (i_trans.z + (sina) * iy));
+ double Y0 = (cp11 * (cosc * sina * ix + sinc * iz) + cp12 * (-cosa * ix));
+ double Y1 = (cp11 * (sinc * ix - cosc * sina * iz) + cp12 * (cosa * iz));
+ double Y2 = (cp11 * (i_trans.y + (cosc * cosa) * iy) + cp12 * (i_trans.z + (sina) * iy));
+ double H0 = (-cosa * ix);
+ double H1 = (cosa * iz);
+ double H2 = i_trans.z + (sina) * iy;
+
+ double VX = i_vertex2d[i].x;
+ double VY = i_vertex2d[i].y;
+
+ double a, b, c, d, e, f;
+ a = (VX * H0 - X0);
+ b = (VX * H1 - X1);
+ c = (VX * H2 - X2);
+ d = (VY * H0 - Y0);
+ e = (VY * H1 - Y1);
+ f = (VY * H2 - Y2);
+
+ L += d * e + a * b;
+ N += d * d + a * a;
+ J += d * f + a * c;
+ M += e * e + b * b;
+ K += e * f + b * c;
+ O += f * f + c * c;
+
+ }
+ L *= 2;
+ J *= 2;
+ K *= 2;
+ return getMinimumErrorAngleFromParam(L, J, K, M, N, O, i_hint_angle);
+
+ }
+
+ private double optimizeParamZ(TSinCosValue i_angle_x, TSinCosValue i_angle_y, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d, int i_number_of_vertex, double i_hint_angle)
+ {
+ NyARPerspectiveProjectionMatrix cp = this._projection_mat_ref;
+ double sina = i_angle_x.sin_val;
+ double cosa = i_angle_x.cos_val;
+ double sinb = i_angle_y.sin_val;
+ double cosb = i_angle_y.cos_val;
+ double L, J, K, M, N, O;
+ L = J = K = M = N = O = 0;
+ for (int i = 0; i < i_number_of_vertex; i++)
+ {
+ double ix, iy, iz;
+ ix = i_vertex3d[i].x;
+ iy = i_vertex3d[i].y;
+ iz = i_vertex3d[i].z;
+
+ double cp00 = cp.m00;
+ double cp01 = cp.m01;
+ double cp02 = cp.m02;
+ double cp11 = cp.m11;
+ double cp12 = cp.m12;
+
+ double X0 = (cp00 * (-sina * sinb * ix - cosa * iy + sina * cosb * iz) + cp01 * (ix * cosb + sinb * iz));
+ double X1 = (cp01 * (sina * ix * sinb + cosa * iy - sina * iz * cosb) + cp00 * (cosb * ix + sinb * iz));
+ double X2 = cp00 * i_trans.x + cp01 * (i_trans.y) + cp02 * (-cosa * sinb) * ix + cp02 * (sina) * iy + cp02 * ((cosb * cosa) * iz + i_trans.z);
+ double Y0 = cp11 * (ix * cosb + sinb * iz);
+ double Y1 = cp11 * (sina * ix * sinb + cosa * iy - sina * iz * cosb);
+ double Y2 = (cp11 * i_trans.y + cp12 * (-cosa * sinb) * ix + cp12 * ((sina) * iy + (cosb * cosa) * iz + i_trans.z));
+ double H0 = 0;
+ double H1 = 0;
+ double H2 = ((-cosa * sinb) * ix + (sina) * iy + (cosb * cosa) * iz + i_trans.z);
+
+ double VX = i_vertex2d[i].x;
+ double VY = i_vertex2d[i].y;
+
+ double a, b, c, d, e, f;
+ a = (VX * H0 - X0);
+ b = (VX * H1 - X1);
+ c = (VX * H2 - X2);
+ d = (VY * H0 - Y0);
+ e = (VY * H1 - Y1);
+ f = (VY * H2 - Y2);
+
+ L += d * e + a * b;
+ N += d * d + a * a;
+ J += d * f + a * c;
+ M += e * e + b * b;
+ K += e * f + b * c;
+ O += f * f + c * c;
+
+ }
+ L *= 2;
+ J *= 2;
+ K *= 2;
+
+ return getMinimumErrorAngleFromParam(L, J, K, M, N, O, i_hint_angle);
+ }
+ private TSinCosValue[] __angles_in = TSinCosValue.createArray(3);
+ private NyARDoublePoint3d __ang = new NyARDoublePoint3d();
+ public void modifyMatrix(NyARDoubleMatrix33 io_rot, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d, int i_number_of_vertex)
+ {
+ TSinCosValue[] angles_in = this.__angles_in;// x,y,z
+ NyARDoublePoint3d ang = this.__ang;
+
+ // ZXY系のsin/cos値を抽出
+ rotation2Sincos_ZXY(io_rot, angles_in, ang);
+ ang.x += optimizeParamX(angles_in[1], angles_in[2], i_trans, i_vertex3d, i_vertex2d, i_number_of_vertex, ang.x);
+ ang.y += optimizeParamY(angles_in[0], angles_in[2], i_trans, i_vertex3d, i_vertex2d, i_number_of_vertex, ang.y);
+ ang.z += optimizeParamZ(angles_in[0], angles_in[1], i_trans, i_vertex3d, i_vertex2d, i_number_of_vertex, ang.z);
+ io_rot.setZXYAngle(ang.x, ang.y, ang.z);
+ return;
+ }
+ private double[] __sin_table = new double[4];
+ /**
+ * エラーレートが最小になる点を得る。
+ */
+ private double getMinimumErrorAngleFromParam(double iL, double iJ, double iK, double iM, double iN, double iO, double i_hint_angle)
+ {
+ double[] sin_table = this.__sin_table;
+
+ double M = (iN - iM) / iL;
+ double J = iJ / iL;
+ double K = -iK / iL;
+
+ // パラメータからsinテーブルを作成
+ // (- 4*M^2-4)*x^4 + (4*K- 4*J*M)*x^3 + (4*M^2 -(K^2- 4)- J^2)*x^2 +(4*J*M- 2*K)*x + J^2-1 = 0
+ int number_of_sin = NyAREquationSolver.solve4Equation(-4 * M * M - 4, 4 * K - 4 * J * M, 4 * M * M - (K * K - 4) - J * J, 4 * J * M - 2 * K, J * J - 1, sin_table);
+
+
+ // 最小値2個を得ておく。
+ double min_ang_0 = Double.MaxValue;
+ double min_ang_1 = Double.MaxValue;
+ double min_err_0 = Double.MaxValue;
+ double min_err_1 = Double.MaxValue;
+ for (int i = 0; i < number_of_sin; i++)
+ {
+ // +-cos_v[i]が頂点候補
+ double sin_rt = sin_table[i];
+ double cos_rt = Math.Sqrt(1 - (sin_rt * sin_rt));
+ // cosを修復。微分式で0に近い方が正解
+ // 0 = 2*cos(x)*sin(x)*M - sin(x)^2 + cos(x)^2 + sin(x)*K + cos(x)*J
+ double a1 = 2 * cos_rt * sin_rt * M + sin_rt * (K - sin_rt) + cos_rt * (cos_rt + J);
+ double a2 = 2 * (-cos_rt) * sin_rt * M + sin_rt * (K - sin_rt) + (-cos_rt) * ((-cos_rt) + J);
+ // 絶対値になおして、真のcos値を得ておく。
+ a1 = a1 < 0 ? -a1 : a1;
+ a2 = a2 < 0 ? -a2 : a2;
+ cos_rt = (a1 < a2) ? cos_rt : -cos_rt;
+ double ang = Math.Atan2(sin_rt, cos_rt);
+ // エラー値を計算
+ double err = iN * sin_rt * sin_rt + (iL * cos_rt + iJ) * sin_rt + iM * cos_rt * cos_rt + iK * cos_rt + iO;
+ // 最小の2個を獲得する。
+ if (min_err_0 > err)
+ {
+ min_err_1 = min_err_0;
+ min_ang_1 = min_ang_0;
+ min_err_0 = err;
+ min_ang_0 = ang;
+ }
+ else if (min_err_1 > err)
+ {
+ min_err_1 = err;
+ min_ang_1 = ang;
+ }
+ }
+ // [0]をテスト
+ double gap_0;
+ gap_0 = min_ang_0 - i_hint_angle;
+ if (gap_0 > Math.PI)
+ {
+ gap_0 = (min_ang_0 - Math.PI * 2) - i_hint_angle;
+ }
+ else if (gap_0 < -Math.PI)
+ {
+ gap_0 = (min_ang_0 + Math.PI * 2) - i_hint_angle;
+ }
+ // [1]をテスト
+ double gap_1;
+ gap_1 = min_ang_1 - i_hint_angle;
+ if (gap_1 > Math.PI)
+ {
+ gap_1 = (min_ang_1 - Math.PI * 2) - i_hint_angle;
+ }
+ else if (gap_1 < -Math.PI)
+ {
+ gap_1 = (min_ang_1 + Math.PI * 2) - i_hint_angle;
+ }
+ return Math.Abs(gap_1) < Math.Abs(gap_0) ? gap_1 : gap_0;
+ }
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/artoolkit/INyARRotTransOptimize.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/artoolkit/INyARRotTransOptimize.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/artoolkit/INyARRotTransOptimize.cs (revision 304)
@@ -0,0 +1,37 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public interface INyARRotTransOptimize
+ {
+ double modifyMatrix(NyARRotMatrix_ARToolKit io_rot, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d);
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/artoolkit/NyARRotTransOptimize.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/artoolkit/NyARRotTransOptimize.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/optimize/artoolkit/NyARRotTransOptimize.cs (revision 304)
@@ -0,0 +1,242 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 基本姿勢と実画像を一致するように、角度を微調整→平行移動量を再計算
+ * を繰り返して、変換行列を最適化する。
+ *
+ */
+ public class NyARRotTransOptimize_O2 : INyARRotTransOptimize
+ {
+ private NyARPerspectiveProjectionMatrix _projection_mat_ref;
+ public NyARRotTransOptimize_O2(NyARPerspectiveProjectionMatrix i_projection_mat_ref)
+ {
+ this._projection_mat_ref = i_projection_mat_ref;
+ return;
+ }
+
+ private double[][] __modifyMatrix_double1D = ArrayUtils.newDouble2dArray(8, 3);
+ /**
+ * arGetRot計算を階層化したModifyMatrix 896
+ *
+ * @param trans
+ * @param i_vertex3d
+ * [m][3]
+ * @param i_vertex2d
+ * [n][2]
+ * @return
+ * @throws NyARException
+ */
+ public double modifyMatrix(NyARRotMatrix_ARToolKit io_rot, NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d)
+ {
+ double factor;
+ double a2, b2, c2;
+ double h, x, y;
+ double err, minerr = 0;
+ int t1, t2, t3;
+ int best_idx = 0;
+
+ factor = 10.0 * Math.PI / 180.0;
+ double rot0, rot1, rot2;
+ double combo00, combo01, combo02, combo03, combo10, combo11, combo12, combo13, combo20, combo21, combo22, combo23;
+ double combo02_2, combo02_5, combo02_8, combo02_11;
+ double combo22_2, combo22_5, combo22_8, combo22_11;
+ double combo12_2, combo12_5, combo12_8, combo12_11;
+ // vertex展開
+ double VX00, VX01, VX02, VX10, VX11, VX12, VX20, VX21, VX22, VX30, VX31, VX32;
+ VX00 = i_vertex3d[0].x;
+ VX01 = i_vertex3d[0].y;
+ VX02 = i_vertex3d[0].z;
+ VX10 = i_vertex3d[1].x;
+ VX11 = i_vertex3d[1].y;
+ VX12 = i_vertex3d[1].z;
+ VX20 = i_vertex3d[2].x;
+ VX21 = i_vertex3d[2].y;
+ VX22 = i_vertex3d[2].z;
+ VX30 = i_vertex3d[3].x;
+ VX31 = i_vertex3d[3].y;
+ VX32 = i_vertex3d[3].z;
+ double P2D00, P2D01, P2D10, P2D11, P2D20, P2D21, P2D30, P2D31;
+ P2D00 = i_vertex2d[0].x;
+ P2D01 = i_vertex2d[0].y;
+ P2D10 = i_vertex2d[1].x;
+ P2D11 = i_vertex2d[1].y;
+ P2D20 = i_vertex2d[2].x;
+ P2D21 = i_vertex2d[2].y;
+ P2D30 = i_vertex2d[3].x;
+ P2D31 = i_vertex2d[3].y;
+ NyARPerspectiveProjectionMatrix prjmat = this._projection_mat_ref;
+ double CP0 = prjmat.m00, CP1 = prjmat.m01, CP2 = prjmat.m02, CP4 = prjmat.m10, CP5 = prjmat.m11, CP6 = prjmat.m12, CP8 = prjmat.m20, CP9 = prjmat.m21, CP10 = prjmat.m22;
+ combo03 = CP0 * i_trans.x + CP1 * i_trans.y + CP2 * i_trans.z + prjmat.m03;
+ combo13 = CP4 * i_trans.x + CP5 * i_trans.y + CP6 * i_trans.z + prjmat.m13;
+ combo23 = CP8 * i_trans.x + CP9 * i_trans.y + CP10 * i_trans.z + prjmat.m23;
+ double CACA, SASA, SACA, CA, SA;
+ double CACACB, SACACB, SASACB, CASB, SASB;
+ double SACASC, SACACBSC, SACACBCC, SACACC;
+ double[][] double1D = this.__modifyMatrix_double1D;
+
+ double[] a_factor = double1D[1];
+ double[] sinb = double1D[2];
+ double[] cosb = double1D[3];
+ double[] b_factor = double1D[4];
+ double[] sinc = double1D[5];
+ double[] cosc = double1D[6];
+ double[] c_factor = double1D[7];
+ double w, w2;
+ double wsin, wcos;
+
+ NyARDoublePoint3d angle = io_rot.refAngle();
+ a2 = angle.x;
+ b2 = angle.y;
+ c2 = angle.z;
+
+ // comboの3行目を先に計算
+ for (int i = 0; i < 10; i++)
+ {
+ minerr = 1000000000.0;
+ // sin-cosテーブルを計算(これが外に出せるとは…。)
+ for (int j = 0; j < 3; j++)
+ {
+ w2 = factor * (j - 1);
+ w = a2 + w2;
+ a_factor[j] = w;
+ w = b2 + w2;
+ b_factor[j] = w;
+ sinb[j] = Math.Sin(w);
+ cosb[j] = Math.Cos(w);
+ w = c2 + w2;
+ c_factor[j] = w;
+ sinc[j] = Math.Sin(w);
+ cosc[j] = Math.Cos(w);
+ }
+ //
+ for (t1 = 0; t1 < 3; t1++)
+ {
+ SA = Math.Sin(a_factor[t1]);
+ CA = Math.Cos(a_factor[t1]);
+ // Optimize
+ CACA = CA * CA;
+ SASA = SA * SA;
+ SACA = SA * CA;
+ for (t2 = 0; t2 < 3; t2++)
+ {
+ wsin = sinb[t2];
+ wcos = cosb[t2];
+ CACACB = CACA * wcos;
+ SACACB = SACA * wcos;
+ SASACB = SASA * wcos;
+ CASB = CA * wsin;
+ SASB = SA * wsin;
+ // comboの計算1
+ combo02 = CP0 * CASB + CP1 * SASB + CP2 * wcos;
+ combo12 = CP4 * CASB + CP5 * SASB + CP6 * wcos;
+ combo22 = CP8 * CASB + CP9 * SASB + CP10 * wcos;
+
+ combo02_2 = combo02 * VX02 + combo03;
+ combo02_5 = combo02 * VX12 + combo03;
+ combo02_8 = combo02 * VX22 + combo03;
+ combo02_11 = combo02 * VX32 + combo03;
+ combo12_2 = combo12 * VX02 + combo13;
+ combo12_5 = combo12 * VX12 + combo13;
+ combo12_8 = combo12 * VX22 + combo13;
+ combo12_11 = combo12 * VX32 + combo13;
+ combo22_2 = combo22 * VX02 + combo23;
+ combo22_5 = combo22 * VX12 + combo23;
+ combo22_8 = combo22 * VX22 + combo23;
+ combo22_11 = combo22 * VX32 + combo23;
+ for (t3 = 0; t3 < 3; t3++)
+ {
+ wsin = sinc[t3];
+ wcos = cosc[t3];
+ SACASC = SACA * wsin;
+ SACACC = SACA * wcos;
+ SACACBSC = SACACB * wsin;
+ SACACBCC = SACACB * wcos;
+
+ rot0 = CACACB * wcos + SASA * wcos + SACACBSC - SACASC;
+ rot1 = SACACBCC - SACACC + SASACB * wsin + CACA * wsin;
+ rot2 = -CASB * wcos - SASB * wsin;
+ combo00 = CP0 * rot0 + CP1 * rot1 + CP2 * rot2;
+ combo10 = CP4 * rot0 + CP5 * rot1 + CP6 * rot2;
+ combo20 = CP8 * rot0 + CP9 * rot1 + CP10 * rot2;
+
+ rot0 = -CACACB * wsin - SASA * wsin + SACACBCC - SACACC;
+ rot1 = -SACACBSC + SACASC + SASACB * wcos + CACA * wcos;
+ rot2 = CASB * wsin - SASB * wcos;
+ combo01 = CP0 * rot0 + CP1 * rot1 + CP2 * rot2;
+ combo11 = CP4 * rot0 + CP5 * rot1 + CP6 * rot2;
+ combo21 = CP8 * rot0 + CP9 * rot1 + CP10 * rot2;
+ //
+ err = 0.0;
+ h = combo20 * VX00 + combo21 * VX01 + combo22_2;
+ x = P2D00 - (combo00 * VX00 + combo01 * VX01 + combo02_2) / h;
+ y = P2D01 - (combo10 * VX00 + combo11 * VX01 + combo12_2) / h;
+ err += x * x + y * y;
+ h = combo20 * VX10 + combo21 * VX11 + combo22_5;
+ x = P2D10 - (combo00 * VX10 + combo01 * VX11 + combo02_5) / h;
+ y = P2D11 - (combo10 * VX10 + combo11 * VX11 + combo12_5) / h;
+ err += x * x + y * y;
+ h = combo20 * VX20 + combo21 * VX21 + combo22_8;
+ x = P2D20 - (combo00 * VX20 + combo01 * VX21 + combo02_8) / h;
+ y = P2D21 - (combo10 * VX20 + combo11 * VX21 + combo12_8) / h;
+ err += x * x + y * y;
+ h = combo20 * VX30 + combo21 * VX31 + combo22_11;
+ x = P2D30 - (combo00 * VX30 + combo01 * VX31 + combo02_11) / h;
+ y = P2D31 - (combo10 * VX30 + combo11 * VX31 + combo12_11) / h;
+ err += x * x + y * y;
+ if (err < minerr)
+ {
+ minerr = err;
+ a2 = a_factor[t1];
+ b2 = b_factor[t2];
+ c2 = c_factor[t3];
+ best_idx = t1 + t2 * 3 + t3 * 9;
+ }
+ }
+ }
+ }
+ if (best_idx == (1 + 3 + 9))
+ {
+ factor *= 0.5;
+ }
+ }
+ io_rot.setAngle(a2, b2, c2);
+ /* printf("factor = %10.5f\n", factor*180.0/MD_PI); */
+ return minerr / 4;
+ }
+
+
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMatResult.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMatResult.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMatResult.cs (revision 304)
@@ -7,28 +7,29 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
+using System;
+
namespace jp.nyatla.nyartoolkit.cs.core
{

@@ -39,6 +40,32 @@
public class NyARTransMatResult : NyARDoubleMatrix34
{
public bool has_value = false;
- public NyARDoublePoint3d angle = new NyARDoublePoint3d();
+ /**
+ * この関数は、0-PIの間で値を返します。
+ * @param o_out
+ */
+ public void getZXYAngle(NyARDoublePoint3d o_out)
+ {
+ double sina = this.m21;
+ if (sina >= 1.0)
+ {
+ o_out.x = Math.PI / 2;
+ o_out.y = 0;
+ o_out.z = Math.Atan2(-this.m10, this.m00);
+ }
+ else if (sina <= -1.0)
+ {
+ o_out.x = -Math.PI / 2;
+ o_out.y = 0;
+ o_out.z = Math.Atan2(-this.m10, this.m00);
+ }
+ else
+ {
+ o_out.x = Math.Asin(sina);
+ o_out.z = Math.Atan2(-this.m01, this.m11);
+ o_out.y = Math.Atan2(-this.m20, this.m22);
+ }
+ }
}
+
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs (revision 304)
@@ -1,233 +0,0 @@
-/*
- * 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>
- *
- */
-namespace jp.nyatla.nyartoolkit.cs.core
-{
-/**
- * This class calculates ARMatrix from square information and holds it. --
- * 変換行列を計算して、結果を保持するクラス。
- *
- */
-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;
-
- /**
- * 派生クラスで自分でメンバオブジェクトを指定したい場合はこちらを使う。
- *
- */
- 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);
- //互換性が重要な時は、NyARRotMatrix_ARToolKitを使うこと。
- //理屈はNyARRotMatrix_NyARToolKitもNyARRotMatrix_ARToolKitも同じだけど、少しだけ値がずれる。
- 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;
- }
-
-
-
-
- /**
- * 頂点順序をi_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)
- {
- //頂点順序を考慮した矩形の頂点情報
- 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を矩形情報から計算
- this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);
-
- //平行移動量計算機にオフセット頂点をセット
- this._calculator.setOffsetSquare(this._offset);
-
- //平行移動量計算機に適応先矩形の情報をセット
- this._calculator.setFittedSquare(sqvertex_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;
- }
-
- /*
- * (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;
-
- // io_result_convが初期値なら、transMatで計算する。
- if (!io_result_conv.has_value) {
- this.transMat(i_square, i_direction, i_width, io_result_conv);
- return;
- }
-
- //計算用に頂点情報を初期化(順番調整)
- initVertexOrder(i_square, i_direction, sqvertex_ref,linear_ref);
-
- //基準矩形を設定
- this._offset.setSquare(i_width,this._center);
-
- // 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);
-
- // エラー値が許容範囲でなければTransMatをやり直し
- 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);
- //エラー値が低かったら値を差換え
- 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.setValue(i_rot.refAngle());
- o_result.has_value = true;
- return;
- }
-}
-
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransMat.cs (revision 304)
@@ -0,0 +1,316 @@
+/*
+ * 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>
+ *
+ */
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+/**
+ * This class calculates ARMatrix from square information and holds it. --
+ * 変換行列を計算して、結果を保持するクラス。
+ *
+ */
+public class NyARTransMat : INyARTransMat
+{
+ private const double FIT_DIFF_THRESHOLD = 1.0;
+ private const double FIT_DIFF_THRESHOLD_CONT = 1.0;
+
+ private NyARDoublePoint2d _center=new NyARDoublePoint2d(0,0);
+ private NyARTransOffset _offset=new NyARTransOffset();
+ private NyARPerspectiveProjectionMatrix _projection_mat_ref;
+ protected NyARRotMatrix _rotmatrix;
+ protected INyARTransportVectorSolver _transsolver;
+ protected NyARPartialDifferentiationOptimize _mat_optimize;
+ private NyARCameraDistortionFactor _ref_dist_factor;
+
+
+
+
+ /**
+ * 派生クラスで自分でメンバオブジェクトを指定したい場合はこちらを使う。
+ *
+ */
+ protected NyARTransMat()
+ {
+ //_calculator,_rotmatrix,_mat_optimizeをコンストラクタの終了後に
+ //作成して割り当ててください。
+ return;
+ }
+ public NyARTransMat(NyARParam i_param)
+ {
+ NyARCameraDistortionFactor dist=i_param.getDistortionFactor();
+ NyARPerspectiveProjectionMatrix pmat=i_param.getPerspectiveProjectionMatrix();
+ this._transsolver = new NyARTransportVectorSolver(pmat, 4);
+ this._rotmatrix = new NyARRotMatrix(pmat);
+ this._mat_optimize=new NyARPartialDifferentiationOptimize(pmat);
+ this._ref_dist_factor=dist;
+ this._projection_mat_ref=pmat;
+
+ }
+
+ public void setCenter(double i_x, double i_y)
+ {
+ this._center.x= i_x;
+ this._center.y= i_y;
+ }
+
+
+
+
+ /**
+ * 頂点順序をi_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)
+ {
+ //頂点順序を考慮した矩形の頂点情報
+ 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 NyARDoublePoint2d[] __transMat_vertex_2d = NyARDoublePoint2d.createArray(4);
+ private NyARDoublePoint3d[] __transMat_vertex_3d = NyARDoublePoint3d.createArray(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);
+
+ //平行移動量計算機に、2D座標系をセット
+ NyARDoublePoint2d[] vertex_2d=this.__transMat_vertex_2d;
+ NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;
+ this._ref_dist_factor.ideal2ObservBatch(sqvertex_ref, vertex_2d,4);
+ this._transsolver.set2dVertex(vertex_2d,4);
+
+ //基準矩形の3D座標系を作成
+ this._offset.setSquare(i_width,this._center);
+
+ //回転行列を計算
+ this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);
+
+ //回転後の3D座標系から、平行移動量を計算
+ this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);
+ this._transsolver.solveTransportVector(vertex_3d,trans);
+
+ //計算結果の最適化(平行移動量と回転行列の最適化)
+ this.optimize(this._rotmatrix, trans, this._transsolver,this._offset.vertex, vertex_2d);
+
+ // マトリクスの保存
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);
+ return;
+ }
+
+ /*
+ * (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 o_result_conv)
+ {
+ NyARDoublePoint2d[] sqvertex_ref = __transMat_sqvertex_ref;
+ NyARLinear[] linear_ref=__transMat_linear_ref;
+ NyARDoublePoint3d trans=this.__transMat_trans;
+
+ // io_result_convが初期値なら、transMatで計算する。
+ if (!o_result_conv.has_value) {
+ this.transMat(i_square, i_direction, i_width, o_result_conv);
+ return;
+ }
+
+ //計算用に頂点情報を初期化(順番調整)
+ initVertexOrder(i_square, i_direction, sqvertex_ref,linear_ref);
+
+
+ //平行移動量計算機に、2D座標系をセット
+ NyARDoublePoint2d[] vertex_2d=this.__transMat_vertex_2d;
+ NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;
+ this._ref_dist_factor.ideal2ObservBatch(sqvertex_ref, vertex_2d,4);
+ this._transsolver.set2dVertex(vertex_2d,4);
+
+ //基準矩形の3D座標系を作成
+ this._offset.setSquare(i_width,this._center);
+
+ //回転行列を計算
+ this._rotmatrix.initRotByPrevResult(o_result_conv);
+
+ //回転後の3D座標系から、平行移動量を計算
+ this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);
+ this._transsolver.solveTransportVector(vertex_3d,trans);
+
+ //現在のエラーレートを計算しておく
+ double min_err=errRate(this._rotmatrix,trans, this._offset.vertex, vertex_2d,4,vertex_3d);
+ NyARDoubleMatrix33 rot=this.__rot;
+ //エラーレートが閾値超えてたらアゲイン
+ if(min_err<FIT_DIFF_THRESHOLD_CONT){
+ rot.setValue(this._rotmatrix);
+ //最適化してみる。
+ for (int i = 0;i<5; i++) {
+ //変換行列の最適化
+ this._mat_optimize.modifyMatrix(rot, trans, this._offset.vertex, vertex_2d, 4);
+ double err=errRate(rot,trans,this._offset.vertex, vertex_2d,4,vertex_3d);
+ //System.out.println("E:"+err);
+ if(min_err-err<FIT_DIFF_THRESHOLD){
+ //System.out.println("BREAK");
+ break;
+ }
+ this._transsolver.solveTransportVector(vertex_3d, trans);
+ this._rotmatrix.setValue(rot);
+ min_err=err;
+ }
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);
+ }else{
+ //回転行列を計算
+ this._rotmatrix.initRotBySquare(linear_ref,sqvertex_ref);
+
+ //回転後の3D座標系から、平行移動量を計算
+ this._rotmatrix.getPoint3dBatch(this._offset.vertex,vertex_3d,4);
+ this._transsolver.solveTransportVector(vertex_3d,trans);
+
+ //計算結果の最適化(平行移動量と回転行列の最適化)
+ this.optimize(this._rotmatrix, trans, this._transsolver,this._offset.vertex, vertex_2d);
+ this.updateMatrixValue(this._rotmatrix, this._offset.point, trans,o_result_conv);
+ }
+ return;
+ }
+ private NyARDoubleMatrix33 __rot=new NyARDoubleMatrix33();
+ private double optimize(NyARRotMatrix io_rotmat,NyARDoublePoint3d io_transvec,INyARTransportVectorSolver i_solver,NyARDoublePoint3d[] i_offset_3d,NyARDoublePoint2d[] i_2d_vertex)
+ {
+ //System.out.println("START");
+ NyARDoublePoint3d[] vertex_3d = this.__transMat_vertex_3d;
+ //初期のエラー値を計算
+ double min_err = errRate(io_rotmat, io_transvec, i_offset_3d, i_2d_vertex, 4, vertex_3d);
+ NyARDoubleMatrix33 rot = this.__rot;
+ rot.setValue(io_rotmat);
+ for (int i = 0; i < 5; i++)
+ {
+ //変換行列の最適化
+ this._mat_optimize.modifyMatrix(rot, io_transvec, i_offset_3d, i_2d_vertex, 4);
+ double err = errRate(rot, io_transvec, i_offset_3d, i_2d_vertex, 4, vertex_3d);
+ //System.out.println("E:"+err);
+ if (min_err - err < FIT_DIFF_THRESHOLD)
+ {
+ //System.out.println("BREAK");
+ break;
+ }
+ i_solver.solveTransportVector(vertex_3d, io_transvec);
+ io_rotmat.setValue(rot);
+ min_err = err;
+ }
+ //System.out.println("END");
+ return min_err;
+ }
+
+ //エラーレート計算機
+ public double errRate(NyARDoubleMatrix33 io_rot,NyARDoublePoint3d i_trans, NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint2d[] i_vertex2d,int i_number_of_vertex,NyARDoublePoint3d[] o_rot_vertex)
+ {
+ NyARPerspectiveProjectionMatrix cp = this._projection_mat_ref;
+ double cp00=cp.m00;
+ double cp01=cp.m01;
+ double cp02=cp.m02;
+ double cp11=cp.m11;
+ double cp12=cp.m12;
+
+ double err=0;
+ for(int i=0;i<i_number_of_vertex;i++){
+ double x3d,y3d,z3d;
+ o_rot_vertex[i].x=x3d=io_rot.m00*i_vertex3d[i].x+io_rot.m01*i_vertex3d[i].y+io_rot.m02*i_vertex3d[i].z;
+ o_rot_vertex[i].y=y3d=io_rot.m10*i_vertex3d[i].x+io_rot.m11*i_vertex3d[i].y+io_rot.m12*i_vertex3d[i].z;
+ o_rot_vertex[i].z=z3d=io_rot.m20*i_vertex3d[i].x+io_rot.m21*i_vertex3d[i].y+io_rot.m22*i_vertex3d[i].z;
+ x3d+=i_trans.x;
+ y3d+=i_trans.y;
+ z3d+=i_trans.z;
+
+ //射影変換
+ double x2d=x3d*cp00+y3d*cp01+z3d*cp02;
+ double y2d=y3d*cp11+z3d*cp12;
+ double h2d=z3d;
+
+ //エラーレート計算
+ double t1=i_vertex2d[i].x-x2d/h2d;
+ double t2=i_vertex2d[i].y-y2d/h2d;
+ err+=t1*t1+t2*t2;
+
+ }
+ return err/i_number_of_vertex;
+ }
+ /**
+ * パラメータで変換行列を更新します。
+ *
+ * @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.has_value = true;
+ return;
+ }
+}
+
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_NyARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_NyARToolKit.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_NyARToolKit.cs (revision 304)
@@ -1,89 +0,0 @@
-/*
- * 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
-{
- /**
- * 回転行列計算用の、3x3行列
- * 計算方法はARToolKitと同じだが、ARToolKitにある不要な行列から角度を逆算する
- * 処理を省略しているため、下位12桁目の計算値が異なる。
- *
- */
- public class NyARRotMatrix_NyARToolKit : NyARRotMatrix_ARToolKit
- {
- /**
- * インスタンスを準備します。
- *
- * @param i_param
- */
- public NyARRotMatrix_NyARToolKit(NyARPerspectiveProjectionMatrix i_matrix)
- : base(i_matrix)
- {
- return;
- }
- public override void setAngle(double i_x, double i_y, double i_z)
- {
- double sina = Math.Sin(i_x);
- double cosa = Math.Cos(i_x);
- double sinb = Math.Sin(i_y);
- double cosb = Math.Cos(i_y);
- double sinc = Math.Sin(i_z);
- double cosc = Math.Cos(i_z);
- // Optimize
- double CACA = cosa * cosa;
- double SASA = sina * sina;
- double SACA = sina * cosa;
- double SASB = sina * sinb;
- double CASB = cosa * sinb;
- double SACACB = SACA * cosb;
-
- this.m00 = CACA * cosb * cosc + SASA * cosc + SACACB * sinc - SACA * sinc;
- this.m01 = -CACA * cosb * sinc - SASA * sinc + SACACB * cosc - SACA * cosc;
- this.m02 = CASB;
- this.m10 = SACACB * cosc - SACA * cosc + SASA * cosb * sinc + CACA * sinc;
- this.m11 = -SACACB * sinc + SACA * sinc + SASA * cosb * cosc + CACA * cosc;
- this.m12 = SASB;
- this.m20 = -CASB * cosc - SASB * sinc;
- this.m21 = CASB * sinc - SASB * cosc;
- this.m22 = cosb;
- //angleを逆計算せずに直接代入
- this._angle.x = i_x;
- this._angle.y = i_y;
- this._angle.z = i_z;
- return;
- }
-
- }
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_ARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_ARToolKit.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_ARToolKit.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -42,7 +41,7 @@
*
* @param i_param
*/
- public NyARRotMatrix_ARToolKit(NyARPerspectiveProjectionMatrix i_matrix)
+ public NyARRotMatrix_ARToolKit(NyARPerspectiveProjectionMatrix i_matrix):base(i_matrix)
{
this.__initRot_vec1 = new NyARRotVector(i_matrix);
this.__initRot_vec2 = new NyARRotVector(i_matrix);
@@ -53,71 +52,25 @@
private NyARRotVector __initRot_vec2;
protected NyARDoublePoint3d _angle;

- public override void initRotByPrevResult(NyARTransMatResult i_prev_result)
- {
- this.m00 = i_prev_result.m00;
- this.m01 = i_prev_result.m01;
- this.m02 = i_prev_result.m02;
+ public override void initRotBySquare(NyARLinear[] i_linear,NyARDoublePoint2d[] i_sqvertex)
+ {
+ base.initRotBySquare(i_linear,i_sqvertex);
+ //Matrixからangleをロード
+ this.updateAngleFromMatrix();
+ return;
+ }
+ public NyARDoublePoint3d refAngle()
+ {
+ return this._angle;
+ }

- this.m10 = i_prev_result.m10;
- this.m11 = i_prev_result.m11;
- this.m12 = i_prev_result.m12;
-
- this.m20 = i_prev_result.m20;
- this.m21 = i_prev_result.m21;
- this.m22 = i_prev_result.m22;
- return;
- }
-
-
- public override void initRotBySquare(NyARLinear[] i_linear, NyARDoublePoint2d[] i_sqvertex)
- {
- NyARRotVector vec1 = this.__initRot_vec1;
- NyARRotVector vec2 = this.__initRot_vec2;
-
- //向かい合った辺から、2本のベクトルを計算
-
- //軸1
- vec1.exteriorProductFromLinear(i_linear[0], i_linear[2]);
- vec1.checkVectorByVertex(i_sqvertex[0], i_sqvertex[1]);
-
- //軸2
- vec2.exteriorProductFromLinear(i_linear[1], i_linear[3]);
- vec2.checkVectorByVertex(i_sqvertex[3], i_sqvertex[0]);
-
- //回転の最適化?
- NyARRotVector.checkRotation(vec1, vec2);
-
- this.m00 = vec1.v1;
- this.m10 = vec1.v2;
- this.m20 = vec1.v3;
- this.m01 = vec2.v1;
- this.m11 = vec2.v2;
- this.m21 = vec2.v3;
-
- //最後の軸を計算
- double w02 = vec1.v2 * vec2.v3 - vec1.v3 * vec2.v2;
- double w12 = vec1.v3 * vec2.v1 - vec1.v1 * vec2.v3;
- double w22 = vec1.v1 * vec2.v2 - vec1.v2 * vec2.v1;
- double w = Math.Sqrt(w02 * w02 + w12 * w12 + w22 * w22);
- this.m02 = w02 / w;
- this.m12 = w12 / w;
- this.m22 = w22 / w;
- //Matrixからangleをロード
- this.updateAngleFromMatrix();
- return;
- }
- public override NyARDoublePoint3d refAngle()
- {
- return this._angle;
- }
/**
* 回転角から回転行列を計算してセットします。
* @param i_x
* @param i_y
* @param i_z
*/
- public override void setAngle(double i_x, double i_y, double i_z)
+ public virtual void setAngle(double i_x, double i_y, double i_z)
{
double sina = Math.Sin(i_x);
double cosa = Math.Cos(i_x);
@@ -145,43 +98,8 @@
updateAngleFromMatrix();
return;
}
+
/**
- * i_in_pointを変換行列で座標変換する。
- * @param i_in_point
- * @param i_out_point
- */
- public override void getPoint3d(NyARDoublePoint3d i_in_point, NyARDoublePoint3d i_out_point)
- {
- double x = i_in_point.x;
- double y = i_in_point.y;
- double z = i_in_point.z;
- i_out_point.x = this.m00 * x + this.m01 * y + this.m02 * z;
- i_out_point.y = this.m10 * x + this.m11 * y + this.m12 * z;
- i_out_point.z = this.m20 * x + this.m21 * y + this.m22 * z;
- return;
- }
- /**
- * 複数の頂点を一括して変換する
- * @param i_in_point
- * @param i_out_point
- * @param i_number_of_vertex
- */
- public override void getPoint3dBatch(NyARDoublePoint3d[] i_in_point, NyARDoublePoint3d[] i_out_point, int i_number_of_vertex)
- {
- for (int i = i_number_of_vertex - 1; i >= 0; i--)
- {
- NyARDoublePoint3d out_ptr = i_out_point[i];
- NyARDoublePoint3d in_ptr = i_in_point[i];
- double x = in_ptr.x;
- double y = in_ptr.y;
- double z = in_ptr.z;
- out_ptr.x = this.m00 * x + this.m01 * y + this.m02 * z;
- out_ptr.y = this.m10 * x + this.m11 * y + this.m12 * z;
- out_ptr.z = this.m20 * x + this.m21 * y + this.m22 * z;
- }
- return;
- }
- /**
* 現在のMatrixからangkeを復元する。
* @param o_angle
*/
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_ARToolKit_O2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_ARToolKit_O2.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix_ARToolKit_O2.cs (revision 304)
@@ -0,0 +1,88 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 回転行列計算用の、3x3行列
+ * 計算方法はARToolKitと同じだが、ARToolKitにある不要な行列から角度を逆算する
+ * 処理を省略しているため、下位12桁目の計算値が異なる。
+ *
+ */
+ public class NyARRotMatrix_ARToolKit_O2 : NyARRotMatrix_ARToolKit
+ {
+ /**
+ * インスタンスを準備します。
+ *
+ * @param i_param
+ */
+ public NyARRotMatrix_ARToolKit_O2(NyARPerspectiveProjectionMatrix i_matrix)
+ : base(i_matrix)
+ {
+ return;
+ }
+ public override void setAngle(double i_x, double i_y, double i_z)
+ {
+ double sina = Math.Sin(i_x);
+ double cosa = Math.Cos(i_x);
+ double sinb = Math.Sin(i_y);
+ double cosb = Math.Cos(i_y);
+ double sinc = Math.Sin(i_z);
+ double cosc = Math.Cos(i_z);
+ // Optimize
+ double CACA = cosa * cosa;
+ double SASA = sina * sina;
+ double SACA = sina * cosa;
+ double SASB = sina * sinb;
+ double CASB = cosa * sinb;
+ double SACACB = SACA * cosb;
+
+ this.m00 = CACA * cosb * cosc + SASA * cosc + SACACB * sinc - SACA * sinc;
+ this.m01 = -CACA * cosb * sinc - SASA * sinc + SACACB * cosc - SACA * cosc;
+ this.m02 = CASB;
+ this.m10 = SACACB * cosc - SACA * cosc + SASA * cosb * sinc + CACA * sinc;
+ this.m11 = -SACACB * sinc + SACA * sinc + SASA * cosb * cosc + CACA * cosc;
+ this.m12 = SASB;
+ this.m20 = -CASB * cosc - SASB * sinc;
+ this.m21 = CASB * sinc - SASB * cosc;
+ this.m22 = cosb;
+ //angleを逆計算せずに直接代入
+ this._angle.x = i_x;
+ this._angle.y = i_y;
+ this._angle.z = i_z;
+ return;
+ }
+
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotVector.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotVector.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotVector.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/rotmatrix/NyARRotMatrix.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -36,39 +35,107 @@
* 回転行列計算用の、3x3行列
*
*/
- public abstract class NyARRotMatrix : NyARDoubleMatrix33
+ public class NyARRotMatrix : NyARDoubleMatrix33
{
+ public NyARRotMatrix(NyARPerspectiveProjectionMatrix i_matrix)
+ {
+ this.__initRot_vec1 = new NyARRotVector(i_matrix);
+ this.__initRot_vec2 = new NyARRotVector(i_matrix);
+ return;
+ }
+ private NyARRotVector __initRot_vec1;
+ private NyARRotVector __initRot_vec2;
+
/**
* NyARTransMatResultの内容からNyARRotMatrixを復元します。
* @param i_prev_result
*/
- public abstract void initRotByPrevResult(NyARTransMatResult i_prev_result);
- public abstract void initRotBySquare(NyARLinear[] i_linear, NyARDoublePoint2d[] i_sqvertex);
+ public virtual void initRotByPrevResult(NyARTransMatResult i_prev_result)
+ {
+ this.m00 = i_prev_result.m00;
+ this.m01 = i_prev_result.m01;
+ this.m02 = i_prev_result.m02;
+
+ this.m10 = i_prev_result.m10;
+ this.m11 = i_prev_result.m11;
+ this.m12 = i_prev_result.m12;
+
+ this.m20 = i_prev_result.m20;
+ this.m21 = i_prev_result.m21;
+ this.m22 = i_prev_result.m22;
+ return;
+ }
+
+ public virtual void initRotBySquare(NyARLinear[] i_linear, NyARDoublePoint2d[] i_sqvertex)
+ {
+ NyARRotVector vec1 = this.__initRot_vec1;
+ NyARRotVector vec2 = this.__initRot_vec2;
+
+ //向かい合った辺から、2本のベクトルを計算
+
+ //軸1
+ vec1.exteriorProductFromLinear(i_linear[0], i_linear[2]);
+ vec1.checkVectorByVertex(i_sqvertex[0], i_sqvertex[1]);
+
+ //軸2
+ vec2.exteriorProductFromLinear(i_linear[1], i_linear[3]);
+ vec2.checkVectorByVertex(i_sqvertex[3], i_sqvertex[0]);
+
+ //回転の最適化?
+ NyARRotVector.checkRotation(vec1, vec2);
+
+ this.m00 = vec1.v1;
+ this.m10 = vec1.v2;
+ this.m20 = vec1.v3;
+ this.m01 = vec2.v1;
+ this.m11 = vec2.v2;
+ this.m21 = vec2.v3;
+
+ //最後の軸を計算
+ double w02 = vec1.v2 * vec2.v3 - vec1.v3 * vec2.v2;
+ double w12 = vec1.v3 * vec2.v1 - vec1.v1 * vec2.v3;
+ double w22 = vec1.v1 * vec2.v2 - vec1.v2 * vec2.v1;
+ double w = Math.Sqrt(w02 * w02 + w12 * w12 + w22 * w22);
+ this.m02 = w02 / w;
+ this.m12 = w12 / w;
+ this.m22 = w22 / w;
+ //Matrixからangleをロード
+ return;
+ }
/**
- * 格納しているAngleの参照値を返します。
- * 返したオブジェクトはクラスに所有し続けられ、内容が変わることがあります。
- * @return
- */
- public abstract NyARDoublePoint3d refAngle();
- /**
- * 回転角から回転行列を計算してセットします。
- * @param i_x
- * @param i_y
- * @param i_z
- */
- public abstract void setAngle(double i_x, double i_y, double i_z);
- /**
* i_in_pointを変換行列で座標変換する。
* @param i_in_point
* @param i_out_point
*/
- public abstract void getPoint3d(NyARDoublePoint3d i_in_point, NyARDoublePoint3d i_out_point);
+ public void getPoint3d(NyARDoublePoint3d i_in_point, NyARDoublePoint3d i_out_point)
+ {
+ double x = i_in_point.x;
+ double y = i_in_point.y;
+ double z = i_in_point.z;
+ i_out_point.x = this.m00 * x + this.m01 * y + this.m02 * z;
+ i_out_point.y = this.m10 * x + this.m11 * y + this.m12 * z;
+ i_out_point.z = this.m20 * x + this.m21 * y + this.m22 * z;
+ return;
+ }
/**
* 複数の頂点を一括して変換する
* @param i_in_point
* @param i_out_point
* @param i_number_of_vertex
*/
- public abstract void getPoint3dBatch(NyARDoublePoint3d[] i_in_point, NyARDoublePoint3d[] i_out_point, int i_number_of_vertex);
+ public void getPoint3dBatch(NyARDoublePoint3d[] i_in_point, NyARDoublePoint3d[] i_out_point, int i_number_of_vertex)
+ {
+ for (int i = i_number_of_vertex - 1; i >= 0; i--)
+ {
+ NyARDoublePoint3d out_ptr = i_out_point[i];
+ NyARDoublePoint3d in_ptr = i_in_point[i];
+ double x = in_ptr.x;
+ double y = in_ptr.y;
+ double z = in_ptr.z;
+ out_ptr.x = this.m00 * x + this.m01 * y + this.m02 * z;
+ out_ptr.y = this.m10 * x + this.m11 * y + this.m12 * z;
+ out_ptr.z = this.m20 * x + this.m21 * y + this.m22 * z;
+ }
+ }
}
}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/NyARTransportVectorSolver_ARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/NyARTransportVectorSolver_ARToolKit.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/NyARTransportVectorSolver_ARToolKit.cs (revision 304)
@@ -0,0 +1,133 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+/**
+ * 並進ベクトル[T]を3次元座標[b]と基点の回転済行列[M]から計算します。
+ * ARToolKit互換の数値を計算します。
+ *
+ */
+public class NyARTransportVectorSolver_ARToolKit : INyARTransportVectorSolver
+{
+ private NyARMat _mat_at = new NyARMat(3,8);//3,NUMBER_OF_VERTEX*2
+ private NyARMat _mat_a = new NyARMat(8,3);//NUMBER_OF_VERTEX,3
+ private NyARMat _mat_t = new NyARMat(3,3);//NUMBER_OF_VERTEX,3
+ private NyARMat _mat_c = new NyARMat(8,1);//NUMBER_OF_VERTEX * 2, 1
+ private NyARMat _mat_e = new NyARMat(3,1);
+ private NyARMat _mat_f = new NyARMat(3,1);
+ private double[] _cx=new double[4];
+ private double[] _cy=new double[4];
+
+ private NyARPerspectiveProjectionMatrix _projection_mat;
+ public NyARTransportVectorSolver_ARToolKit(NyARPerspectiveProjectionMatrix i_projection_mat_ref)
+ {
+ this._projection_mat=i_projection_mat_ref;
+ //aとb(aの転置行列)の固定部分を設定。
+ double[][] mata = this._mat_a.getArray();
+ double[][] matat = this._mat_at.getArray();
+
+ //変換用行列のcpara部分を先に作成
+ for (int i = 0; i < 4; i++) {
+ int x2 = i * 2;
+ mata[x2][0] = matat[0][x2] = i_projection_mat_ref.m00;// mat_a->m[j*6+0]=mat_b->m[num*0+j*2] =cpara[0][0];
+ mata[x2][1] = matat[1][x2] = i_projection_mat_ref.m01;// mat_a->m[j*6+1]=mat_b->m[num*2+j*2]=cpara[0][1];
+ mata[x2 + 1][0] = matat[0][x2 + 1] = 0.0;// mat_a->m[j*6+3] =mat_b->m[num*0+j*2+1]= 0.0;
+ mata[x2 + 1][1] = matat[1][x2 + 1] = i_projection_mat_ref.m11;// mat_a->m[j*6+4] =mat_b->m[num*2+j*2+1]= cpara[1][1];
+ }
+ return;
+ }
+ public void set2dVertex(NyARDoublePoint2d[] i_ref_vertex_2d,int i_number_of_vertex)
+ {
+ Debug.Assert(i_number_of_vertex==4);
+ double[] cx=this._cx;
+ double[] cy=this._cy;
+ double cpara02=this._projection_mat.m02;
+ double cpara12=this._projection_mat.m12;
+ NyARMat mat_t=this._mat_t;
+ double[][] mata = this._mat_a.getArray();
+ double[][] matat= this._mat_at.getArray();
+ for (int i = 0; i < 4; i++){
+ cx[i]=i_ref_vertex_2d[i].x;
+ cy[i]=i_ref_vertex_2d[i].y;
+ int x2 = i * 2;
+ mata[x2][2] = matat[2][x2] = cpara02 - i_ref_vertex_2d[i].x;// mat_a->m[j*6+2]=mat_b->m[num*4+j*2]=cpara[0][2]-pos2d[j][0];
+ mata[x2 + 1][2] = matat[2][x2 + 1] = cpara12 - i_ref_vertex_2d[i].y;// mat_a->m[j*6+5]=mat_b->m[num*4+j*2+1]=cpara[1][2]-pos2d[j][1];
+ }
+ //T(3x3行列)の作成
+ mat_t.matrixMul(this._mat_at, this._mat_a);
+ mat_t.matrixSelfInv();
+ return;
+ }
+ /**
+ * 画面座標群と3次元座標群から、平行移動量を計算します。
+ * 2d座標系は、直前に実行したset2dVertexのものを使用します。
+ * @param i_vertex_2d
+ * 直前のset2dVertexコールで指定したものと同じものを指定してください。
+ * @param i_vertex3d
+ * 3次元空間の座標群を設定します。頂点の順番は、画面座標群と同じ順序で格納してください。
+ * @param o_transfer
+ * @throws NyARException
+ */
+ public void solveTransportVector(NyARDoublePoint3d[] i_vertex3d,NyARDoublePoint3d o_transfer)
+ {
+ double[][] matc = this._mat_c.getArray();
+ double cpara00=this._projection_mat.m00;
+ double cpara01=this._projection_mat.m01;
+ double cpara02=this._projection_mat.m02;
+ double cpara11=this._projection_mat.m11;
+ double cpara12=this._projection_mat.m12;
+ double[] cx=this._cx;
+ double[] cy=this._cy;
+
+ //(3D座標?)を一括請求
+ for (int i = 0; i < 4; i++) {
+ int x2 = i+i;
+ NyARDoublePoint3d point3d_ptr=i_vertex3d[i];
+ //透視変換?
+ matc[x2][0] = point3d_ptr.z * cx[i] - cpara00 * point3d_ptr.x - cpara01 * point3d_ptr.y - cpara02 * point3d_ptr.z;// mat_c->m[j*2+0] = wz*pos2d[j][0]-cpara[0][0]*wx-cpara[0][1]*wy-cpara[0][2]*wz;
+ matc[x2 + 1][0] = point3d_ptr.z * cy[i] - cpara11 * point3d_ptr.y - cpara12 * point3d_ptr.z;// mat_c->m[j*2+1]= wz*pos2d[j][1]-cpara[1][1]*wy-cpara[1][2]*wz;
+ }
+ this._mat_e.matrixMul(this._mat_at,this._mat_c);
+ this._mat_f.matrixMul(this._mat_t, this._mat_e);
+
+ double[][] matf = this._mat_f.getArray();
+ o_transfer.x= matf[0][0];// trans[0] = mat_f->m[0];
+ o_transfer.y= matf[1][0];
+ o_transfer.z= matf[2][0];// trans[2] = mat_f->m[2];
+ return;
+ }
+}
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/INyARTransportVectorSolver.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/INyARTransportVectorSolver.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/INyARTransportVectorSolver.cs (revision 304)
@@ -0,0 +1,51 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * 並進ベクトル[T]を3次元座標[b]と基点の回転済行列[M]から計算するインタフェイスです。
+ * [M][T]=[b]
+ *
+ */
+ public interface INyARTransportVectorSolver
+ {
+ void set2dVertex(NyARDoublePoint2d[] i_ref_vertex_2d,int i_number_of_vertex);
+ /**
+ * 画面座標群と3次元座標群から、平行移動量を計算します。
+ * 2d座標系は、直前に実行したset2dVertexのものを使用します。
+ * @param i_vertex_2d
+ * 直前のset2dVertexコールで指定したものと同じものを指定してください。
+ * @param i_vertex3d
+ * 3次元空間の座標群を設定します。頂点の順番は、画面座標群と同じ順序で格納してください。
+ * @param o_transfer
+ * @throws NyARException
+ */
+ void solveTransportVector(NyARDoublePoint3d[] i_vertex3d,NyARDoublePoint3d o_transfer);
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/NyARTransportVectorSolver.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/NyARTransportVectorSolver.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/solver/NyARTransportVectorSolver.cs (revision 304)
@@ -0,0 +1,161 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008-2009 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
+{
+ /**
+ * 並進ベクトル[T]を3次元座標[b]と基点の回転済行列[M]から計算します。
+ *
+ * アルゴリズムは、ARToolKit 拡張現実プログラミング入門 の、P207のものです。
+ *
+ * 計算手順
+ * [A]*[T]=bを、[A]T*[A]*[T]=[A]T*[b]にする。
+ * set2dVertexで[A]T*[A]=[M]を計算して、Aの3列目の情報だけ保存しておく。
+ * getTransportVectorで[M]*[T]=[A]T*[b]を連立方程式で解いて、[T]を得る。
+ */
+ public class NyARTransportVectorSolver : INyARTransportVectorSolver
+ {
+ private double[] _cx;
+ private double[] _cy;
+ private NyARPerspectiveProjectionMatrix _projection_mat;
+ private int _nmber_of_vertex;
+ public NyARTransportVectorSolver(NyARPerspectiveProjectionMatrix i_projection_mat_ref, int i_max_vertex)
+ {
+ this._projection_mat = i_projection_mat_ref;
+ this._cx = new double[i_max_vertex];
+ this._cy = new double[i_max_vertex];
+ return;
+ }
+ private double _a00, _a01_10, _a02_20, _a11, _a12_21, _a22;
+ /**
+ * 画面上の座標群を指定します。
+ * @param i_ref_vertex_2d
+ * 歪み矯正済の画面上の頂点座標群への参照値を指定します。
+ * @throws NyARException
+ *
+ */
+ public void set2dVertex(NyARDoublePoint2d[] i_ref_vertex_2d, int i_number_of_vertex)
+ {
+ //3x2nと2n*3の行列から、最小二乗法計算するために3x3マトリクスを作る。
+ //行列[A]の3列目のキャッシュ
+ double[] cx = this._cx;
+ double[] cy = this._cy;
+
+ double m22;
+ double p00 = this._projection_mat.m00;
+ double p01 = this._projection_mat.m01;
+ double p11 = this._projection_mat.m11;
+ double p12 = this._projection_mat.m12;
+ double p02 = this._projection_mat.m02;
+ double w1, w2, w3, w4;
+ this._a00 = i_number_of_vertex * p00 * p00;
+ this._a01_10 = i_number_of_vertex * p00 * p01;
+ this._a11 = i_number_of_vertex * (p01 * p01 + p11 * p11);
+
+ m22 = 0;
+ w1 = w2 = 0;
+ //[A]T*[A]
+ for (int i = 0; i < i_number_of_vertex; i++)
+ {
+ //座標を保存しておく。
+ w3 = p02 - (cx[i] = i_ref_vertex_2d[i].x);
+ w4 = p12 - (cy[i] = i_ref_vertex_2d[i].y);
+ w1 += w3;
+ w2 += w4;
+ m22 += w3 * w3 + w4 * w4;
+ }
+ this._a02_20 = w1 * p00;
+ this._a12_21 = p01 * w1 + p11 * w2;
+ this._a22 = m22;
+
+ this._nmber_of_vertex = i_number_of_vertex;
+ return;
+ }
+
+ /**
+ * 画面座標群と3次元座標群から、平行移動量を計算します。
+ * 2d座標系は、直前に実行したset2dVertexのものを使用します。
+ * @param i_vertex_2d
+ * 直前のset2dVertexコールで指定したものと同じものを指定してください。
+ * @param i_vertex3d
+ * 3次元空間の座標群を設定します。頂点の順番は、画面座標群と同じ順序で格納してください。
+ * @param o_transfer
+ * @throws NyARException
+ */
+ public void solveTransportVector(NyARDoublePoint3d[] i_vertex3d, NyARDoublePoint3d o_transfer)
+ {
+ int number_of_vertex = this._nmber_of_vertex;
+ double p00 = this._projection_mat.m00;
+ double p01 = this._projection_mat.m01;
+ double p02 = this._projection_mat.m02;
+ double p11 = this._projection_mat.m11;
+ double p12 = this._projection_mat.m12;
+ //行列[A]の3列目のキャッシュ
+ double[] cx = this._cx;
+ double[] cy = this._cy;
+
+ //回転行列を元座標の頂点群に適応
+ //[A]T*[b]を計算
+ double b1 = 0, b2 = 0, b3 = 0;
+ for (int i = 0; i < number_of_vertex; i++)
+ {
+ double w1 = i_vertex3d[i].z * cx[i] - p00 * i_vertex3d[i].x - p01 * i_vertex3d[i].y - p02 * i_vertex3d[i].z;
+ double w2 = i_vertex3d[i].z * cy[i] - p11 * i_vertex3d[i].y - p12 * i_vertex3d[i].z;
+ b1 += w1;
+ b2 += w2;
+ b3 += cx[i] * w1 + cy[i] * w2;
+ }
+ //[A]T*[b]を計算
+ b3 = p02 * b1 + p12 * b2 - b3;//順番変えたらダメよ
+ b2 = p01 * b1 + p11 * b2;
+ b1 = p00 * b1;
+ //([A]T*[A])*[T]=[A]T*[b]を方程式で解く。
+ //a01とa10を0と仮定しても良いんじゃないかな?
+ double a00 = this._a00;
+ double a01 = this._a01_10;
+ double a02 = this._a02_20;
+ double a11 = this._a11;
+ double a12 = this._a12_21;
+ double a22 = this._a22;
+
+ double t1 = a22 * b2 - a12 * b3;
+ double t2 = a12 * b2 - a11 * b3;
+ double t3 = a01 * b3 - a02 * b2;
+ double t4 = a12 * a12 - a11 * a22;
+ double t5 = a02 * a12 - a01 * a22;
+ double t6 = a02 * a11 - a01 * a12;
+ double det = a00 * t4 - a01 * t5 + a02 * t6;
+ o_transfer.x = (a01 * t1 - a02 * t2 + b1 * t4) / det;
+ o_transfer.y = -(a00 * t1 + a02 * t3 + b1 * t5) / det;
+ o_transfer.z = (a00 * t2 + a01 * t3 + b1 * t6) / det;
+
+ return;
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransOffset.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransOffset.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/transmat/NyARTransOffset.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_O3.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_O3.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_O3.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
@@ -214,6 +213,8 @@
this.__updateExtpat_xw = new double[i_xdiv];
this.__updateExtpat_yw = new double[i_ydiv];
this.__updateExtpat_rgbset = new int[i_xdiv * i_ydiv * 3];
+ this._last_pix_resolution_x = i_xdiv;
+ this._last_pix_resolution_y = i_ydiv;
}
return;
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_PseudoAffine.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_PseudoAffine.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_PseudoAffine.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkitCS
+ * PROJECT: NyARToolkitCS(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -77,33 +70,33 @@
* @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);
- //疑似アフィン変換のパラメタマトリクスを計算します。
- //長方形から計算すると、有効要素がm00,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;
- }
+ {
+ 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);
+ //疑似アフィン変換のパラメタマトリクスを計算します。
+ //長方形から計算すると、有効要素がm00,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;
+ mat.inverse(mat);
+ return;
+ }

/**
* 変換行列と頂点座標から、パラメータを計算
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/INyARColorPatt.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/INyARColorPatt.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/INyARColorPatt.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkitCS
+ * PROJECT: NyARToolkitCS(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -43,30 +36,39 @@
*/
public class NyARColorPatt_Perspective : INyARColorPatt
{
- private int[] _patdata;
- private NyARBufferReader _buf_reader;
+ protected int[] _patdata;
+ protected NyARIntPoint2d _pickup_lt = new NyARIntPoint2d();
+ protected int _resolution;
+ protected NyARBufferReader _buf_reader;
+ protected NyARIntSize _size;
+ protected NyARPerspectiveParamGenerator_O1 _perspective_gen;
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();
+
+ private void initializeInstance(int i_width, int i_height, int i_point_per_pix)
+ {
+ Debug.Assert(i_width > 2 && i_height > 2);
+ this._resolution = i_point_per_pix;
+ 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);
+ return;
+ }
+
/**
* 例えば、64
* @param i_width
* 取得画像の解像度幅
* @param i_height
* 取得画像の解像度高さ
+ * @param i_point_per_pix
+ * 1ピクセルあたりの縦横サンプリング数。2なら2x2=4ポイントをサンプリングする。
*/
- public NyARColorPatt_Perspective(int i_width, int i_height)
+ public NyARColorPatt_Perspective(int i_width, int i_height, int i_point_per_pix)
{
- //入力制限
- 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);
+ initializeInstance(i_width, i_height, i_point_per_pix);
+ setEdgeSize(0, 0, i_point_per_pix);
return;
}
/**
@@ -78,16 +80,11 @@
* @param i_edge_percentage
* エッジ幅の割合(ARToolKit標準と同じなら、25)
*/
- public NyARColorPatt_Perspective(int i_width, int i_height, int i_edge_percentage)
+ public NyARColorPatt_Perspective(int i_width, int i_height, int i_resolution, 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);
+ initializeInstance(i_width, i_height, i_resolution);
+ setEdgeSizeByPercent(i_edge_percentage, i_edge_percentage, i_resolution);
return;
}
/**
@@ -101,22 +98,25 @@
* @param i_x_edge
* @param i_y_edge
*/
- public void setEdgeSize(int i_x_edge, int i_y_edge)
+ public void setEdgeSize(int i_x_edge, int i_y_edge, int i_resolution)
{
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._perspective_gen = new NyARPerspectiveParamGenerator_O1(
+ LOCAL_LT, LOCAL_LT,
+ (i_x_edge * 2 + this._size.w) * i_resolution,
+ (i_y_edge * 2 + this._size.h) * i_resolution);
//ピックアップ開始位置を計算
- this._pickup_lt.x = i_x_edge + LOCAL_LT;
- this._pickup_lt.y = i_y_edge + LOCAL_LT;
+ this._pickup_lt.x = i_x_edge * i_resolution + LOCAL_LT;
+ this._pickup_lt.y = i_y_edge * i_resolution + LOCAL_LT;
return;
}
- public void setEdgeSizeByPercent(int i_x_percent, int i_y_percent)
+ public void setEdgeSizeByPercent(int i_x_percent, int i_y_percent, int i_resolution)
{
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);
+ setEdgeSize(this._size.w * i_x_percent / 50, this._size.h * i_y_percent / 50, i_resolution);
return;
}

@@ -142,6 +142,7 @@
return this._pixelreader;
}
private int[] __pickFromRaster_rgb_tmp = new int[3];
+ protected double[] __pickFromRaster_cpara = new double[8];
/**
*
* @param image
@@ -149,42 +150,62 @@
* @return 切り出しに失敗した
* @throws Exception
*/
- public bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square)
+ public virtual bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square)
{
//遠近法のパラメータを計算
- double[] cpara = new double[8];
+ double[] cpara = this.__pickFromRaster_cpara;
if (!this._perspective_gen.getParam(i_square.imvertex, cpara))
{
return false;
}

+ int resolution = this._resolution;
int img_x = image.getWidth();
int img_y = image.getHeight();
+ int res_pix = resolution * resolution;

- int[] rgb_tmp = __pickFromRaster_rgb_tmp;
+ int[] rgb_tmp = this.__pickFromRaster_rgb_tmp;

//ピクセルリーダーを取得
INyARRgbPixelReader reader = image.getRgbPixelReader();
-
- for (int iy = 0; iy < this._size.h; iy++)
+ int p = 0;
+ for (int iy = 0; iy < this._size.h * resolution; iy += resolution)
{
- for (int ix = 0; ix < this._size.w; ix++)
+ //解像度分の点を取る。
+ for (int ix = 0; ix < this._size.w * resolution; ix += resolution)
{
- //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)
+ int r, g, b;
+ r = g = b = 0;
+ for (int i2y = iy; i2y < iy + resolution; i2y++)
{
- 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));
+ int cy = this._pickup_lt.y + i2y;
+ for (int i2x = ix; i2x < ix + resolution; i2x++)
+ {
+ //1ピクセルを作成
+ int cx = this._pickup_lt.x + i2x;
+ 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 = 0; }
+ if (x >= img_x) { x = img_x - 1; }
+ if (y < 0) { y = 0; }
+ if (y >= img_y) { y = img_y - 1; }
+
+ reader.getPixel(x, y, rgb_tmp);
+ r += rgb_tmp[0];
+ g += rgb_tmp[1];
+ b += rgb_tmp[2];
+ }
}
+ r /= res_pix;
+ g /= res_pix;
+ b /= res_pix;
+ this._patdata[p] = ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff));
+ p++;
}
- //ピクセル問い合わせ
- //ピクセルセット
}
+ //ピクセル問い合わせ
+ //ピクセルセット
return true;
}
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective_O2.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective_O2.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/pickup/NyARColorPatt_Perspective_O2.cs (revision 304)
@@ -0,0 +1,716 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+
+ interface IpickFromRaster_Impl
+ {
+ void pickFromRaster(double[] i_cpara, INyARRgbRaster image, NyARSquare i_square, int[] o_patt);
+ }
+
+ /**
+ * 汎用ピックアップ関数
+ *
+ */
+ class pickFromRaster_N : IpickFromRaster_Impl
+ {
+ protected int _resolution;
+ protected NyARIntSize _size_ref;
+ protected NyARIntPoint2d _lt_ref;
+ public pickFromRaster_N(NyARIntPoint2d i_lt, int i_resolution, NyARIntSize i_source_size)
+ {
+ this._lt_ref = i_lt;
+ this._resolution = i_resolution;
+ this._size_ref = i_source_size;
+
+ this._rgb_temp = new int[i_resolution * i_resolution * 3];
+ this._rgb_px = new int[i_resolution * i_resolution];
+ this._rgb_py = new int[i_resolution * i_resolution];
+
+ this._cp1cy_cp2 = new double[i_resolution];
+ this._cp4cy_cp5 = new double[i_resolution];
+ this._cp7cy_1 = new double[i_resolution];
+ return;
+ }
+ private int[] _rgb_temp;
+ private int[] _rgb_px;
+ private int[] _rgb_py;
+ private double[] _cp1cy_cp2;
+ private double[] _cp4cy_cp5;
+ private double[] _cp7cy_1;
+
+ public void pickFromRaster(double[] i_cpara, INyARRgbRaster image, NyARSquare i_square, int[] o_patt)
+ {
+ int i2x, i2y;//プライム変数
+ int x, y;
+ int w;
+ int r, g, b;
+
+ int resolution = this._resolution;
+ int res_pix = resolution * resolution;
+ int img_x = image.getWidth();
+ int img_y = image.getHeight();
+
+ int[] rgb_tmp = this._rgb_temp;
+ int[] rgb_px = this._rgb_px;
+ int[] rgb_py = this._rgb_py;
+
+ double[] cp1cy_cp2 = this._cp1cy_cp2;
+ double[] cp4cy_cp5 = this._cp4cy_cp5;
+ double[] cp7cy_1 = this._cp7cy_1;
+
+ double cp0 = i_cpara[0];
+ double cp3 = i_cpara[3];
+ double cp6 = i_cpara[6];
+ double cp1 = i_cpara[1];
+ double cp2 = i_cpara[2];
+ double cp4 = i_cpara[4];
+ double cp5 = i_cpara[5];
+ double cp7 = i_cpara[7];
+
+
+ int pick_y = this._lt_ref.y;
+ int pick_x = this._lt_ref.x;
+ //ピクセルリーダーを取得
+ INyARRgbPixelReader reader = image.getRgbPixelReader();
+ int p = 0;
+
+
+ for (int iy = 0; iy < this._size_ref.h * resolution; iy += resolution)
+ {
+ w = pick_y + iy;
+ cp1cy_cp2[0] = cp1 * w + cp2;
+ cp4cy_cp5[0] = cp4 * w + cp5;
+ cp7cy_1[0] = cp7 * w + 1.0;
+ for (i2y = 1; i2y < resolution; i2y++)
+ {
+ cp1cy_cp2[i2y] = cp1cy_cp2[i2y - 1] + cp1;
+ cp4cy_cp5[i2y] = cp4cy_cp5[i2y - 1] + cp4;
+ cp7cy_1[i2y] = cp7cy_1[i2y - 1] + cp7;
+ }
+ //解像度分の点を取る。
+
+ for (int ix = 0; ix < this._size_ref.w * resolution; ix += resolution)
+ {
+ int n = 0;
+ w = pick_x + ix;
+ for (i2y = resolution - 1; i2y >= 0; i2y--)
+ {
+ double cp0cx = cp0 * w + cp1cy_cp2[i2y];
+ double cp6cx = cp6 * w + cp7cy_1[i2y];
+ double cp3cx = cp3 * w + cp4cy_cp5[i2y];
+
+ double m = 1 / (cp6cx);
+ double d = -cp6 / (cp6cx * (cp6cx + cp6));
+
+ double m2 = cp0cx * m;
+ double m3 = cp3cx * m;
+ double d2 = cp0cx * d + cp0 * (m + d);
+ double d3 = cp3cx * d + cp3 * (m + d);
+ for (i2x = resolution - 1; i2x >= 0; i2x--)
+ {
+ //1ピクセルを作成
+ x = rgb_px[n] = (int)(m2);
+ y = rgb_py[n] = (int)(m3);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[n] = 0; } else if (x >= img_x) { rgb_px[n] = img_x - 1; }
+ if (y < 0) { rgb_py[n] = 0; } else if (y >= img_y) { rgb_py[n] = img_y - 1; }
+ }
+ n++;
+ m2 += d2;
+ m3 += d3;
+ }
+ }
+ reader.getPixelSet(rgb_px, rgb_py, res_pix, rgb_tmp);
+ r = g = b = 0;
+ for (int i = res_pix * 3 - 1; i > 0; )
+ {
+ b += rgb_tmp[i--];
+ g += rgb_tmp[i--];
+ r += rgb_tmp[i--];
+ }
+ r /= res_pix;
+ g /= res_pix;
+ b /= res_pix;
+ o_patt[p] = ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff));
+ p++;
+ }
+ }
+ return;
+ }
+ }
+ /**
+ * チェックデジット:4127936236942444153655776299710081208144715171590159116971715177917901890204024192573274828522936312731813388371037714083
+ *
+ */
+ class pickFromRaster_1 : IpickFromRaster_Impl
+ {
+ protected NyARIntSize _size_ref;
+ protected NyARIntPoint2d _lt_ref;
+ public pickFromRaster_1(NyARIntPoint2d i_lt, NyARIntSize i_source_size)
+ {
+ this._lt_ref = i_lt;
+ this._size_ref = i_source_size;
+
+ this._rgb_temp = new int[i_source_size.w * 3];
+ this._rgb_px = new int[i_source_size.w];
+ this._rgb_py = new int[i_source_size.w];
+
+ return;
+ }
+ private int[] _rgb_temp;
+ private int[] _rgb_px;
+ private int[] _rgb_py;
+
+
+ public void pickFromRaster(double[] i_cpara, INyARRgbRaster image, NyARSquare i_square, int[] o_patt)
+ {
+ double d0,m0;
+ int x,y;
+
+ int img_x = image.getWidth();
+ int img_y = image.getHeight();
+ int patt_w=this._size_ref.w;
+
+ int[] rgb_tmp = this._rgb_temp;
+ int[] rgb_px=this._rgb_px;
+ int[] rgb_py=this._rgb_py;
+
+
+
+ double cp0=i_cpara[0];
+ double cp3=i_cpara[3];
+ double cp6=i_cpara[6];
+ double cp1=i_cpara[1];
+ double cp4=i_cpara[4];
+ double cp7=i_cpara[7];
+
+
+ int pick_y=this._lt_ref.y;
+ int pick_x=this._lt_ref.x;
+ //ピクセルリーダーを取得
+ INyARRgbPixelReader reader=image.getRgbPixelReader();
+ int p=0;
+
+
+ double cp0cx0,cp3cx0;
+ double cp1cy_cp20=cp1*pick_y+i_cpara[2]+cp0*pick_x;
+ double cp4cy_cp50=cp4*pick_y+i_cpara[5]+cp3*pick_x;
+ double cp7cy_10=cp7*pick_y+1.0+cp6*pick_x;
+
+
+ for(int iy=this._size_ref.h-1;iy>=0;iy--){
+ m0=1/(cp7cy_10);
+ d0=-cp6/(cp7cy_10*(cp7cy_10+cp6));
+
+ cp0cx0=cp1cy_cp20;
+ cp3cx0=cp4cy_cp50;
+
+ //ピックアップシーケンス
+
+ //0番目のピクセル(検査対象)をピックアップ
+
+
+ for(int ix=patt_w-1;ix>=0;ix--){
+ //1ピクセルを作成
+ x=rgb_px[ix]=(int)(cp0cx0*m0);
+ y=rgb_py[ix]=(int)(cp3cx0*m0);
+ if(x<0||x>=img_x||y<0||y>=img_y){
+ if(x<0){rgb_px[ix]=0;}else if(x>=img_x){rgb_px[ix]=img_x-1;}
+ if(y<0){rgb_py[ix]=0;}else if(y>=img_y){rgb_py[ix]=img_y-1;}
+ }
+ cp0cx0+=cp0;
+ cp3cx0+=cp3;
+ m0+=d0;
+ }
+
+ cp1cy_cp20+=cp1;
+ cp4cy_cp50+=cp4;
+ cp7cy_10+=cp7;
+
+ reader.getPixelSet(rgb_px, rgb_py,patt_w, rgb_tmp);
+ for(int ix=patt_w-1;ix>=0;ix--){
+ int idx=ix*3;
+ o_patt[p]=(rgb_tmp[idx]<<16)|(rgb_tmp[idx+1]<<8)|((rgb_tmp[idx+2]&0xff));
+ p++;
+ }
+ }
+
+ return;
+ }
+ }
+
+ /**
+ * 2x2
+ * チェックデジット:207585881161241401501892422483163713744114324414474655086016467027227327958629279571017
+ *
+ */
+ class pickFromRaster_2x : IpickFromRaster_Impl
+ {
+ protected NyARIntSize _size_ref;
+ protected NyARIntPoint2d _lt_ref;
+ public pickFromRaster_2x(NyARIntPoint2d i_lt, NyARIntSize i_source_size)
+ {
+ this._lt_ref = i_lt;
+ this._size_ref = i_source_size;
+
+ this._rgb_temp = new int[i_source_size.w * 4 * 3];
+ this._rgb_px = new int[i_source_size.w * 4];
+ this._rgb_py = new int[i_source_size.w * 4];
+
+
+ return;
+ }
+ private int[] _rgb_temp;
+ private int[] _rgb_px;
+ private int[] _rgb_py;
+
+
+ public void pickFromRaster(double[] i_cpara, INyARRgbRaster image, NyARSquare i_square, int[] o_patt)
+ {
+ double d0, m0, d1, m1;
+ int x, y;
+
+ int img_x = image.getWidth();
+ int img_y = image.getHeight();
+ int patt_w = this._size_ref.w;
+
+ int[] rgb_tmp = this._rgb_temp;
+ int[] rgb_px = this._rgb_px;
+ int[] rgb_py = this._rgb_py;
+
+
+
+ double cp0 = i_cpara[0];
+ double cp3 = i_cpara[3];
+ double cp6 = i_cpara[6];
+ double cp1 = i_cpara[1];
+ double cp4 = i_cpara[4];
+ double cp7 = i_cpara[7];
+
+
+ int pick_y = this._lt_ref.y;
+ int pick_x = this._lt_ref.x;
+ //ピクセルリーダーを取得
+ INyARRgbPixelReader reader = image.getRgbPixelReader();
+ int p = 0;
+
+
+ double cp0cx0, cp3cx0;
+ double cp1cy_cp20 = cp1 * pick_y + i_cpara[2] + cp0 * pick_x;
+ double cp4cy_cp50 = cp4 * pick_y + i_cpara[5] + cp3 * pick_x;
+ double cp7cy_10 = cp7 * pick_y + 1.0 + cp6 * pick_x;
+
+
+ double cp0cx1, cp3cx1;
+ double cp1cy_cp21 = cp1cy_cp20 + cp1;
+ double cp4cy_cp51 = cp4cy_cp50 + cp4;
+ double cp7cy_11 = cp7cy_10 + cp7;
+
+ double cw0 = cp1 + cp1;
+ double cw7 = cp7 + cp7;
+ double cw4 = cp4 + cp4;
+
+ for (int iy = this._size_ref.h - 1; iy >= 0; iy--)
+ {
+ cp0cx0 = cp1cy_cp20;
+ cp3cx0 = cp4cy_cp50;
+ cp0cx1 = cp1cy_cp21;
+ cp3cx1 = cp4cy_cp51;
+
+ m0 = 1 / (cp7cy_10);
+ d0 = -cp6 / (cp7cy_10 * (cp7cy_10 + cp6));
+ m1 = 1 / (cp7cy_11);
+ d1 = -cp6 / (cp7cy_11 * (cp7cy_11 + cp6));
+
+ int n = patt_w * 2 * 2 - 1;
+
+ for (int ix = patt_w * 2 - 1; ix >= 0; ix--)
+ {
+ //[n,0]
+ x = rgb_px[n] = (int)(cp0cx0 * m0);
+ y = rgb_py[n] = (int)(cp3cx0 * m0);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[n] = 0; } else if (x >= img_x) { rgb_px[n] = img_x - 1; }
+ if (y < 0) { rgb_py[n] = 0; } else if (y >= img_y) { rgb_py[n] = img_y - 1; }
+ }
+ cp0cx0 += cp0;
+ cp3cx0 += cp3;
+ m0 += d0;
+ n--;
+ //[n,1]
+ x = rgb_px[n] = (int)(cp0cx1 * m1);
+ y = rgb_py[n] = (int)(cp3cx1 * m1);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[n] = 0; } else if (x >= img_x) { rgb_px[n] = img_x - 1; }
+ if (y < 0) { rgb_py[n] = 0; } else if (y >= img_y) { rgb_py[n] = img_y - 1; }
+ }
+ cp0cx1 += cp0;
+ cp3cx1 += cp3;
+ m1 += d1;
+ n--;
+ }
+ cp7cy_10 += cw7;
+ cp7cy_11 += cw7;
+
+ cp1cy_cp20 += cw0;
+ cp4cy_cp50 += cw4;
+ cp1cy_cp21 += cw0;
+ cp4cy_cp51 += cw4;
+
+
+
+ reader.getPixelSet(rgb_px, rgb_py, patt_w * 4, rgb_tmp);
+ for (int ix = patt_w - 1; ix >= 0; ix--)
+ {
+ int idx = ix * 12;//3*2*2
+ int r = (rgb_tmp[idx + 0] + rgb_tmp[idx + 3] + rgb_tmp[idx + 6] + rgb_tmp[idx + 9]) / 4;
+ int g = (rgb_tmp[idx + 1] + rgb_tmp[idx + 4] + rgb_tmp[idx + 7] + rgb_tmp[idx + 10]) / 4;
+ int b = (rgb_tmp[idx + 2] + rgb_tmp[idx + 5] + rgb_tmp[idx + 8] + rgb_tmp[idx + 11]) / 4;
+ o_patt[p] = (r << 16) | (g << 8) | ((b & 0xff));
+ p++;
+ }
+ }
+
+ return;
+ }
+ }
+
+ /**
+ * 4x4
+ *
+ */
+ class pickFromRaster_4x : IpickFromRaster_Impl
+ {
+ protected NyARIntSize _size_ref;
+ protected NyARIntPoint2d _lt_ref;
+ public pickFromRaster_4x(NyARIntPoint2d i_lt, NyARIntSize i_source_size)
+ {
+ this._lt_ref = i_lt;
+ this._size_ref = i_source_size;
+
+ this._rgb_temp = new int[4 * 4 * 3];
+ this._rgb_px = new int[4 * 4];
+ this._rgb_py = new int[4 * 4];
+ return;
+ }
+ private int[] _rgb_temp;
+ private int[] _rgb_px;
+ private int[] _rgb_py;
+
+ public void pickFromRaster(double[] i_cpara, INyARRgbRaster image, NyARSquare i_square, int[] o_patt)
+ {
+ int x, y;
+ double d, m;
+ double cp6cx, cp0cx, cp3cx;
+ int[] rgb_px = this._rgb_px;
+ int[] rgb_py = this._rgb_py;
+
+ int r, g, b;
+ //遠近法のパラメータを計算
+
+ int img_x = image.getWidth();
+ int img_y = image.getHeight();
+ int[] rgb_tmp = this._rgb_temp;
+ double cp0 = i_cpara[0];
+ double cp3 = i_cpara[3];
+ double cp6 = i_cpara[6];
+ double cp1 = i_cpara[1];
+ double cp2 = i_cpara[2];
+ double cp4 = i_cpara[4];
+ double cp5 = i_cpara[5];
+ double cp7 = i_cpara[7];
+
+
+ int pick_lt_x = this._lt_ref.x;
+ //ピクセルリーダーを取得
+ INyARRgbPixelReader reader = image.getRgbPixelReader();
+
+
+ int p = 0;
+ int py = this._lt_ref.y;
+ for (int iy = this._size_ref.h - 1; iy >= 0; iy--, py += 4)
+ {
+ double cp1cy_cp2_0 = cp1 * py + cp2;
+ double cp4cy_cp5_0 = cp4 * py + cp5;
+ double cp7cy_1_0 = cp7 * py + 1.0;
+
+ double cp1cy_cp2_1 = cp1cy_cp2_0 + cp1;
+ double cp1cy_cp2_2 = cp1cy_cp2_1 + cp1;
+ double cp1cy_cp2_3 = cp1cy_cp2_2 + cp1;
+
+ double cp4cy_cp5_1 = cp4cy_cp5_0 + cp4;
+ double cp4cy_cp5_2 = cp4cy_cp5_1 + cp4;
+ double cp4cy_cp5_3 = cp4cy_cp5_2 + cp4;
+
+ int px = pick_lt_x;
+ //解像度分の点を取る。
+ for (int ix = this._size_ref.w - 1; ix >= 0; ix--, px += 4)
+ {
+
+ cp6cx = cp6 * px;
+ cp0cx = cp0 * px;
+ cp3cx = cp3 * px;
+
+ cp6cx += cp7cy_1_0;
+ m = 1 / cp6cx;
+ d = -cp7 / ((cp6cx + cp7) * cp6cx);
+
+ //1ピクセルを作成[0,0]
+ x = rgb_px[0] = (int)((cp0cx + cp1cy_cp2_0) * m);
+ y = rgb_py[0] = (int)((cp3cx + cp4cy_cp5_0) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[0] = 0; } else if (x >= img_x) { rgb_px[0] = img_x - 1; }
+ if (y < 0) { rgb_py[0] = 0; } else if (y >= img_y) { rgb_py[0] = img_y - 1; }
+ }
+
+ //1ピクセルを作成[0,1]
+ m += d;
+ x = rgb_px[4] = (int)((cp0cx + cp1cy_cp2_1) * m);
+ y = rgb_py[4] = (int)((cp3cx + cp4cy_cp5_1) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[4] = 0; } else if (x >= img_x) { rgb_px[4] = img_x - 1; }
+ if (y < 0) { rgb_py[4] = 0; } else if (y >= img_y) { rgb_py[4] = img_y - 1; }
+ }
+ //1ピクセルを作成[0,2]
+ m += d;
+ x = rgb_px[8] = (int)((cp0cx + cp1cy_cp2_2) * m);
+ y = rgb_py[8] = (int)((cp3cx + cp4cy_cp5_2) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[8] = 0; } else if (x >= img_x) { rgb_px[8] = img_x - 1; }
+ if (y < 0) { rgb_py[8] = 0; } else if (y >= img_y) { rgb_py[8] = img_y - 1; }
+ }
+
+ //1ピクセルを作成[0,3]
+ m += d;
+ x = rgb_px[12] = (int)((cp0cx + cp1cy_cp2_3) * m);
+ y = rgb_py[12] = (int)((cp3cx + cp4cy_cp5_3) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[12] = 0; } else if (x >= img_x) { rgb_px[12] = img_x - 1; }
+ if (y < 0) { rgb_py[12] = 0; } else if (y >= img_y) { rgb_py[12] = img_y - 1; }
+ }
+
+ cp6cx += cp6;
+ cp0cx += cp0;
+ cp3cx += cp3;
+
+ m = 1 / cp6cx;
+ d = -cp7 / ((cp6cx + cp7) * cp6cx);
+
+ //1ピクセルを作成[1,0]
+ x = rgb_px[1] = (int)((cp0cx + cp1cy_cp2_0) * m);
+ y = rgb_py[1] = (int)((cp3cx + cp4cy_cp5_0) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[1] = 0; } else if (x >= img_x) { rgb_px[1] = img_x - 1; }
+ if (y < 0) { rgb_py[1] = 0; } else if (y >= img_y) { rgb_py[1] = img_y - 1; }
+ }
+ //1ピクセルを作成[1,1]
+ m += d;
+ x = rgb_px[5] = (int)((cp0cx + cp1cy_cp2_1) * m);
+ y = rgb_py[5] = (int)((cp3cx + cp4cy_cp5_1) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[5] = 0; } else if (x >= img_x) { rgb_px[5] = img_x - 1; }
+ if (y < 0) { rgb_py[5] = 0; } else if (y >= img_y) { rgb_py[5] = img_y - 1; }
+ }
+ //1ピクセルを作成[1,2]
+ m += d;
+ x = rgb_px[9] = (int)((cp0cx + cp1cy_cp2_2) * m);
+ y = rgb_py[9] = (int)((cp3cx + cp4cy_cp5_2) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[9] = 0; } else if (x >= img_x) { rgb_px[9] = img_x - 1; }
+ if (y < 0) { rgb_py[9] = 0; } else if (y >= img_y) { rgb_py[9] = img_y - 1; }
+ }
+ //1ピクセルを作成[1,3]
+ m += d;
+ x = rgb_px[13] = (int)((cp0cx + cp1cy_cp2_3) * m);
+ y = rgb_py[13] = (int)((cp3cx + cp4cy_cp5_3) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[13] = 0; } else if (x >= img_x) { rgb_px[13] = img_x - 1; }
+ if (y < 0) { rgb_py[13] = 0; } else if (y >= img_y) { rgb_py[13] = img_y - 1; }
+ }
+
+ cp6cx += cp6;
+ cp0cx += cp0;
+ cp3cx += cp3;
+
+ m = 1 / cp6cx;
+ d = -cp7 / ((cp6cx + cp7) * cp6cx);
+
+ //1ピクセルを作成[2,0]
+ x = rgb_px[2] = (int)((cp0cx + cp1cy_cp2_0) * m);
+ y = rgb_py[2] = (int)((cp3cx + cp4cy_cp5_0) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[2] = 0; } else if (x >= img_x) { rgb_px[2] = img_x - 1; }
+ if (y < 0) { rgb_py[2] = 0; } else if (y >= img_y) { rgb_py[2] = img_y - 1; }
+ }
+ //1ピクセルを作成[2,1]
+ m += d;
+ x = rgb_px[6] = (int)((cp0cx + cp1cy_cp2_1) * m);
+ y = rgb_py[6] = (int)((cp3cx + cp4cy_cp5_1) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[6] = 0; } else if (x >= img_x) { rgb_px[6] = img_x - 1; }
+ if (y < 0) { rgb_py[6] = 0; } else if (y >= img_y) { rgb_py[6] = img_y - 1; }
+ }
+ //1ピクセルを作成[2,2]
+ m += d;
+ x = rgb_px[10] = (int)((cp0cx + cp1cy_cp2_2) * m);
+ y = rgb_py[10] = (int)((cp3cx + cp4cy_cp5_2) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[10] = 0; } else if (x >= img_x) { rgb_px[10] = img_x - 1; }
+ if (y < 0) { rgb_py[10] = 0; } else if (y >= img_y) { rgb_py[10] = img_y - 1; }
+ }
+ //1ピクセルを作成[2,3](ここ計算ずれします。)
+ m += d;
+ x = rgb_px[14] = (int)((cp0cx + cp1cy_cp2_3) * m);
+ y = rgb_py[14] = (int)((cp3cx + cp4cy_cp5_3) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[14] = 0; } else if (x >= img_x) { rgb_px[14] = img_x - 1; }
+ if (y < 0) { rgb_py[14] = 0; } else if (y >= img_y) { rgb_py[14] = img_y - 1; }
+ }
+ cp6cx += cp6;
+ cp0cx += cp0;
+ cp3cx += cp3;
+
+ m = 1 / cp6cx;
+ d = -cp7 / ((cp6cx + cp7) * cp6cx);
+
+ //1ピクセルを作成[3,0]
+ x = rgb_px[3] = (int)((cp0cx + cp1cy_cp2_0) * m);
+ y = rgb_py[3] = (int)((cp3cx + cp4cy_cp5_0) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[3] = 0; } else if (x >= img_x) { rgb_px[3] = img_x - 1; }
+ if (y < 0) { rgb_py[3] = 0; } else if (y >= img_y) { rgb_py[3] = img_y - 1; }
+ }
+ //1ピクセルを作成[3,1]
+ m += d;
+ x = rgb_px[7] = (int)((cp0cx + cp1cy_cp2_1) * m);
+ y = rgb_py[7] = (int)((cp3cx + cp4cy_cp5_1) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[7] = 0; } else if (x >= img_x) { rgb_px[7] = img_x - 1; }
+ if (y < 0) { rgb_py[7] = 0; } else if (y >= img_y) { rgb_py[7] = img_y - 1; }
+ }
+ //1ピクセルを作成[3,2]
+ m += d;
+ x = rgb_px[11] = (int)((cp0cx + cp1cy_cp2_2) * m);
+ y = rgb_py[11] = (int)((cp3cx + cp4cy_cp5_2) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[11] = 0; } else if (x >= img_x) { rgb_px[11] = img_x - 1; }
+ if (y < 0) { rgb_py[11] = 0; } else if (y >= img_y) { rgb_py[11] = img_y - 1; }
+ }
+ //1ピクセルを作成[3,3]
+ m += d;
+ x = rgb_px[15] = (int)((cp0cx + cp1cy_cp2_3) * m);
+ y = rgb_py[15] = (int)((cp3cx + cp4cy_cp5_3) * m);
+ if (x < 0 || x >= img_x || y < 0 || y >= img_y)
+ {
+ if (x < 0) { rgb_px[15] = 0; } else if (x >= img_x) { rgb_px[15] = img_x - 1; }
+ if (y < 0) { rgb_py[15] = 0; } else if (y >= img_y) { rgb_py[15] = img_y - 1; }
+ }
+
+ reader.getPixelSet(rgb_px, rgb_py, 4 * 4, rgb_tmp);
+
+ r = (rgb_tmp[0] + rgb_tmp[3] + rgb_tmp[6] + rgb_tmp[9] + rgb_tmp[12] + rgb_tmp[15] + rgb_tmp[18] + rgb_tmp[21] + rgb_tmp[24] + rgb_tmp[27] + rgb_tmp[30] + rgb_tmp[33] + rgb_tmp[36] + rgb_tmp[39] + rgb_tmp[42] + rgb_tmp[45]) / 16;
+ g = (rgb_tmp[1] + rgb_tmp[4] + rgb_tmp[7] + rgb_tmp[10] + rgb_tmp[13] + rgb_tmp[16] + rgb_tmp[19] + rgb_tmp[22] + rgb_tmp[25] + rgb_tmp[28] + rgb_tmp[31] + rgb_tmp[34] + rgb_tmp[37] + rgb_tmp[40] + rgb_tmp[43] + rgb_tmp[46]) / 16;
+ b = (rgb_tmp[2] + rgb_tmp[5] + rgb_tmp[8] + rgb_tmp[11] + rgb_tmp[14] + rgb_tmp[17] + rgb_tmp[20] + rgb_tmp[23] + rgb_tmp[26] + rgb_tmp[29] + rgb_tmp[32] + rgb_tmp[35] + rgb_tmp[38] + rgb_tmp[41] + rgb_tmp[44] + rgb_tmp[47]) / 16;
+ o_patt[p] = ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff));
+ p++;
+
+ }
+ }
+ return;
+ }
+ }
+
+
+
+
+
+
+
+
+
+ /**
+ * 遠近法を使ったパースペクティブ補正をかけて、ラスタ上の四角形から
+ * 任意解像度の矩形パターンを作成します。
+ *
+ */
+ public class NyARColorPatt_Perspective_O2 : NyARColorPatt_Perspective
+ {
+ private IpickFromRaster_Impl _pickup;
+ public NyARColorPatt_Perspective_O2(int i_width, int i_height, int i_resolution, int i_edge_percentage):base(i_width, i_height, i_resolution, i_edge_percentage)
+ {
+ switch (i_resolution)
+ {
+ case 1:
+ this._pickup = new pickFromRaster_1(this._pickup_lt, this._size);
+ break;
+ case 2:
+ this._pickup = new pickFromRaster_2x(this._pickup_lt, this._size);
+ break;
+ case 4:
+ this._pickup = new pickFromRaster_4x(this._pickup_lt, this._size);
+ break;
+ default:
+ this._pickup = new pickFromRaster_N(this._pickup_lt, i_resolution, this._size);
+ break;
+ }
+ return;
+ }
+
+ public override bool pickFromRaster(INyARRgbRaster image, NyARSquare i_square)
+ {
+ //遠近法のパラメータを計算
+ double[] cpara = this.__pickFromRaster_cpara;
+ if (!this._perspective_gen.getParam(i_square.imvertex, cpara))
+ {
+ return false;
+ }
+ this._pickup.pickFromRaster(cpara, image, i_square, this._patdata);
+ return true;
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationColorData.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationColorData.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationColorData.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_BlackWhite.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_BlackWhite.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_BlackWhite.cs (revision 304)
@@ -1,4 +1,34 @@
-using System;
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattResult.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattResult.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattResult.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_Color_WITHOUT_PCA.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_Color_WITHOUT_PCA.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPatt_Color_WITHOUT_PCA.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/INyARMatchPatt.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/INyARMatchPatt.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/INyARMatchPatt.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationBlackWhiteData.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationBlackWhiteData.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/match/NyARMatchPattDeviationBlackWhiteData.cs (revision 304)
@@ -1,4 +1,34 @@
-using System;
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARCameraDistortionFactor.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARCameraDistortionFactor.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARCameraDistortionFactor.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.utils;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARPerspectiveProjectionMatrix.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARPerspectiveProjectionMatrix.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARPerspectiveProjectionMatrix.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/INyARCameraDistortionFactor.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/INyARCameraDistortionFactor.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/INyARCameraDistortionFactor.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARObserv2IdealMap.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARObserv2IdealMap.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARObserv2IdealMap.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARParam.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARParam.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/param/NyARParam.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System.IO;
@@ -71,7 +70,7 @@
{
try
{
- loadARParam(new StreamReader(i_filename));
+ loadARParam(new StreamReader(i_filename).BaseStream);
}
catch (Exception e)
{
@@ -106,7 +105,10 @@
return;
}

-
+ public void loadARParam(Stream i_stream)
+ {
+ loadARParam(new BinaryReader(i_stream));
+ }
/**
* int arParamLoad( const char *filename, int num, ARParam *param, ...);
* i_streamの入力ストリームからi_num個の設定を読み込み、パラメタを配列にして返します。
@@ -114,28 +116,27 @@
* @param i_stream
* @throws Exception
*/
- public void loadARParam(StreamReader i_stream)
+ public void loadARParam(BinaryReader i_reader)
{
try
{
byte[] buf = new byte[SIZE_OF_PARAM_SET];
- BinaryReader br=new BinaryReader(i_stream.BaseStream);
double[] tmp = new double[12];

// バッファを加工
- this._screen_size.w = endianConv(br.ReadInt32());
- this._screen_size.h = endianConv(br.ReadInt32());
+ this._screen_size.w = endianConv(i_reader.ReadInt32());
+ this._screen_size.h = endianConv(i_reader.ReadInt32());
//double値を12個読み込む
for (int i = 0; i < 12; i++)
{
- tmp[i] =endianConv(br.ReadDouble());
+ tmp[i] = endianConv(i_reader.ReadDouble());
}
//Projectionオブジェクトにセット
this._projection_matrix.setValue(tmp);
//double値を4個読み込む
for (int i = 0; i < 4; i++)
{
- tmp[i] = endianConv(br.ReadDouble());
+ tmp[i] = endianConv(i_reader.ReadDouble());
}
//Factorオブジェクトにセット
this._dist.setValue(tmp);
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster_BasicClass.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster_BasicClass.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster_BasicClass.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/INyARRaster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/INyARRaster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/INyARRaster.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARBinRaster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARBinRaster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARBinRaster.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.utils;
@@ -35,13 +34,13 @@
public class NyARBinRaster : NyARRaster_BasicClass
{
private INyARBufferReader _buffer_reader;
- protected int[][] _ref_buf;
+ protected int[] _ref_buf;

public NyARBinRaster(int i_width, int i_height)
: base(new NyARIntSize(i_width, i_height))
{
- this._ref_buf = ArrayUtils.newInt2dArray(i_height,i_width);
- this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_INT2D_BIN_8);
+ this._ref_buf = new int[i_height*i_width];
+ this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);
}
public override INyARBufferReader getBufferReader()
{
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARGrayscaleRaster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARGrayscaleRaster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARGrayscaleRaster.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.utils;
@@ -42,7 +41,7 @@
: base(new NyARIntSize(i_width, i_height))
{
this._ref_buf = ArrayUtils.newInt2dArray(i_height, i_width);
- this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_INT2D_GLAY_8);
+ this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_INT2D_GRAY_8);
}
public override INyARBufferReader getBufferReader()
{
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BasicClass.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BasicClass.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BasicClass.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_Blank.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_Blank.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_Blank.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
@@ -56,6 +55,14 @@
o_rgb[i * 3 + 2] = 0;// B
}
}
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ NyARException.notImplement();
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
}

private INyARRgbPixelReader _reader;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/INyARRgbRaster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/INyARRgbRaster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/INyARRgbRaster.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_RGB.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_RGB.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_RGB.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BGRA.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BGRA.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/rgb/NyARRgbRaster_BGRA.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
@@ -66,6 +65,18 @@
}
return;
}
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ byte[] ref_buf = this._parent._ref_buf;
+ int bp = (i_x + i_y * this._parent._size.w) * 4;
+ ref_buf[bp+0] = (byte)i_rgb[0];// R
+ ref_buf[bp+1] = (byte)i_rgb[1];// G
+ ref_buf[bp+2] = (byte)i_rgb[2];// B
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
}

private INyARRgbPixelReader _rgb_reader;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/raster/NyARRaster.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARDoubleMatrixProcessor.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARDoubleMatrixProcessor.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARDoubleMatrixProcessor.cs (revision 304)
@@ -1,164 +0,0 @@
-/*
- * 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の逆行列を計算して、thisへ格納します。
- * @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の逆行列をthisへ格納するコードを書くこと。*/
- NyARException.notImplement();
- return false;
- }
- /**
- * i_srcの逆行列を計算して、結果をo_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: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator.cs (revision 304)
@@ -1,4 +1,28 @@
-using System;
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;
using jp.nyatla.nyartoolkit.cs.utils;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARSystemOfLinearEquationsProcessor.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARSystemOfLinearEquationsProcessor.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARSystemOfLinearEquationsProcessor.cs (revision 304)
@@ -1,32 +1,25 @@
/*
* 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyAREquationSolver.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyAREquationSolver.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyAREquationSolver.cs (revision 304)
@@ -0,0 +1,326 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyAREquationSolver
+ {
+ public static int solve2Equation(double i_a, double i_b, double i_c, double[] o_result)
+ {
+ Debug.Assert(i_a != 0);
+ return solve2Equation(i_b / i_a, i_c / i_a, o_result, 0);
+ }
+
+ public static int solve2Equation(double i_b, double i_c, double[] o_result)
+ {
+ return solve2Equation(i_b, i_c, o_result, 0);
+ }
+
+ public static int solve2Equation(double i_b, double i_c, double[] o_result, int i_result_st)
+ {
+ double t = i_b * i_b - 4 * i_c;
+ if (t < 0)
+ {
+ //虚数根
+ return 0;
+ }
+ if (t == 0)
+ {
+ //重根
+ o_result[i_result_st + 0] = -i_b / (2);
+ return 1;
+ }
+ //実根2個
+ t = Math.Sqrt(t);
+ o_result[i_result_st + 0] = (-i_b + t) / (2);
+ o_result[i_result_st + 1] = (-i_b - t) / (2);
+ return 2;
+ }
+
+ /**
+ * 3次方程式 a*x^3+b*x^2+c*x+d=0の実根を求める。
+ * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html
+ * のコードを基にしてます。
+ * @param i_a
+ * X^3の係数
+ * @param i_b
+ * X^2の係数
+ * @param i_c
+ * X^1の係数
+ * @param i_d
+ * X^0の係数
+ * @param o_result
+ * 実根。double[3]を指定すること。
+ * @return
+ */
+ public static int solve3Equation(double i_a, double i_b, double i_c, double i_d, double[] o_result)
+ {
+ Debug.Assert(i_a != 0);
+ return solve3Equation(i_b / i_a, i_c / i_a, i_d / i_a, o_result);
+ }
+
+ /**
+ * 3次方程式 x^3+b*x^2+c*x+d=0の実根を求める。
+ * だけを求める。
+ * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html
+ * のコードを基にしてます。
+ * @param i_b
+ * X^2の係数
+ * @param i_c
+ * X^1の係数
+ * @param i_d
+ * X^0の係数
+ * @param o_result
+ * 実根。double[1]以上を指定すること。
+ * @return
+ */
+ public static int solve3Equation(double i_b, double i_c, double i_d, double[] o_result)
+ {
+ double tmp, b, p, q;
+ b = i_b / (3);
+ p = b * b - i_c / 3;
+ q = (b * (i_c - 2 * b * b) - i_d) / 2;
+ if ((tmp = q * q - p * p * p) == 0)
+ {
+ // 重根
+ q = cuberoot(q);
+ o_result[0] = 2 * q - b;
+ o_result[1] = -q - b;
+ return 2;
+ }
+ else if (tmp > 0)
+ {
+ // 実根1,虚根2
+ double a3 = cuberoot(q + ((q > 0) ? 1 : -1) * Math.Sqrt(tmp));
+ double b3 = p / a3;
+ o_result[0] = a3 + b3 - b;
+ // 虚根:-0.5*(a3+b3)-b,Math.abs(a3-b3)*Math.sqrt(3.0)/2
+ return 1;
+ }
+ else
+ {
+ // 実根3
+ tmp = 2 * Math.Sqrt(p);
+ double t = Math.Acos(q / (p * tmp / 2));
+ o_result[0] = tmp * Math.Cos(t / 3) - b;
+ o_result[1] = tmp * Math.Cos((t + 2 * Math.PI) / 3) - b;
+ o_result[2] = tmp * Math.Cos((t + 4 * Math.PI) / 3) - b;
+ return 3;
+ }
+ }
+
+
+
+ /**
+ * 4次方程式の実根だけを求める。
+ * @param i_a
+ * X^3の係数
+ * @param i_b
+ * X^2の係数
+ * @param i_c
+ * X^1の係数
+ * @param i_d
+ * X^0の係数
+ * @param o_result
+ * 実根。double[3]を指定すること。
+ * @return
+ */
+ public static int solve4Equation(double i_a, double i_b, double i_c, double i_d, double i_e, double[] o_result)
+ {
+ Debug.Assert(i_a != 0);
+ double A3, A2, A1, A0, B3;
+ A3 = i_b / i_a;
+ A2 = i_c / i_a;
+ A1 = i_d / i_a;
+ A0 = i_e / i_a;
+ B3 = A3 / 4;
+ double p, q, r;
+ double B3_2 = B3 * B3;
+ p = A2 - 6 * B3_2;//A2-6*B3*B3;
+ q = A1 + B3 * (-2 * A2 + 8 * B3_2);//A1-2*A2*B3+8*B3*B3*B3;
+ r = A0 + B3 * (-A1 + A2 * B3) - 3 * B3_2 * B3_2;//A0-A1*B3+A2*B3*B3-3*B3*B3*B3*B3;
+ if (q == 0)
+ {
+ double result_0, result_1;
+ //複二次式
+ int res = solve2Equation(p, r, o_result, 0);
+ switch (res)
+ {
+ case 0:
+ //全て虚数解
+ return 0;
+ case 1:
+ //重根
+ //解は0,1,2の何れか。
+ result_0 = o_result[0];
+ if (result_0 < 0)
+ {
+ //全て虚数解
+ return 0;
+ }
+ //実根1個
+ if (result_0 == 0)
+ {
+ //NC
+ o_result[0] = 0 - B3;
+ return 1;
+ }
+ //実根2個
+ result_0 = Math.Sqrt(result_0);
+ o_result[0] = result_0 - B3;
+ o_result[1] = -result_0 - B3;
+ return 2;
+ case 2:
+ //実根2個だからt==t2==0はありえない。(case1)
+ //解は、0,2,4の何れか。
+ result_0 = o_result[0];
+ result_1 = o_result[1];
+ int number_of_result = 0;
+ if (result_0 > 0)
+ {
+ //NC
+ result_0 = Math.Sqrt(result_0);
+ o_result[0] = result_0 - B3;
+ o_result[1] = -result_0 - B3;
+ number_of_result += 2;
+ }
+ if (result_1 > 0)
+ {
+ //NC
+ result_1 = Math.Sqrt(result_1);
+ o_result[number_of_result + 0] = result_1 - B3;
+ o_result[number_of_result + 1] = -result_1 - B3;
+ number_of_result += 2;
+ }
+ return number_of_result;
+ default:
+ throw new NyARException();
+ }
+ }
+ else
+ {
+ //それ以外
+ //最適化ポイント:
+ //u^3 + (2*p)*u^2 +((- 4*r)+(p^2))*u -q^2= 0
+ double u = solve3Equation_1((2 * p), (-4 * r) + (p * p), -q * q);
+ if (u < 0)
+ {
+ //全て虚数解
+ return 0;
+ }
+ double ru = Math.Sqrt(u);
+ //2次方程式を解いてyを計算(最適化ポイント)
+ int result_1st, result_2nd;
+ result_1st = solve2Equation(-ru, (p + u) / 2 + ru * q / (2 * u), o_result, 0);
+ //配列使い回しのために、変数に退避
+ switch (result_1st)
+ {
+ case 0:
+ break;
+ case 1:
+ o_result[0] = o_result[0] - B3;
+ break;
+ case 2:
+ o_result[0] = o_result[0] - B3;
+ o_result[1] = o_result[1] - B3;
+ break;
+ default:
+ throw new NyARException();
+ }
+ result_2nd = solve2Equation(ru, (p + u) / 2 - ru * q / (2 * u), o_result, result_1st);
+ //0,1番目に格納
+ switch (result_2nd)
+ {
+ case 0:
+ break;
+ case 1:
+ o_result[result_1st + 0] = o_result[result_1st + 0] - B3;
+ break;
+ case 2:
+ o_result[result_1st + 0] = o_result[result_1st + 0] - B3;
+ o_result[result_1st + 1] = o_result[result_1st + 1] - B3;
+ break;
+ default:
+ throw new NyARException();
+ }
+ return result_1st + result_2nd;
+ }
+ }
+ /**
+ * 3乗根を求められないシステムで、3乗根を求めます。
+ * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html
+ * @param i_in
+ * @return
+ */
+ private static double cuberoot(double i_in)
+ {
+ double res = Math.Pow(Math.Abs(i_in), 1.0 / 3.0);
+ return (i_in >= 0) ? res : -res;
+ }
+ /**
+ * 3次方程式の実根を1個だけ求める。
+ * 4字方程式で使う。
+ * @param i_b
+ * @param i_c
+ * @param i_d
+ * @param o_result
+ * @return
+ */
+ private static double solve3Equation_1(double i_b, double i_c, double i_d)
+ {
+ double tmp, b, p, q;
+ b = i_b / (3);
+ p = b * b - i_c / 3;
+ q = (b * (i_c - 2 * b * b) - i_d) / 2;
+ if ((tmp = q * q - p * p * p) == 0)
+ {
+ // 重根
+ q = cuberoot(q);
+ return 2 * q - b;
+ }
+ else if (tmp > 0)
+ {
+ // 実根1,虚根2
+ double a3 = cuberoot(q + ((q > 0) ? 1 : -1) * Math.Sqrt(tmp));
+ double b3 = p / a3;
+ return a3 + b3 - b;
+ }
+ else
+ {
+ // 実根3
+ tmp = 2 * Math.Sqrt(p);
+ double t = Math.Acos(q / (p * tmp / 2));
+ return tmp * Math.Cos(t / 3) - b;
+ }
+ }
+
+
+ }
+
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator_O1.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator_O1.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/utils/NyARPerspectiveParamGenerator_O1.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkitCS
+ * PROJECT: NyARToolkitCS(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntSize.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntSize.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntSize.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix22.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix22.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix22.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkit
+ * PROJECT: NyARToolkit(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/

@@ -63,5 +56,23 @@
o_value[4] = this.m11;
return;
}
+ public bool inverse(NyARDoubleMatrix22 i_src)
+ {
+ 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;
+ this.m00=a22*det;
+ this.m01=-a12*det;
+ this.m10=a21*det;
+ this.m11=-a11*det;
+ return true;
+ }
}
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix33.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix33.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix33.cs (revision 304)
@@ -1,34 +1,31 @@
/*
* 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
+
+using System.Collections.Generic;
+using System;
+
namespace jp.nyatla.nyartoolkit.cs.core
{

@@ -68,6 +65,19 @@
this.m22 = i_value[8];
return;
}
+ public void setValue(NyARDoubleMatrix33 i_value)
+ {
+ this.m00 = i_value.m00;
+ this.m01 = i_value.m01;
+ this.m02 = i_value.m02;
+ this.m10 = i_value.m10;
+ this.m11 = i_value.m11;
+ this.m12 = i_value.m12;
+ this.m20 = i_value.m20;
+ this.m21 = i_value.m21;
+ this.m22 = i_value.m22;
+ return;
+ }
/**
* 遅いからあんまり使わないでね。
*/
@@ -84,5 +94,84 @@
o_value[8] = this.m22;
return;
}
+ public bool inverse(NyARDoubleMatrix33 i_src)
+ {
+ double a11,a12,a13,a21,a22,a23,a31,a32,a33;
+ double b11,b12,b13,b21,b22,b23,b31,b32,b33;
+ a11=i_src.m00;a12=i_src.m01;a13=i_src.m02;
+ a21=i_src.m10;a22=i_src.m11;a23=i_src.m12;
+ a31=i_src.m20;a32=i_src.m21;a33=i_src.m22;
+
+ b11=a22*a33-a23*a32;
+ b12=a32*a13-a33*a12;
+ b13=a12*a23-a13*a22;
+
+ b21=a23*a31-a21*a33;
+ b22=a33*a11-a31*a13;
+ b23=a13*a21-a11*a23;
+
+ b31=a21*a32-a22*a31;
+ b32=a31*a12-a32*a11;
+ b33=a11*a22-a12*a21;
+
+ double det_1=a11*b11+a21*b12+a31*b13;
+ if(det_1==0){
+ return false;
+ }
+ det_1=1/det_1;
+
+ this.m00=b11*det_1;
+ this.m01=b12*det_1;
+ this.m02=b13*det_1;
+
+ this.m10=b21*det_1;
+ this.m11=b22*det_1;
+ this.m12=b23*det_1;
+
+ this.m20=b31*det_1;
+ this.m21=b32*det_1;
+ this.m22=b33*det_1;
+
+ return true;
+ }
+ /**
+ * この関数は、0-PIの間で値を返します。
+ * @param o_out
+ */
+ public void getZXYAngle(NyARDoublePoint3d o_out)
+ {
+ double sina = this.m21;
+ if (sina >= 1.0) {
+ o_out.x = Math.PI / 2;
+ o_out.y = 0;
+ o_out.z = Math.Atan2(-this.m10, this.m00);
+ } else if (sina <= -1.0) {
+ o_out.x = -Math.PI / 2;
+ o_out.y = 0;
+ o_out.z = Math.Atan2(-this.m10, this.m00);
+ } else {
+ o_out.x = Math.Asin(sina);
+ o_out.z = Math.Atan2(-this.m01, this.m11);
+ o_out.y = Math.Atan2(-this.m20, this.m22);
+ }
+ }
+ public void setZXYAngle(double i_x, double i_y, double i_z)
+ {
+ double sina = Math.Sin(i_x);
+ double cosa = Math.Cos(i_x);
+ double sinb = Math.Sin(i_y);
+ double cosb = Math.Cos(i_y);
+ double sinc = Math.Sin(i_z);
+ double cosc = Math.Cos(i_z);
+ this.m00 = cosc * cosb - sinc * sina * sinb;
+ this.m01 = -sinc * cosa;
+ this.m02 = cosc * sinb + sinc * sina * cosb;
+ this.m10 = sinc * cosb + cosc * sina * sinb;
+ this.m11 = cosc * cosa;
+ this.m12 = sinc * sinb - cosc * sina * cosb;
+ this.m20 = -cosa * sinb;
+ this.m21 = sina;
+ this.m22 = cosb * cosa;
+ }
}
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix34.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix34.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix34.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkit
+ * PROJECT: NyARToolkit(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix44.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix44.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/NyARDoubleMatrix44.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkit
+ * PROJECT: NyARToolkit(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -108,6 +101,92 @@
o_value[15] = this.m33;
return;
}
+ public bool inverse(NyARDoubleMatrix44 i_src)
+ {
+ 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;
+
+ this.m00=b11*det_1;
+ this.m01=b12*det_1;
+ this.m02=b13*det_1;
+ this.m03=b14*det_1;
+
+ this.m10=b21*det_1;
+ this.m11=b22*det_1;
+ this.m12=b23*det_1;
+ this.m13=b24*det_1;
+
+ this.m20=b31*det_1;
+ this.m21=b32*det_1;
+ this.m22=b33*det_1;
+ this.m23=b34*det_1;
+
+ this.m30=b41*det_1;
+ this.m31=b42*det_1;
+ this.m32=b43*det_1;
+ this.m33=b44*det_1;
+
+ return true;
+ }
}

}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/INyARDoubleMatrix.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/INyARDoubleMatrix.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/matrix/INyARDoubleMatrix.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntPointStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntPointStack.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntPointStack.cs (revision 304)
@@ -7,54 +7,40 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.utils;
namespace jp.nyatla.nyartoolkit.cs.core
{

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

- override protected void onReservRequest(int i_start, int i_end, object[] i_buffer)
+ protected override NyARIntPoint2d createElement()
{
- for (int i = i_start; i < i_end; i++)
- {
- i_buffer[i] = new NyARIntPoint2d();
- }
+ return new NyARIntPoint2d();
}
-
- new public NyARIntPoint2d[] getArray()
- {
- return (NyARIntPoint2d[])this._items;
- }
-
- new public NyARIntPoint2d prePush()
- {
- return (NyARIntPoint2d)base.prePush();
- }
}
}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntRectStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntRectStack.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/stack/NyARIntRectStack.cs (revision 304)
@@ -7,55 +7,40 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.utils;

namespace jp.nyatla.nyartoolkit.cs.core
{
- public class NyARIntRectStack : NyObjectStack
+ public class NyARIntRectStack : NyObjectStack<NyARIntRect>
{
- public NyARIntRectStack(int i_length): base(new NyARIntRect[i_length])
+ public NyARIntRectStack(int i_length): base(i_length)
{

}
-
- override protected void onReservRequest(int i_start, int i_end, object[] i_buffer)
+ protected override NyARIntRect createElement()
{
- for (int i = i_start; i < i_end; i++)
- {
- i_buffer[i] = new NyARIntRect();
- }
+ return new NyARIntRect();
}
-
- new public NyARIntRect[] getArray()
- {
- return (NyARIntRect[])this._items;
- }
-
- new public NyARIntRect prePush()
- {
- return (NyARIntRect)base.prePush();
- }
}
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntRect.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntRect.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntRect.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint2d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint2d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint2d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint2d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint2d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARIntPoint2d.cs (revision 304)
@@ -1,4 +1,34 @@
-using System;
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
using System.Collections.Generic;
using System.Text;

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARLinear.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARLinear.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARLinear.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint3d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint3d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/types/NyARDoublePoint3d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter_GsToBin.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter_GsToBin.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter_GsToBin.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter_RgbToGs.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter_RgbToGs.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter_RgbToGs.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/rgb2bin/INyARRasterFilter_RgbToBin.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/rgb2bin/INyARRasterFilter_RgbToBin.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/rgb2bin/INyARRasterFilter_RgbToBin.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/rgb2bin/NyARRasterFilter_ARToolkitThreshold.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/rgb2bin/NyARRasterFilter_ARToolkitThreshold.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/rgb2bin/NyARRasterFilter_ARToolkitThreshold.cs (revision 304)
@@ -7,251 +7,366 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System.Diagnostics;
namespace jp.nyatla.nyartoolkit.cs.core
{
- /**
- * 定数閾値による2値化をする。
- *
- */
public class NyARRasterFilter_ARToolkitThreshold : INyARRasterFilter_RgbToBin
{
- private int _threshold;
-
- public NyARRasterFilter_ARToolkitThreshold(int i_threshold)
+ interface IdoThFilterImpl
{
- this._threshold = i_threshold;
+ void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output, NyARIntSize i_size, int i_threshold);
}
- public void setThreshold(int i_threshold)
+ class doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24 : IdoThFilterImpl
{
- this._threshold = i_threshold;
- }
-
- public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output)
- {
- INyARBufferReader in_buffer_reader = i_input.getBufferReader();
- INyARBufferReader out_buffer_reader = i_output.getBufferReader();
- int in_buf_type = in_buffer_reader.getBufferType();
-
- Debug.Assert(out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT2D_BIN_8));
- Debug.Assert(checkInputType(in_buf_type) == true);
- Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true);
-
- int[][] out_buf = (int[][])out_buffer_reader.getBuffer();
-
- NyARIntSize size = i_output.getSize();
- switch (in_buffer_reader.getBufferType())
+ public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output, NyARIntSize i_size, int i_threshold)
{
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
- convert24BitRgb((byte[])i_input.getBufferReader().getBuffer(), out_buf, size);
- break;
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:
- convert32BitRgbx((byte[])i_input.getBufferReader().getBuffer(), out_buf, size);
- break;
- case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:
- convert16BitRgb565word((short[])i_input.getBufferReader().getBuffer(), out_buf, size);
- break;
- default:
- throw new NyARException();
- }
- return;
- }
- private void convert16BitRgb565word(short[] i_in, int[][] i_out, NyARIntSize i_size)
- {
- int size_w = i_size.w;
- int x_mod_end = size_w - (size_w % 8);
- int th = this._threshold * 3;
- int bp = (size_w * i_size.h - 1);
- uint w=0;
- int x;
- uint px;
- for (int y = i_size.h - 1; y >= 0; y--)
- {
- int[] row_ptr = i_out[y];
- //端数分
- for (x = size_w - 1; x >= x_mod_end; x--)
- {
- px =(uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x] = w <= th ? 0 : 1;
- bp--;
- }
- //タイリング
- for (; x >= 0; x -= 8)
- {
- px =(uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 1] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 2] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 3] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 4] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 5] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 6] = w <= th ? 0 : 1;
- bp--;
- px = (uint)i_in[bp];
- w = ((px & 0xf800) >> 8) + ((px & 0x07e0) >> 3) + ((px & 0x001f) << 3);
- row_ptr[x - 7] = w <= th ? 0 : 1;
- bp--;
- }
- }
- return;
- }
+ int[] out_buf = (int[])i_output.getBuffer();
+ byte[] in_buf = (byte[])i_input.getBuffer();

-
- private void convert24BitRgb(byte[] i_in, int[][] i_out, NyARIntSize i_size)
- {
- int size_w = i_size.w;
- int x_mod_end = size_w - (size_w % 8);
- int th = this._threshold * 3;
- int bp = (size_w * i_size.h - 1) * 3;
- int w;
- int x;
- for (int y = i_size.h - 1; y >= 0; y--)
- {
- int[] row_ptr = i_out[y];
- //端数分
- for (x = size_w - 1; x >= x_mod_end; x--)
+ int th = i_threshold * 3;
+ int bp = (i_size.w * i_size.h - 1) * 3;
+ int w;
+ int xy;
+ int pix_count = i_size.h * i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+ for (xy = pix_count - 1; xy >= pix_mod_part; xy--)
{
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x] = w <= th ? 0 : 1;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
}
- //タイリング
- for (; x >= 0; x -= 8)
+ //タイリング
+ for (; xy >= 0; )
{
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x] = w <= th ? 0 : 1;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 1] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 2] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 3] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 4] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 5] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 6] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 7] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 3;
+ xy--;
}
+ return;
}
- return;
+
}
- private void convert32BitRgbx(byte[] i_in, int[][] i_out, NyARIntSize i_size)
+ class doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32 : IdoThFilterImpl
{
- int size_w = i_size.w;
- int x_mod_end = size_w - (size_w % 8);
- int th = this._threshold * 3;
- int bp = (size_w * i_size.h - 1) * 4;
- int w;
- int x;
- for (int y = i_size.h - 1; y >= 0; y--)
+ public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output, NyARIntSize i_size, int i_threshold)
{
- int[] row_ptr = i_out[y];
+ int[] out_buf = (int[])i_output.getBuffer();
+ byte[] in_buf = (byte[])i_input.getBuffer();

- //端数分
- for (x = size_w - 1; x >= x_mod_end; x--)
+ int th = i_threshold * 3;
+ int bp = (i_size.w * i_size.h - 1) * 4;
+ int w;
+ int xy;
+ int pix_count = i_size.h * i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+ for (xy = pix_count - 1; xy >= pix_mod_part; xy--)
{
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x] = w <= th ? 0 : 1;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
}
//タイリング
- for (; x >= 0; x -= 8)
+ for (; xy >= 0; )
{
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x] = w <= th ? 0 : 1;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 1] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 2] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 3] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 4] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 5] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 6] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
- w = ((i_in[bp] & 0xff) + (i_in[bp + 1] & 0xff) + (i_in[bp + 2] & 0xff));
- row_ptr[x - 7] = w <= th ? 0 : 1;
+ xy--;
+ w = ((in_buf[bp] & 0xff) + (in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
bp -= 4;
+ xy--;
}
}
- return;
}

- private bool checkInputType(int i_input_type)
+ class doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32 : IdoThFilterImpl
{
- switch (i_input_type)
+ public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output, NyARIntSize i_size, int i_threshold)
{
+ int[] out_buf = (int[])i_output.getBuffer();
+ byte[] in_buf = (byte[])i_input.getBuffer();
+
+ int th = i_threshold * 3;
+ int bp = (i_size.w * i_size.h - 1) * 4;
+ int w;
+ int xy;
+ int pix_count = i_size.h * i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+ for (xy = pix_count - 1; xy >= pix_mod_part; xy--)
+ {
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ }
+ //タイリング
+ for (; xy >= 0; )
+ {
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ w = ((in_buf[bp + 1] & 0xff) + (in_buf[bp + 2] & 0xff) + (in_buf[bp + 3] & 0xff));
+ out_buf[xy] = w <= th ? 0 : 1;
+ bp -= 4;
+ xy--;
+ }
+ return;
+ }
+
+ }
+
+ class doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32 : IdoThFilterImpl
+ {
+ public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output, NyARIntSize i_size, int i_threshold)
+ {
+ int[] out_buf = (int[])i_output.getBuffer();
+ int[] in_buf = (int[])i_input.getBuffer();
+
+ int th = i_threshold * 3;
+ int w;
+ int xy;
+ int pix_count = i_size.h * i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+
+ for (xy = pix_count - 1; xy >= pix_mod_part; xy--)
+ {
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ }
+ //タイリング
+ for (; xy >= 0; )
+ {
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ w = in_buf[xy];
+ out_buf[xy] = (((w >> 16) & 0xff) + ((w >> 8) & 0xff) + (w & 0xff)) <= th ? 0 : 1;
+ xy--;
+ }
+ }
+ }
+
+ class doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE : IdoThFilterImpl
+ {
+ public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output, NyARIntSize i_size, int i_threshold)
+ {
+ int[] out_buf = (int[])i_output.getBuffer();
+ short[] in_buf = (short[])i_input.getBuffer();
+
+ int th = i_threshold * 3;
+ int w;
+ int xy;
+ int pix_count = i_size.h * i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+
+ for (xy = pix_count - 1; xy >= pix_mod_part; xy--)
+ {
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ }
+ //タイリング
+ for (; xy >= 0; )
+ {
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ w = (int)in_buf[xy];
+ w = ((w & 0xf800) >> 8) + ((w & 0x07e0) >> 3) + ((w & 0x001f) << 3);
+ out_buf[xy] = w <= th ? 0 : 1;
+ xy--;
+ }
+ }
+ }
+
+ private int _threshold;
+ private IdoThFilterImpl _do_threshold_impl;
+
+ public NyARRasterFilter_ARToolkitThreshold(int i_threshold, int i_input_raster_type)
+ {
+ this._threshold = i_threshold;
+ switch (i_input_raster_type)
+ {
case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:
case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
+ this._do_threshold_impl = new doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24();
+ break;
case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:
+ this._do_threshold_impl = new doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32();
+ break;
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:
+ this._do_threshold_impl = new doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32();
+ break;
+ case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:
+ this._do_threshold_impl = new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32();
+ break;
case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:
- return true;
+ this._do_threshold_impl = new doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE();
+ break;
+
default:
- return false;
+ throw new NyARException();
}
+
+
}
+ public void setThreshold(int i_threshold)
+ {
+ this._threshold = i_threshold;
+ }
+
+ public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output)
+ {
+ INyARBufferReader in_buffer_reader = i_input.getBufferReader();
+ INyARBufferReader out_buffer_reader = i_output.getBufferReader();
+
+ Debug.Assert(out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));
+ Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true);
+ this._do_threshold_impl.doThFilter(in_buffer_reader, out_buffer_reader, i_output.getSize(), this._threshold);
+ return;
+ }
+
}
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/rasterfilter/INyARRasterFilter.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
namespace jp.nyatla.nyartoolkit.cs.core
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARCode.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARCode.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARCode.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System.IO;
@@ -203,12 +202,18 @@
return;
}

- public void loadARPatt(StreamReader i_stream)
+ public void loadARPatt(StreamReader i_reader)
{
//ラスタにパターンをロードする。
- NyARCodeFileReader.loadFromARToolKitFormFile(i_stream, this);
+ NyARCodeFileReader.loadFromARToolKitFormFile(i_reader, this);
return;
}
+ public void loadARPatt(Stream i_stream)
+ {
+ //ラスタにパターンをロードする。
+ NyARCodeFileReader.loadFromARToolKitFormFile(new StreamReader(i_stream), this);
+ return;
+ }

}
}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVec.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVec.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/NyARVec.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingLabelStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingLabelStack.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingLabelStack.cs (revision 304)
@@ -1,108 +0,0 @@
-/*
- * 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 jp.nyatla.nyartoolkit.cs.utils;
-
-namespace jp.nyatla.nyartoolkit.cs.core
-{
-
- /**
- * NyLabelの予約型動的配列
- *
- */
- public class NyARLabelingLabelStack : NyObjectStack
- {
- protected NyARLabelingLabelStack(NyARLabelingLabel[] i_label_array)
- : base(i_label_array)
- {
- }
- public NyARLabelingLabelStack(int i_max_array_size)
- : base(new NyARLabelingLabel[i_max_array_size])
- {
- }
-
- override protected void onReservRequest(int i_start, int i_end, object[] i_buffer)
- {
- for (int i = i_start; i < i_end; i++)
- {
- i_buffer[i] = new NyARLabelingLabel();
- }
- }
- new public NyARLabelingLabel[] getArray()
- {
- return (NyARLabelingLabel[])this._items;
- }
- new public NyARLabelingLabel getItem(int i_index)
- {
- return (NyARLabelingLabel)this._items[i_index];
- }
- new public NyARLabelingLabel prePush()
- {
- return (NyARLabelingLabel)base.prePush();
- }
- /**
- * エリアの大きい順にラベルをソートします。
- */
- public void sortByArea()
- {
- int len = this._length;
- int h = len * 13 / 10;
- NyARLabelingLabel[] item = (NyARLabelingLabel[])this._items;
- int swaps;
- int i;
- for (; ; )
- {
- swaps = 0;
- for (i = 0; i + h < len; i++)
- {
- if (item[i + h].area > item[i].area)
- {
- NyARLabelingLabel temp = item[i + h];
- item[i + h] = item[i];
- item[i] = temp;
- swaps++;
- }
- }
- if (h == 1)
- {
- if (swaps == 0)
- {
- break;
- }
- }
- else
- {
- h = h * 10 / 13;
- }
- }
- }
- }
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabeling_ARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabeling_ARToolKit.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabeling_ARToolKit.cs (revision 304)
@@ -1,403 +0,0 @@
-/*
- * 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>
- *
- */
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- /**
- * ARToolKit互換のラベリングクラスです。 ARToolKitと同一な評価結果を返します。
- *
- */
- public class NyARLabeling_ARToolKit : INyARLabeling
- {
- private const int WORK_SIZE = 1024 * 32;// #define WORK_SIZE 1024*32
- private NyARWorkHolder work_holder = new NyARWorkHolder(WORK_SIZE);
- private NyARIntSize _dest_size;
- private INyARLabelingImage _out_image;
-
- public void attachDestination(INyARLabelingImage i_destination_image)
- {
- // サイズチェック
- NyARIntSize size = i_destination_image.getSize();
- this._out_image = i_destination_image;
-
- // NyLabelingImageのイメージ初期化(枠書き)
- int[][] img = (int[][])i_destination_image.getBufferReader().getBuffer();
- for (int i = 0; i < size.w; i++)
- {
- img[0][i] = 0;
- img[size.h - 1][i] = 0;
- }
- for (int i = 0; i < size.h; i++)
- {
- img[i][0] = 0;
- img[i][size.w - 1] = 0;
- }
-
- // サイズ(参照値)を保存
- this._dest_size = size;
- }
- public INyARLabelingImage getAttachedDestination()
- {
- return this._out_image;
- }
- /**
- * static ARInt16 *labeling2( ARUint8 *image, int thresh,int *label_num, int **area, double **pos, int **clip,int **label_ref, int LorR ) 関数の代替品
- * ラスタimageをラベリングして、結果を保存します。 Optimize:STEP[1514->1493]
- *
- * @param i_raster
- * @throws NyARException
- */
- public void labeling(NyARBinRaster i_raster)
- {
- int m, n; /* work */
- int i, j, k;
- INyARLabelingImage out_image = this._out_image;
-
- // サイズチェック
- NyARIntSize in_size = i_raster.getSize();
- this._dest_size.isEqualSize(in_size);
-
- int lxsize = in_size.w;// lxsize = arUtil_c.arImXsize;
- int lysize = in_size.h;// lysize = arUtil_c.arImYsize;
- int[][] label_img = (int[][])out_image.getBufferReader().getBuffer();
-
- // 枠作成はインスタンスを作った直後にやってしまう。
-
- //ラベリング情報のリセット(ラベリングインデックスを使用)
- out_image.reset(true);
-
- int[] label_idxtbl = out_image.getIndexArray();
-
- int[] work2_pt;
- int wk_max = 0;
-
- int label_pixel;
- int[][] raster_buf = (int[][])i_raster.getBufferReader().getBuffer();
- int[] line_ptr;
- int[][] work2 = this.work_holder.work2;
- int[] label_img_pt0,label_img_pt1;
- for (j = 1; j < lysize - 1; j++)
- {// for (int j = 1; j < lysize - 1;j++, pnt += poff*2, pnt2 += 2) {
- line_ptr = raster_buf[j];
- label_img_pt0 = label_img[j];
- label_img_pt1 = label_img[j - 1];
- for (i = 1; i < lxsize - 1; i++)
- {// for(int i = 1; i < lxsize-1;i++, pnt+=poff, pnt2++) {
- // RGBの合計値が閾値より小さいかな?
- if (line_ptr[i] == 0)
- {
- // pnt1 = ShortPointer.wrap(pnt2, -lxsize);//pnt1 =&(pnt2[-lxsize]);
- if (label_img_pt1[i] > 0)
- {// if( *pnt1 > 0 ) {
- label_pixel = label_img_pt1[i];// *pnt2 = *pnt1;
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
- }
- else if (label_img_pt1[i + 1] > 0)
- {// }else if(*(pnt1+1) > 0 ) {
- if (label_img_pt1[i - 1] > 0)
- {// if( *(pnt1-1) > 0 ) {
- m = label_idxtbl[label_img_pt1[i + 1] - 1];// m =work[*(pnt1+1)-1];
- n = label_idxtbl[label_img_pt1[i - 1] - 1];// n =work[*(pnt1-1)-1];
- if (m > n)
- {
- label_pixel = n;// *pnt2 = n;
- // wk=IntPointer.wrap(work, 0);//wk =
- // &(work[0]);
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == m)
- {// if( *wk == m )
- label_idxtbl[k] = n;// *wk = n;
- }
- }
- }
- else if (m < n)
- {
- label_pixel = m;// *pnt2 = m;
- // wk=IntPointer.wrap(work,0);//wk = &(work[0]);
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == n)
- {// if( *wk == n ){
- label_idxtbl[k] = m;// *wk = m;
- }
- }
- }
- else
- {
- label_pixel = m;// *pnt2 = m;
- }
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;
- work2_pt[1] += i;
- work2_pt[2] += j;
- work2_pt[6] = j;
- }
- else if ((label_img_pt0[i - 1]) > 0)
- {// }else if(*(pnt2-1) > 0) {
- m = label_idxtbl[(label_img_pt1[i + 1]) - 1];// m =work[*(pnt1+1)-1];
- n = label_idxtbl[label_img_pt0[i - 1] - 1];// n =work[*(pnt2-1)-1];
- if (m > n)
- {
-
- label_pixel = n;// *pnt2 = n;
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == m)
- {// if( *wk == m ){
- label_idxtbl[k] = n;// *wk = n;
- }
- }
- }
- else if (m < n)
- {
- label_pixel = m;// *pnt2 = m;
- for (k = 0; k < wk_max; k++)
- {
- if (label_idxtbl[k] == n)
- {// if( *wk == n ){
- label_idxtbl[k] = m;// *wk = m;
- }
- }
- }
- else
- {
- label_pixel = m;// *pnt2 = m;
- }
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- }
- else
- {
-
- label_pixel = label_img_pt1[i + 1];// *pnt2 =
- // *(pnt1+1);
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- if (work2_pt[3] > i)
- {// if(
- // work2[((*pnt2)-1)*7+3] >
- // i ){
- work2_pt[3] = i;// work2[((*pnt2)-1)*7+3] = i;
- }
- work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
- }
- }
- else if ((label_img_pt1[i - 1]) > 0)
- {// }else if(
- // *(pnt1-1) > 0 ) {
- label_pixel = label_img_pt1[i - 1];// *pnt2 =
- // *(pnt1-1);
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- if (work2_pt[4] < i)
- {// if( work2[((*pnt2)-1)*7+4] <i ){
- work2_pt[4] = i;// work2[((*pnt2)-1)*7+4] = i;
- }
- work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
- }
- else if (label_img_pt0[i - 1] > 0)
- {// }else if(*(pnt2-1) > 0) {
- label_pixel = label_img_pt0[i - 1];// *pnt2 =*(pnt2-1);
-
- work2_pt = work2[label_pixel - 1];
- work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
- work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
- work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
- if (work2_pt[4] < i)
- {// if( work2[((*pnt2)-1)*7+4] <i ){
- work2_pt[4] = i;// work2[((*pnt2)-1)*7+4] = i;
- }
- }
- else
- {
- // 現在地までの領域を予約
- this.work_holder.reserv(wk_max);
- wk_max++;
- label_idxtbl[wk_max - 1] = wk_max;
- label_pixel = wk_max;// work[wk_max-1] = *pnt2 = wk_max;
- work2_pt = work2[wk_max - 1];
- work2_pt[0] = 1;
- work2_pt[1] = i;
- work2_pt[2] = j;
- work2_pt[3] = i;
- work2_pt[4] = i;
- work2_pt[5] = j;
- work2_pt[6] = j;
- }
- label_img_pt0[i] = label_pixel;
- }
- else
- {
- label_img_pt0[i] = 0;// *pnt2 = 0;
- }
- }
- }
- // インデックステーブルとラベル数の計算
- int wlabel_num = 1;// *label_num = *wlabel_num = j - 1;
-
- for (i = 0; i < wk_max; i++)
- {// for(int i = 1; i <= wk_max; i++,wk++) {
- label_idxtbl[i] = (label_idxtbl[i] == i + 1) ? wlabel_num++ : label_idxtbl[label_idxtbl[i] - 1];// *wk=(*wk==i)?j++:work[(*wk)-1];
- }
- wlabel_num -= 1;// *label_num = *wlabel_num = j - 1;
- if (wlabel_num == 0)
- {// if( *label_num == 0 ) {
- // 発見数0
- out_image.getLabelStack().clear();
- return;
- }
- // ラベル情報の保存等
- NyARLabelingLabelStack label_list = out_image.getLabelStack();
-
- // ラベルバッファを予約
- label_list.reserv(wlabel_num);
-
- // エリアと重心、クリップ領域を計算
- NyARLabelingLabel label_pt;
- NyARLabelingLabel[] labels = label_list.getArray();
- for (i = 0; i < wlabel_num; i++)
- {
- label_pt = labels[i];
- label_pt.id = i + 1;
- label_pt.area = 0;
- label_pt.pos_x = label_pt.pos_y = 0;
- label_pt.clip_l = lxsize;// wclip[i*4+0] = lxsize;
- label_pt.clip_t = lysize;// wclip[i*4+2] = lysize;
- label_pt.clip_r = label_pt.clip_b = 0;// wclip[i*4+3] = 0;
- }
-
- for (i = 0; i < wk_max; i++)
- {
- label_pt = labels[label_idxtbl[i] - 1];
- work2_pt = work2[i];
- label_pt.area += work2_pt[0];
- label_pt.pos_x += work2_pt[1];
- label_pt.pos_y += work2_pt[2];
- if (label_pt.clip_l > work2_pt[3])
- {
- label_pt.clip_l = work2_pt[3];
- }
- if (label_pt.clip_r < work2_pt[4])
- {
- label_pt.clip_r = work2_pt[4];
- }
- if (label_pt.clip_t > work2_pt[5])
- {
- label_pt.clip_t = work2_pt[5];
- }
- if (label_pt.clip_b < work2_pt[6])
- {
- label_pt.clip_b = work2_pt[6];
- }
- }
-
- for (i = 0; i < wlabel_num; i++)
- {// for(int i = 0; i < *label_num; i++ ) {
- label_pt = labels[i];
- label_pt.pos_x /= label_pt.area;
- label_pt.pos_y /= label_pt.area;
- }
- return;
- }
-
- }
-
- /**
- * NyARLabeling_O2のworkとwork2を可変長にするためのクラス
- *
- *
- */
- class NyARWorkHolder
- {
- private const int ARRAY_APPEND_STEP = 256;
-
- public int[][] work2;
-
- private int allocate_size;
-
- /**
- * 最大i_holder_size個の動的割り当てバッファを準備する。
- *
- * @param i_holder_size
- */
- public NyARWorkHolder(int i_holder_size)
- {
- // ポインタだけははじめに確保しておく
- this.work2 = new int[i_holder_size][];
- this.allocate_size = 0;
- }
-
- /**
- * i_indexで指定した番号までのバッファを準備する。
- *
- * @param i_index
- */
- public void reserv(int i_index)
- {
- // アロケート済みなら即リターン
- if (this.allocate_size > i_index)
- {
- return;
- }
- // 要求されたインデクスは範囲外
- if (i_index >= this.work2.Length)
- {
- throw new NyARException();
- }
- // 追加アロケート範囲を計算
- int range = i_index + ARRAY_APPEND_STEP;
- if (range >= this.work2.Length)
- {
- range = this.work2.Length;
- }
- // アロケート
- for (int i = this.allocate_size; i < range; i++)
- {
- this.work2[i] = new int[7];
- }
- this.allocate_size = range;
- }
- }
-}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/INyARLabeling.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/INyARLabeling.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/INyARLabeling.cs (revision 304)
@@ -1,43 +0,0 @@
-/*
- * 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>
- *
- */
-
-namespace jp.nyatla.nyartoolkit.cs.core
-{
-
- public interface INyARLabeling
- {
- void attachDestination(INyARLabelingImage i_destination_image);
- INyARLabelingImage getAttachedDestination();
-
- void labeling(NyARBinRaster i_raster);
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/INyARLabelingImage.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/INyARLabelingImage.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/INyARLabelingImage.cs (revision 304)
@@ -1,40 +0,0 @@
-/*
- * 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>
- *
- */
-namespace jp.nyatla.nyartoolkit.cs.core
-{
- public interface INyARLabelingImage : INyARRaster
- {
- int[] getIndexArray();
- NyARLabelingLabelStack getLabelStack();
- void reset(bool i_label_index_enable);
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingLabel.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingLabel.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingLabel.cs (revision 304)
@@ -1,46 +0,0 @@
-/*
- * 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>
- *
- */
-namespace jp.nyatla.nyartoolkit.cs.core
-{
-
- public class NyARLabelingLabel
- {
- public int id;
- public int area;
- public int clip_r;// 0
- public int clip_l;// 1
- public int clip_b;// 2
- public int clip_t;// 3
- public double pos_x;
- public double pos_y;
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingImage.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingImage.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelingImage.cs (revision 304)
@@ -1,188 +0,0 @@
-/*
- * 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.Diagnostics;
-using jp.nyatla.nyartoolkit.cs.utils;
-namespace jp.nyatla.nyartoolkit.cs.core
-{
-
- /**
- *
- */
- public class NyARLabelingImage : NyARRaster_BasicClass, INyARLabelingImage
- {
- private const int MAX_LABELS = 1024 * 32;
- protected int[][] _ref_buf;
- private INyARBufferReader _buffer_reader;
- protected NyARLabelingLabelStack _label_list;
- protected int[] _index_table;
- protected bool _is_index_table_enable;
- public NyARLabelingImage(int i_width, int i_height)
- : base(new NyARIntSize(i_width, i_height))
- {
- this._ref_buf = ArrayUtils.newInt2dArray(i_height, i_width);
- this._label_list = new NyARLabelingLabelStack(MAX_LABELS);
- this._index_table = new int[MAX_LABELS];
- this._is_index_table_enable = false;
- this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_INT2D);
-
- return;
- }
- public override INyARBufferReader getBufferReader()
- {
- return this._buffer_reader;
- }
-
-
- /**
- * ラベリング結果がインデックステーブルを持つ場合、その配列を返します。
- * 持たない場合、nullを返します。
- *
- * 値がnullの時はラベル番号そのものがラスタに格納されていますが、
- * null以外の時はラスタに格納されているのはインデクス番号です。
- *
- * インデクス番号とラベル番号の関係は、以下の式で表されます。
- * ラベル番号:=value[インデクス番号]
- *
- */
- public int[] getIndexArray()
- {
- return this._is_index_table_enable ? this._index_table : null;
- }
-
- public NyARLabelingLabelStack getLabelStack()
- {
- return this._label_list;
- }
- public void reset(bool i_label_index_enable)
- {
- Debug.Assert(i_label_index_enable == true);//非ラベルモードは未実装
- this._label_list.clear();
- this._is_index_table_enable = i_label_index_enable;
- return;
- }
-
- protected int[] _getContour_xdir = { 0, 1, 1, 1, 0, -1, -1, -1 };
- protected int[] _getContour_ydir = { -1, -1, 0, 1, 1, 1, 0, -1 };
- /**
- * i_labelのラベルの、クリップ領域が上辺に接しているx座標を返します。
- * @param i_index
- * @return
- */
- protected int getTopClipTangentX(NyARLabelingLabel i_label)
- {
- int w;
- int i_label_id = i_label.id;
- int[] index_table = this._index_table;
- int[] limage_j = this._ref_buf[i_label.clip_t];
- int clip1 = i_label.clip_r;
- int[][] limage = this._ref_buf;
- // p1=ShortPointer.wrap(limage,j*xsize+clip.get());//p1 =&(limage[j*xsize+clip[0]]);
- for (int i = i_label.clip_l; i <= clip1; i++)
- {// for( i = clip[0]; i <=clip[1]; i++, p1++ ) {
- w = limage_j[i];
- if (w > 0 && index_table[w - 1] == i_label_id)
- {
- return i;
- }
- }
- //あれ?見つからないよ?
- throw new NyARException();
- }
- /**
- * i_index番目のラベルの輪郭線を配列に返します。
- * @param i_index
- * @param i_array_size
- * @param o_coord_x
- * @param o_coord_y
- * @return
- * 輪郭線の長さを返します。
- * @throws NyARException
- */
- public int getContour(int i_index, int i_array_size, int[] o_coord_x, int[] o_coord_y)
- {
- int[] xdir = this._getContour_xdir;// static int xdir[8] = { 0,1, 1, 1, 0,-1,-1,-1};
- int[] ydir = this._getContour_ydir;// static int ydir[8] = {-1,-1,0, 1, 1, 1, 0,-1};
- NyARLabelingLabel label = this._label_list.getItem(i_index);
- int i;
- //クリップ領域の上端に接しているポイントを得る。
- int sx = getTopClipTangentX(label);
- int sy = label.clip_t;
-
- int coord_num = 1;// marker_info2->coord_num = 1;
- o_coord_x[0] = sx;// marker_info2->x_coord[0] = sx;
- o_coord_y[0] = sy;// marker_info2->y_coord[0] = sy;
- int dir = 5;
-
- int[][] limage = this._ref_buf;
- int c = o_coord_x[0];
- int r = o_coord_y[0];
- for (; ; )
- {
- dir = (dir + 5) % 8;
- for (i = 0; i < 8; i++)
- {
- if (limage[r + ydir[dir]][c + xdir[dir]] > 0)
- {// if(
- // p1[ydir[dir]*xsize+xdir[dir]] > 0 ){
- break;
- }
- dir = (dir + 1) % 8;
- }
- if (i == 8)
- {
- //8方向全て調べたけどラベルが無いよ?
- throw new NyARException();// return(-1);
- }
- // xcoordとycoordをc,rにも保存
- c = c + xdir[dir];// marker_info2->x_coord[marker_info2->coord_num]=marker_info2->x_coord[marker_info2->coord_num-1]
- // + xdir[dir];
- r = r + ydir[dir];// marker_info2->y_coord[marker_info2->coord_num]=marker_info2->y_coord[marker_info2->coord_num-1]+ ydir[dir];
- o_coord_x[coord_num] = c;// marker_info2->x_coord[marker_info2->coord_num]=marker_info2->x_coord[marker_info2->coord_num-1]+ xdir[dir];
- o_coord_y[coord_num] = r;// marker_info2->y_coord[marker_info2->coord_num]=marker_info2->y_coord[marker_info2->coord_num-1]+ ydir[dir];
- // 終了条件判定
- if (c == sx && r == sy)
- {
- coord_num++;
- break;
- }
- coord_num++;
- if (coord_num == i_array_size)
- {// if( marker_info2.coord_num ==Config.AR_CHAIN_MAX-1 ){
- //輪郭が末端に達した
- return coord_num;
- }
- }
- return coord_num;
-
- }
- }
-}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelInfoStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelInfoStack.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelInfoStack.cs (revision 304)
@@ -0,0 +1,85 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+
+ /**
+ * NyLabelの予約型動的配列
+ *
+ */
+ public abstract class NyARLabelInfoStack<T> : NyObjectStack<T> where T: NyARLabelInfo
+ {
+ public NyARLabelInfoStack(int i_max_array_size)
+ : base(i_max_array_size)
+ {
+ }
+ /**
+ * エリアの大きい順にラベルをソートします。
+ */
+ public void sortByArea()
+ {
+ int len = this._length;
+ if (len < 1)
+ {
+ return;
+ }
+ int h = len * 13 / 10;
+ T[] item = this._items;
+ for (; ; )
+ {
+ int swaps = 0;
+ for (int i = 0; i + h < len; i++)
+ {
+ if (item[i + h].area > item[i].area)
+ {
+ T temp = item[i + h];
+ item[i + h] = item[i];
+ item[i] = temp;
+ swaps++;
+ }
+ }
+ if (h == 1)
+ {
+ if (swaps == 0)
+ {
+ break;
+ }
+ }
+ else
+ {
+ h = h * 10 / 13;
+ }
+ }
+ }
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/rlelabeling/RleLabelFragmentInfoStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/rlelabeling/RleLabelFragmentInfoStack.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/rlelabeling/RleLabelFragmentInfoStack.cs (revision 304)
@@ -0,0 +1,50 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class RleLabelFragmentInfoStack : NyARLabelInfoStack<RleLabelFragmentInfoStack.RleLabelFragmentInfo>
+ {
+ public class RleLabelFragmentInfo : NyARLabelInfo
+ {
+ //継承メンバ
+ //int area; // フラグメントラベルの領域数
+ public int entry_x; // フラグメントラベルの位置
+ }
+ public RleLabelFragmentInfoStack(int i_length)
+ : base(i_length)
+ {
+ return;
+ }
+
+ protected override RleLabelFragmentInfoStack.RleLabelFragmentInfo createElement()
+ {
+ return new RleLabelFragmentInfoStack.RleLabelFragmentInfo();
+ }
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/rlelabeling/NyARLabeling_Rle.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/rlelabeling/NyARLabeling_Rle.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/rlelabeling/NyARLabeling_Rle.cs (revision 304)
@@ -0,0 +1,420 @@
+/*
+ * PROJECT: NyARToolkitCS(Extension)
+ * --------------------------------------------------------------------------------
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using jp.nyatla.nyartoolkit.cs.utils;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ class RleInfoStack : NyObjectStack<RleInfoStack.RleInfo>
+ {
+ public class RleInfo
+ {
+ //継承メンバ
+ public int entry_x; // フラグメントラベルの位置
+ public int area;
+ public int clip_r;
+ public int clip_l;
+ public int clip_b;
+ public int clip_t;
+ public long pos_x;
+ public long pos_y;
+ }
+ public RleInfoStack(int i_length):base(i_length)
+ {
+ return;
+ }
+
+ protected override RleInfoStack.RleInfo createElement()
+ {
+ return new RleInfoStack.RleInfo();
+ }
+ }
+
+
+ /**
+ * [strage class]
+ */
+
+
+ class RleElement
+ {
+ public int l;
+ public int r;
+ public int fid;
+ public static RleElement[] createArray(int i_length)
+ {
+ RleElement[] ret = new RleElement[i_length];
+ for (int i = 0; i < i_length; i++)
+ {
+ ret[i] = new RleElement();
+ }
+ return ret;
+ }
+ }
+
+ // RleImageをラベリングする。
+ public class NyARLabeling_Rle
+ {
+ private const int AR_AREA_MAX = 100000;// #define AR_AREA_MAX 100000
+ private const int AR_AREA_MIN = 70;// #define AR_AREA_MIN 70
+
+ private RleInfoStack _rlestack;
+
+ private RleElement[] _rle1;
+ private RleElement[] _rle2;
+ private int _max_area;
+ private int _min_area;
+
+ public NyARLabeling_Rle(int i_width, int i_height)
+ {
+ this._rlestack = new RleInfoStack(i_width * i_height * 2048 / (320 * 240) + 32);
+ this._rle1 = RleElement.createArray(i_width / 2 + 1);
+ this._rle2 = RleElement.createArray(i_width / 2 + 1);
+ setAreaRange(AR_AREA_MAX, AR_AREA_MIN);
+
+ return;
+ }
+ /**
+ * 対象サイズ
+ * @param i_max
+ * @param i_min
+ */
+ public void setAreaRange(int i_max, int i_min)
+ {
+ this._max_area = i_max;
+ this._min_area = i_min;
+ return;
+ }
+
+ /**
+ * i_bin_bufのbinイメージをREL圧縮する。
+ *
+ * @param i_bin_raster
+ */
+ private int toRel(int[] i_bin_buf, int i_st, int i_len, RleElement[] i_out)
+ {
+ int current = 0;
+ int r = -1;
+ // 行確定開始
+ int x = i_st;
+ int right_edge = i_st + i_len - 1;
+ while (x < right_edge)
+ {
+ // 暗点(0)スキャン
+ if (i_bin_buf[x] != 0)
+ {
+ x++;
+ continue;
+ }
+ // 暗点発見→暗点長を調べる
+ r = (x - i_st);
+ i_out[current].l = r;
+ r++;// 暗点+1
+ x++;
+ while (x < right_edge)
+ {
+ if (i_bin_buf[x] != 0)
+ {
+ // 明点(1)→暗点(0)配列終了>登録
+ i_out[current].r = r;
+ current++;
+ x++;// 次点の確認。
+ r = -1;// 右端の位置を0に。
+ break;
+ }
+ else
+ {
+ // 暗点(0)長追加
+ r++;
+ x++;
+ }
+ }
+ }
+ // 最後の1点だけ判定方法が少し違うの。
+ if (i_bin_buf[x] != 0)
+ {
+ // 明点→rカウント中なら暗点配列終了>登録
+ if (r >= 0)
+ {
+ i_out[current].r = r;
+ current++;
+ }
+ }
+ else
+ {
+ // 暗点→カウント中でなければl1で追加
+ if (r >= 0)
+ {
+ i_out[current].r = (r + 1);
+ }
+ else
+ {
+ // 最後の1点の場合
+ i_out[current].l = (i_len - 1);
+ i_out[current].r = (i_len);
+ }
+ current++;
+ }
+ // 行確定
+ return current;
+ }
+
+ private void addFragment(RleElement i_rel_img, int i_nof, int i_row_index, RleInfoStack o_stack)
+ {
+ int l = i_rel_img.l;
+ int len = i_rel_img.r - l;
+ i_rel_img.fid = i_nof;// REL毎の固有ID
+ RleInfoStack.RleInfo v = o_stack.prePush();
+ v.entry_x = l;
+ v.area = len;
+ v.clip_l = l;
+ v.clip_r = i_rel_img.r - 1;
+ v.clip_t = i_row_index;
+ v.clip_b = i_row_index;
+ v.pos_x = (len * (2 * l + (len - 1))) / 2;
+ v.pos_y = i_row_index * len;
+
+ return;
+ }
+
+ //
+ public int labeling(NyARBinRaster i_bin_raster, int i_top, int i_bottom, RleLabelFragmentInfoStack o_stack)
+ {
+ // リセット処理
+ RleInfoStack rlestack=this._rlestack;
+ rlestack.clear();
+ //
+ RleElement[] rle_prev = this._rle1;
+ RleElement[] rle_current = this._rle2;
+ int len_prev = 0;
+ int len_current = 0;
+ int width = i_bin_raster.getWidth();
+ int[] in_buf = (int[])i_bin_raster.getBufferReader().getBuffer();
+
+ int id_max = 0;
+ int label_count = 0;
+ // 初段登録
+
+ len_prev = toRel(in_buf, i_top, width, rle_prev);
+ for (int i = 0; i < len_prev; i++)
+ {
+ // フラグメントID=フラグメント初期値、POS=Y値、RELインデクス=行
+ addFragment(rle_prev[i], id_max, i_top, rlestack);
+ id_max++;
+ // nofの最大値チェック
+ label_count++;
+ }
+ RleInfoStack.RleInfo[] f_array = rlestack.getArray();
+ // 次段結合
+ for (int y = i_top + 1; y < i_bottom; y++)
+ {
+ // カレント行の読込
+ len_current = toRel(in_buf, y * width, width, rle_current);
+ int index_prev = 0;
+
+ for (int i = 0; i < len_current; i++)
+ {
+ // index_prev,len_prevの位置を調整する
+ int id = -1;
+ // チェックすべきprevがあれば確認
+ while (index_prev < len_prev)
+ {
+ if (rle_current[i].l - rle_prev[index_prev].r > 0)
+ {// 0なら8方位ラベリング
+ // prevがcurの左方にある→次のフラグメントを探索
+ index_prev++;
+ continue;
+ }
+ else if (rle_prev[index_prev].l - rle_current[i].r > 0)
+ {// 0なら8方位ラベリングになる
+ // prevがcur右方にある→独立フラグメント
+ addFragment(rle_current[i], id_max, y, rlestack);
+ id_max++;
+ label_count++;
+ // 次のindexをしらべる
+ goto SCAN_CUR;
+ }
+ id = rle_prev[index_prev].fid;//ルートフラグメントid
+ RleInfoStack.RleInfo id_ptr = f_array[id];
+ //結合対象(初回)->prevのIDをコピーして、ルートフラグメントの情報を更新
+ rle_current[i].fid = id;//フラグメントIDを保存
+ //
+ int l = rle_current[i].l;
+ int r = rle_current[i].r;
+ int len = r - l;
+ //結合先フラグメントの情報を更新する。
+ id_ptr.area += len;
+ //tとentry_xは、結合先のを使うので更新しない。
+ id_ptr.clip_l = l < id_ptr.clip_l ? l : id_ptr.clip_l;
+ id_ptr.clip_r = r > id_ptr.clip_r ? r - 1 : id_ptr.clip_r;
+ id_ptr.clip_b = y;
+ id_ptr.pos_x += (len * (2 * l + (len - 1))) / 2;
+ id_ptr.pos_y += y * len;
+ //多重結合の確認(2個目以降)
+ index_prev++;
+ while (index_prev < len_prev)
+ {
+ if (rle_current[i].l - rle_prev[index_prev].r > 0)
+ {// 0なら8方位ラベリング
+ // prevがcurの左方にある→prevはcurに連結していない。
+ goto SCAN_PREV;
+ }
+ else if (rle_prev[index_prev].l - rle_current[i].r > 0)
+ {// 0なら8方位ラベリングになる
+ // prevがcurの右方にある→prevはcurに連結していない。
+ index_prev--;
+ goto SCAN_CUR;
+ }
+ // prevとcurは連結している→ルートフラグメントの統合
+
+ //結合するルートフラグメントを取得
+ int prev_id = rle_prev[index_prev].fid;
+ RleInfoStack.RleInfo prev_ptr = f_array[prev_id];
+ if (id != prev_id)
+ {
+ label_count--;
+ //prevとcurrentのフラグメントidを書き換える。
+ for (int i2 = index_prev; i2 < len_prev; i2++)
+ {
+ //prevは現在のidから最後まで
+ if (rle_prev[i2].fid == prev_id)
+ {
+ rle_prev[i2].fid = id;
+ }
+ }
+ for (int i2 = 0; i2 < i; i2++)
+ {
+ //currentは0から現在-1まで
+ if (rle_current[i2].fid == prev_id)
+ {
+ rle_current[i2].fid = id;
+ }
+ }
+
+ //現在のルートフラグメントに情報を集約
+ id_ptr.area += prev_ptr.area;
+ id_ptr.pos_x += prev_ptr.pos_x;
+ id_ptr.pos_y += prev_ptr.pos_y;
+ //tとentry_xの決定
+ if (id_ptr.clip_t > prev_ptr.clip_t)
+ {
+ // 現在の方が下にある。
+ id_ptr.clip_t = prev_ptr.clip_t;
+ id_ptr.entry_x = prev_ptr.entry_x;
+ }
+ else if (id_ptr.clip_t < prev_ptr.clip_t)
+ {
+ // 現在の方が上にある。prevにフィードバック
+ }
+ else
+ {
+ // 水平方向で小さい方がエントリポイント。
+ if (id_ptr.entry_x > prev_ptr.entry_x)
+ {
+ id_ptr.entry_x = prev_ptr.entry_x;
+ }
+ else
+ {
+ }
+ }
+ //lの決定
+ if (id_ptr.clip_l > prev_ptr.clip_l)
+ {
+ id_ptr.clip_l = prev_ptr.clip_l;
+ }
+ else
+ {
+ }
+ //rの決定
+ if (id_ptr.clip_r < prev_ptr.clip_r)
+ {
+ id_ptr.clip_r = prev_ptr.clip_r;
+ }
+ else
+ {
+ }
+ //bの決定
+
+ //結合済のルートフラグメントを無効化する。
+ prev_ptr.area = 0;
+ }
+
+
+ index_prev++;
+ }
+ index_prev--;
+ break;
+ SCAN_PREV: ;
+ }
+ // curにidが割り当てられたかを確認
+ // 右端独立フラグメントを追加
+ if (id < 0)
+ {
+ addFragment(rle_current[i], id_max, y, rlestack);
+ id_max++;
+ label_count++;
+ }
+ SCAN_CUR: ;
+ }
+ // prevとrelの交換
+ RleElement[] tmp = rle_prev;
+ rle_prev = rle_current;
+ len_prev = len_current;
+ rle_current = tmp;
+ }
+ //対象のラベルだけ転写
+ o_stack.reserv(label_count);
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo[] o_dest_array=o_stack.getArray();
+ int max=this._max_area;
+ int min=this._min_area;
+ int active_labels=0;
+ for(int i=id_max-1;i>=0;i--){
+ int area=f_array[i].area;
+ if(area<min || area>max){//対象外のエリア0のもminではじく
+ continue;
+ }
+ //
+ RleInfoStack.RleInfo src_info=f_array[i];
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo dest_info=o_dest_array[active_labels];
+ dest_info.area=area;
+ dest_info.clip_b=src_info.clip_b;
+ dest_info.clip_r=src_info.clip_r;
+ dest_info.clip_t=src_info.clip_t;
+ dest_info.clip_l=src_info.clip_l;
+ dest_info.entry_x=src_info.entry_x;
+ dest_info.pos_x=src_info.pos_x/src_info.area;
+ dest_info.pos_y=src_info.pos_y/src_info.area;
+ active_labels++;
+ }
+ //ラベル数を再設定
+ o_stack.pops(label_count-active_labels);
+ //ラベル数を返却
+ return active_labels;
+ }
+ }
+
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/LabelOverlapChecker.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/LabelOverlapChecker.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/LabelOverlapChecker.cs (revision 304)
@@ -0,0 +1,104 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * ラベル同士の重なり(内包関係)を調べるクラスです。
+ * ラベルリストに内包するラベルを蓄積し、それにターゲットのラベルが内包されているか を確認します。
+ */
+ public class LabelOverlapChecker<T> where T : NyARLabelInfo
+ {
+ private T[] _labels;
+ private int _length;
+ /*
+ */
+
+ public LabelOverlapChecker(int i_max_label)
+ {
+ this._labels = new T[i_max_label];
+ }
+
+ /**
+ * チェック対象のラベルを追加する。
+ *
+ * @param i_label_ref
+ */
+ public void push(T i_label_ref)
+ {
+ this._labels[this._length] = i_label_ref;
+ this._length++;
+ }
+
+ /**
+ * 現在リストにあるラベルと重なっているかを返す。
+ *
+ * @param i_label
+ * @return 何れかのラベルの内側にあるならばfalse,独立したラベルである可能性が高ければtrueです.
+ */
+ public bool check(T i_label)
+ {
+ // 重なり処理かな?
+ T[] label_pt = this._labels;
+ int px1 = (int)i_label.pos_x;
+ int py1 = (int)i_label.pos_y;
+ for (int i = this._length - 1; i >= 0; i--)
+ {
+ int px2 = (int)label_pt[i].pos_x;
+ int py2 = (int)label_pt[i].pos_y;
+ int d = (px1 - px2) * (px1 - px2) + (py1 - py2) * (py1 - py2);
+ if (d < label_pt[i].area / 4)
+ {
+ // 対象外
+ return false;
+ }
+ }
+ // 対象
+ return true;
+ }
+ /**
+ * 最大i_max_label個のラベルを蓄積できるようにオブジェクトをリセットする
+ *
+ * @param i_max_label
+ */
+ public void setMaxLabels(int i_max_label)
+ {
+ if (i_max_label > this._labels.Length)
+ {
+ this._labels = new T[i_max_label];
+ }
+ this._length = 0;
+ }
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingLabelStack.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingLabelStack.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingLabelStack.cs (revision 304)
@@ -0,0 +1,48 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARLabelingLabelStack : NyARLabelInfoStack<NyARLabelingLabel>
+ {
+ public NyARLabelingLabelStack(int i_max_array_size)
+ : base(i_max_array_size)
+ {
+ }
+ protected override NyARLabelingLabel createElement()
+ {
+ return new NyARLabelingLabel();
+ }
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabeling_ARToolKit.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabeling_ARToolKit.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabeling_ARToolKit.cs (revision 304)
@@ -0,0 +1,362 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System.Diagnostics;
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ /**
+ * ARToolKit互換のラベリングクラスです。 ARToolKitと同一な評価結果を返します。
+ *
+ */
+ public class NyARLabeling_ARToolKit
+ {
+ private const int WORK_SIZE = 1024 * 32;// #define WORK_SIZE 1024*32
+ private NyARWorkHolder work_holder = new NyARWorkHolder(WORK_SIZE);
+
+ /**
+ * static ARInt16 *labeling2( ARUint8 *image, int thresh,int *label_num, int **area, double **pos, int **clip,int **label_ref, int LorR ) 関数の代替品
+ * ラスタimageをラベリングして、結果を保存します。 Optimize:STEP[1514->1493]
+ *
+ * @param i_raster
+ * @throws NyARException
+ */
+ public int labeling(NyARBinRaster i_raster, NyARLabelingImage o_destination)
+ {
+ int label_img_ptr1, label_pixel;
+ int i, j;
+ int n, k; /* work */
+
+ // サイズチェック
+ NyARIntSize in_size = i_raster.getSize();
+ Debug.Assert(o_destination.getSize().isEqualSize(in_size));
+
+ int lxsize = in_size.w;// lxsize = arUtil_c.arImXsize;
+ int lysize = in_size.h;// lysize = arUtil_c.arImYsize;
+ int[] label_img = (int[])o_destination.getBufferReader().getBuffer();
+
+ // 枠作成はインスタンスを作った直後にやってしまう。
+
+ // ラベリング情報のリセット(ラベリングインデックスを使用)
+ o_destination.reset(true);
+
+ int[] label_idxtbl = o_destination.getIndexArray();
+ int[] raster_buf = (int[])i_raster.getBufferReader().getBuffer();
+
+ int[] work2_pt;
+ int wk_max = 0;
+
+ int pixel_index;
+ int[][] work2 = this.work_holder.work2;
+
+ // [1,1](ptr0)と、[0,1](ptr1)のインデクス値を計算する。
+ for (j = 1; j < lysize - 1; j++)
+ {// for (int j = 1; j < lysize - 1;j++, pnt += poff*2, pnt2 += 2) {
+ pixel_index = j * lxsize + 1;
+ label_img_ptr1 = pixel_index - lxsize;// label_img_pt1 = label_img[j - 1];
+ for (i = 1; i < lxsize - 1; i++, pixel_index++, label_img_ptr1++)
+ {// for(int i = 1; i < lxsize-1;i++, pnt+=poff, pnt2++) {
+ // RGBの合計値が閾値より小さいかな?
+ if (raster_buf[pixel_index] != 0)
+ {
+ label_img[pixel_index] = 0;// label_img_pt0[i] = 0;// *pnt2 = 0;
+ }
+ else
+ {
+ // pnt1 = ShortPointer.wrap(pnt2, -lxsize);//pnt1 =&(pnt2[-lxsize]);
+ if (label_img[label_img_ptr1] > 0)
+ {// if (label_img_pt1[i] > 0) {// if( *pnt1 > 0 ) {
+ label_pixel = label_img[label_img_ptr1];// label_pixel = label_img_pt1[i];// *pnt2 = *pnt1;
+
+ work2_pt = work2[label_pixel - 1];
+ work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
+ work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
+ work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
+ work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
+ }
+ else if (label_img[label_img_ptr1 + 1] > 0)
+ {// } else if (label_img_pt1[i + 1] > 0) {// }else if(*(pnt1+1) > 0 ) {
+ if (label_img[label_img_ptr1 - 1] > 0)
+ {// if (label_img_pt1[i - 1] > 0) {// if( *(pnt1-1) > 0 ) {
+ label_pixel = label_idxtbl[label_img[label_img_ptr1 + 1] - 1];// m = label_idxtbl[label_img_pt1[i + 1] - 1];// m
+ // =work[*(pnt1+1)-1];
+ n = label_idxtbl[label_img[label_img_ptr1 - 1] - 1];// n = label_idxtbl[label_img_pt1[i - 1] - 1];// n =work[*(pnt1-1)-1];
+ if (label_pixel > n)
+ {
+ // wk=IntPointer.wrap(work, 0);//wk = &(work[0]);
+ for (k = 0; k < wk_max; k++)
+ {
+ if (label_idxtbl[k] == label_pixel)
+ {// if( *wk == m )
+ label_idxtbl[k] = n;// *wk = n;
+ }
+ }
+ label_pixel = n;// *pnt2 = n;
+ }
+ else if (label_pixel < n)
+ {
+ // wk=IntPointer.wrap(work,0);//wk = &(work[0]);
+ for (k = 0; k < wk_max; k++)
+ {
+ if (label_idxtbl[k] == n)
+ {// if( *wk == n ){
+ label_idxtbl[k] = label_pixel;// *wk = m;
+ }
+ }
+ }
+ work2_pt = work2[label_pixel - 1];
+ work2_pt[0]++;
+ work2_pt[1] += i;
+ work2_pt[2] += j;
+ work2_pt[6] = j;
+ }
+ else if ((label_img[pixel_index - 1]) > 0)
+ {// } else if ((label_img_pt0[i - 1]) > 0) {// }else if(*(pnt2-1) > 0) {
+ label_pixel = label_idxtbl[label_img[label_img_ptr1 + 1] - 1];// m = label_idxtbl[label_img_pt1[i + 1] - 1];// m =work[*(pnt1+1)-1];
+ n = label_idxtbl[label_img[pixel_index - 1] - 1];// n = label_idxtbl[label_img_pt0[i - 1] - 1];// n =work[*(pnt2-1)-1];
+ if (label_pixel > n)
+ {
+ for (k = 0; k < wk_max; k++)
+ {
+ if (label_idxtbl[k] == label_pixel)
+ {// if( *wk == m ){
+ label_idxtbl[k] = n;// *wk = n;
+ }
+ }
+ label_pixel = n;// *pnt2 = n;
+ }
+ else if (label_pixel < n)
+ {
+ for (k = 0; k < wk_max; k++)
+ {
+ if (label_idxtbl[k] == n)
+ {// if( *wk == n ){
+ label_idxtbl[k] = label_pixel;// *wk = m;
+ }
+ }
+ }
+ work2_pt = work2[label_pixel - 1];
+ work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
+ work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
+ work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
+ }
+ else
+ {
+
+ label_pixel = label_img[label_img_ptr1 + 1];// label_pixel = label_img_pt1[i + 1];// *pnt2 =
+ // *(pnt1+1);
+
+ work2_pt = work2[label_pixel - 1];
+ work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
+ work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
+ work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
+ if (work2_pt[3] > i)
+ {// if(work2[((*pnt2)-1)*7+3] > i ){
+ work2_pt[3] = i;// work2[((*pnt2)-1)*7+3] = i;
+ }
+ work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
+ }
+ }
+ else if ((label_img[label_img_ptr1 - 1]) > 0)
+ {// } else if ((label_img_pt1[i - 1]) > 0) {// }else if(
+ // *(pnt1-1) > 0 ) {
+ label_pixel = label_img[label_img_ptr1 - 1];// label_pixel = label_img_pt1[i - 1];// *pnt2 =
+ // *(pnt1-1);
+
+ work2_pt = work2[label_pixel - 1];
+ work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
+ work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
+ work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
+ if (work2_pt[4] < i)
+ {// if( work2[((*pnt2)-1)*7+4] <i ){
+ work2_pt[4] = i;// work2[((*pnt2)-1)*7+4] = i;
+ }
+ work2_pt[6] = j;// work2[((*pnt2)-1)*7+6] = j;
+ }
+ else if (label_img[pixel_index - 1] > 0)
+ {// } else if (label_img_pt0[i - 1] > 0) {// }else if(*(pnt2-1) > 0) {
+ label_pixel = label_img[pixel_index - 1];// label_pixel = label_img_pt0[i - 1];// *pnt2 =*(pnt2-1);
+
+ work2_pt = work2[label_pixel - 1];
+ work2_pt[0]++;// work2[((*pnt2)-1)*7+0] ++;
+ work2_pt[1] += i;// work2[((*pnt2)-1)*7+1] += i;
+ work2_pt[2] += j;// work2[((*pnt2)-1)*7+2] += j;
+ if (work2_pt[4] < i)
+ {// if( work2[((*pnt2)-1)*7+4] <i ){
+ work2_pt[4] = i;// work2[((*pnt2)-1)*7+4] = i;
+ }
+ }
+ else
+ {
+ // 現在地までの領域を予約
+ this.work_holder.reserv(wk_max);
+ wk_max++;
+ label_idxtbl[wk_max - 1] = wk_max;
+ label_pixel = wk_max;// work[wk_max-1] = *pnt2 = wk_max;
+ work2_pt = work2[wk_max - 1];
+ work2_pt[0] = 1;
+ work2_pt[1] = i;
+ work2_pt[2] = j;
+ work2_pt[3] = i;
+ work2_pt[4] = i;
+ work2_pt[5] = j;
+ work2_pt[6] = j;
+ }
+ label_img[pixel_index] = label_pixel;// label_img_pt0[i] = label_pixel;
+ }
+ }
+
+ }
+ // インデックステーブルとラベル数の計算
+ int wlabel_num = 1;// *label_num = *wlabel_num = j - 1;
+
+ for (i = 0; i < wk_max; i++)
+ {// for(int i = 1; i <= wk_max; i++,wk++) {
+ label_idxtbl[i] = (label_idxtbl[i] == i + 1) ? wlabel_num++ : label_idxtbl[label_idxtbl[i] - 1];// *wk=(*wk==i)?j++:work[(*wk)-1];
+ }
+ wlabel_num -= 1;// *label_num = *wlabel_num = j - 1;
+ if (wlabel_num == 0)
+ {// if( *label_num == 0 ) {
+ // 発見数0
+ o_destination.getLabelStack().clear();
+ return 0;
+ }
+ // ラベル情報の保存等
+ NyARLabelingLabelStack label_list = o_destination.getLabelStack();
+
+ // ラベルバッファを予約
+ label_list.reserv(wlabel_num);
+
+ // エリアと重心、クリップ領域を計算
+ NyARLabelingLabel label_pt;
+ NyARLabelingLabel[] labels = label_list.getArray();
+ for (i = 0; i < wlabel_num; i++)
+ {
+ label_pt = labels[i];
+ label_pt.id = (short)(i + 1);
+ label_pt.area = 0;
+ label_pt.pos_x = label_pt.pos_y = 0;
+ label_pt.clip_l = lxsize;// wclip[i*4+0] = lxsize;
+ label_pt.clip_t = lysize;// wclip[i*4+2] = lysize;
+ label_pt.clip_r = label_pt.clip_b = 0;// wclip[i*4+3] = 0;
+ }
+
+ for (i = 0; i < wk_max; i++)
+ {
+ label_pt = labels[label_idxtbl[i] - 1];
+ work2_pt = work2[i];
+ label_pt.area += work2_pt[0];
+ label_pt.pos_x += work2_pt[1];
+ label_pt.pos_y += work2_pt[2];
+ if (label_pt.clip_l > work2_pt[3])
+ {
+ label_pt.clip_l = work2_pt[3];
+ }
+ if (label_pt.clip_r < work2_pt[4])
+ {
+ label_pt.clip_r = work2_pt[4];
+ }
+ if (label_pt.clip_t > work2_pt[5])
+ {
+ label_pt.clip_t = work2_pt[5];
+ }
+ if (label_pt.clip_b < work2_pt[6])
+ {
+ label_pt.clip_b = work2_pt[6];
+ }
+ }
+
+ for (i = 0; i < wlabel_num; i++)
+ {// for(int i = 0; i < *label_num; i++ ) {
+ label_pt = labels[i];
+ label_pt.pos_x /= label_pt.area;
+ label_pt.pos_y /= label_pt.area;
+ }
+ return wlabel_num;
+ }
+
+ }
+
+ /**
+ * NyARLabeling_O2のworkとwork2を可変長にするためのクラス
+ *
+ *
+ */
+ class NyARWorkHolder
+ {
+ private const int ARRAY_APPEND_STEP = 256;
+
+ public int[][] work2;
+
+ private int allocate_size;
+
+ /**
+ * 最大i_holder_size個の動的割り当てバッファを準備する。
+ *
+ * @param i_holder_size
+ */
+ public NyARWorkHolder(int i_holder_size)
+ {
+ // ポインタだけははじめに確保しておく
+ this.work2 = new int[i_holder_size][];
+ this.allocate_size = 0;
+ }
+
+ /**
+ * i_indexで指定した番号までのバッファを準備する。
+ *
+ * @param i_index
+ */
+ public void reserv(int i_index)
+ {
+ // アロケート済みなら即リターン
+ if (this.allocate_size > i_index)
+ {
+ return;
+ }
+ // 要求されたインデクスは範囲外
+ if (i_index >= this.work2.Length)
+ {
+ throw new NyARException();
+ }
+ // 追加アロケート範囲を計算
+ int range = i_index + ARRAY_APPEND_STEP;
+ if (range >= this.work2.Length)
+ {
+ range = this.work2.Length;
+ }
+ // アロケート
+ for (int i = this.allocate_size; i < range; i++)
+ {
+ this.work2[i] = new int[7];
+ }
+ this.allocate_size = range;
+ }
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingLabel.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingLabel.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingLabel.cs (revision 304)
@@ -0,0 +1,39 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+
+ public class NyARLabelingLabel : NyARLabelInfo
+ {
+ public int id; // ĴÉďÁÓħÉĸËÌăÓĦĎĘ
+
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingImage.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingImage.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/artoolkit/NyARLabelingImage.cs (revision 304)
@@ -0,0 +1,141 @@
+/*
+ * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System.Diagnostics;
+using jp.nyatla.nyartoolkit.cs.utils;
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+
+ /**
+ *
+ */
+ public class NyARLabelingImage : NyARRaster_BasicClass
+ {
+ private const int MAX_LABELS = 1024 * 32;
+ protected int[] _ref_buf;
+ private INyARBufferReader _buffer_reader;
+ protected NyARLabelingLabelStack _label_list;
+ protected int[] _index_table;
+ protected bool _is_index_table_enable;
+ public NyARLabelingImage(int i_width, int i_height)
+ : base(new NyARIntSize(i_width, i_height))
+ {
+ this._ref_buf = new int[i_height*i_width];
+ this._label_list = new NyARLabelingLabelStack(MAX_LABELS);
+ this._index_table = new int[MAX_LABELS];
+ this._is_index_table_enable = false;
+ this._buffer_reader = new NyARBufferReader(this._ref_buf, INyARBufferReader.BUFFERFORMAT_INT2D);
+ //生成時に枠を書きます。
+ drawFrameEdge();
+ return;
+ }
+ public override INyARBufferReader getBufferReader()
+ {
+ return this._buffer_reader;
+ }
+ /**
+ * エッジを書きます。
+ */
+ public void drawFrameEdge()
+ {
+ int w = this._size.w;
+ int h = this._size.h;
+ // NyLabelingImageのイメージ初期化(枠書き)
+ int[] img = (int[])this._ref_buf;
+ int bottom_ptr = (h - 1) * w;
+ for (int i = 0; i < w; i++)
+ {
+ img[i] = 0;
+ img[bottom_ptr + i] = 0;
+ }
+ for (int i = 0; i < h; i++)
+ {
+ img[i * w] = 0;
+ img[(i + 1) * w - 1] = 0;
+ }
+ return;
+ }
+
+
+ /**
+ * ラベリング結果がインデックステーブルを持つ場合、その配列を返します。
+ * 持たない場合、nullを返します。
+ *
+ * 値がnullの時はラベル番号そのものがラスタに格納されていますが、
+ * null以外の時はラスタに格納されているのはインデクス番号です。
+ *
+ * インデクス番号とラベル番号の関係は、以下の式で表されます。
+ * ラベル番号:=value[インデクス番号]
+ *
+ */
+ public int[] getIndexArray()
+ {
+ return this._is_index_table_enable ? this._index_table : null;
+ }
+
+ public NyARLabelingLabelStack getLabelStack()
+ {
+ return this._label_list;
+ }
+ public void reset(bool i_label_index_enable)
+ {
+ Debug.Assert(i_label_index_enable == true);//非ラベルモードは未実装
+ this._label_list.clear();
+ this._is_index_table_enable = i_label_index_enable;
+ return;
+ }
+
+ protected int[] _getContour_xdir = { 0, 1, 1, 1, 0, -1, -1, -1 };
+ protected int[] _getContour_ydir = { -1, -1, 0, 1, 1, 1, 0, -1 };
+ /**
+ * i_labelのラベルの、クリップ領域が上辺に接しているx座標を返します。
+ * @param i_index
+ * @return
+ */
+ public int getTopClipTangentX(NyARLabelingLabel i_label)
+ {
+ int pix;
+ int i_label_id=i_label.id;
+ int[] index_table=this._index_table;
+ int[] limage=this._ref_buf;
+ int limage_ptr=i_label.clip_t*this._size.w;
+ int clip1 = i_label.clip_r;
+ // p1=ShortPointer.wrap(limage,j*xsize+clip.get());//p1 =&(limage[j*xsize+clip[0]]);
+ for (int i = i_label.clip_l; i <= clip1; i++) {// for( i = clip[0]; i <=clip[1]; i++, p1++ ) {
+ pix = limage[limage_ptr+i];
+ if (pix > 0 && index_table[pix-1] == i_label_id){
+ return i;
+ }
+ }
+ //あれ?見つからないよ?
+ throw new NyARException();
+ }
+ }
+}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelInfo.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelInfo.cs (revision 0)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core/labeling/NyARLabelInfo.cs (revision 304)
@@ -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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace jp.nyatla.nyartoolkit.cs.core
+{
+ public class NyARLabelInfo
+ {
+ public int area;
+ public int clip_r;
+ public int clip_l;
+ public int clip_b;
+ public int clip_t;
+ public double pos_x;
+ public double pos_y;
+ }
+}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARCustomSingleDetectMarker.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARCustomSingleDetectMarker.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARCustomSingleDetectMarker.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -66,39 +65,34 @@
protected INyARRasterFilter_RgbToBin _tobin_filter;

private NyARMatchPattDeviationColorData _deviation_data;
- /**
- * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。
- *
- * @param i_param
- * カメラパラメータを指定します。
- * @param i_code
- * 検出するARCodeを指定します。
- * @param i_marker_width
- * ARコードの物理サイズを、ミリメートルで指定します。
- * @param i_filter
- * RGB→BIN変換フィルタを指定します。
- * @throws NyARException
- */
- public NyARCustomSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width, INyARRasterFilter_RgbToBin i_filter)
+ protected NyARCustomSingleDetectMarker()
{
- NyARIntSize scr_size = i_param.getScreenSize();
+ return;
+ }
+ protected void initInstance(
+ INyARColorPatt i_patt_inst,
+ INyARSquareDetector i_sqdetect_inst,
+ INyARTransMat i_transmat_inst,
+ INyARRasterFilter_RgbToBin i_filter,
+ NyARParam i_ref_param,
+ NyARCode i_ref_code,
+ double i_marker_width)
+ {
+ NyARIntSize scr_size=i_ref_param.getScreenSize();
// 解析オブジェクトを作る
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
- this._transmat = new NyARTransMat(i_param);
+ this._square_detect = i_sqdetect_inst;
+ this._transmat = i_transmat_inst;
+ this._tobin_filter=i_filter;
// 比較コードを保存
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._patt = i_patt_inst;
//取得パターンの差分データ器を作成
- this._deviation_data = new NyARMatchPattDeviationColorData(i_code.getWidth(), i_code.getHeight());
+ this._deviation_data=new NyARMatchPattDeviationColorData(i_ref_code.getWidth(),i_ref_code.getHeight());
//i_code用の評価器を作成
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);
-
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code);
//2値画像バッファを作る
- this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
- this._tobin_filter = i_filter;
+ this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);
return;
}

Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARDetectMarker.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARDetectMarker.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARDetectMarker.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.core;
@@ -105,31 +104,46 @@
* i_codeのマーカーサイズをミリメートルで指定した配列を指定します。 先頭からi_number_of_code個の要素には、有効な値を指定する必要があります。
* @param i_number_of_code
* i_codeに含まれる、ARCodeの数を指定します。
+ * @param i_input_raster_type
+ * 入力ラスタのピクセルタイプを指定します。この値は、INyARBufferReaderインタフェイスのgetBufferTypeの戻り値を指定します。
* @throws NyARException
*/
- public NyARDetectMarker(NyARParam i_param, NyARCode[] i_code, double[] i_marker_width, int i_number_of_code)
+ public NyARDetectMarker(NyARParam i_param, NyARCode[] i_code, double[] i_marker_width, int i_number_of_code, int i_input_raster_type)
{
- NyARIntSize scr_size = i_param.getScreenSize();
+ initInstance(i_param, i_code, i_marker_width, i_number_of_code, i_input_raster_type);
+ return;
+ }
+ protected void initInstance(
+ NyARParam i_ref_param,
+ NyARCode[] i_ref_code,
+ double[] i_marker_width,
+ int i_number_of_code,
+ int i_input_raster_type)
+ {
+
+ NyARIntSize scr_size = i_ref_param.getScreenSize();
// 解析オブジェクトを作る
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);
- this._transmat = new NyARTransMat(i_param);

+ this._transmat = new NyARTransMat(i_ref_param);
//各コード用の比較器を作る。
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]);
+ int cw = i_ref_code[0].getWidth();
+ int ch = i_ref_code[0].getHeight();
+ this._match_patt[0] = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code[0]);
for (int i = 1; i < i_number_of_code; i++)
{
//解像度チェック
- if (cw != i_code[i].getWidth() || ch != i_code[i].getHeight())
+ if (cw != i_ref_code[i].getWidth() || ch != i_ref_code[i].getHeight())
{
throw new NyARException();
}
- this._match_patt[i] = new NyARMatchPatt_Color_WITHOUT_PCA(i_code[i]);
+ this._match_patt[i] = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code[i]);
}
- // 評価パターンのホルダを作る
- this._patt = new NyARColorPatt_O3(cw, ch);
+ //NyARToolkitプロファイル
+ this._patt = new NyARColorPatt_Perspective_O2(cw, ch, 4, 25);
+ this._square_detect = new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(), i_ref_param.getScreenSize());
+ this._tobin_filter = new NyARRasterFilter_ARToolkitThreshold(100, i_input_raster_type);
+
//実サイズ保存
this._marker_width = i_marker_width;
//差分データインスタンスの作成
@@ -141,7 +155,7 @@

private NyARBinRaster _bin_raster;

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

/**
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARSingleDetectMarker.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARSingleDetectMarker.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/detector/NyARSingleDetectMarker.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using jp.nyatla.nyartoolkit.cs.core;
@@ -34,44 +33,103 @@

namespace jp.nyatla.nyartoolkit.cs.detector
{
-/**
- * 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。
- *
- */
-public class NyARSingleDetectMarker : NyARCustomSingleDetectMarker
-{
- /**
- * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。
- *
- * @param i_param
- * カメラパラメータを指定します。
- * @param i_code
- * 検出するARCodeを指定します。
- * @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;
- }
+ /**
+ * 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。
+ *
+ */

+ public class NyARSingleDetectMarker : NyARCustomSingleDetectMarker
+ {
+ public const int PF_ARTOOLKIT_COMPATIBLE=1;
+ public const int PF_NYARTOOLKIT=2;
+ public const int PF_NYARTOOLKIT_ARTOOLKIT_FITTING=100;
+ public const int PF_TEST2 = 201;

- /**
- * i_imageにマーカー検出処理を実行し、結果を記録します。
- *
- * @param i_raster
- * マーカーを検出するイメージを指定します。イメージサイズは、カメラパラメータ
- * と一致していなければなりません。
- * @return マーカーが検出できたかを真偽値で返します。
- * @throws NyARException
- */
- public bool detectMarkerLite(INyARRgbRaster i_raster,int i_threshold)
- {
- ((NyARRasterFilter_ARToolkitThreshold)this._tobin_filter).setThreshold(i_threshold);
- return base.detectMarkerLite(i_raster);
- }
-}
+ /**
+ * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。
+ *
+ * @param i_param
+ * カメラパラメータを指定します。
+ * @param i_code
+ * 検出するARCodeを指定します。
+ * @param i_marker_width
+ * ARコードの物理サイズを、ミリメートルで指定します。
+ * @param i_input_raster_type
+ * 入力ラスタのピクセルタイプを指定します。この値は、INyARBufferReaderインタフェイスのgetBufferTypeの戻り値を指定します。
+ * @throws NyARException
+ */
+ public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width, int i_input_raster_type, int i_profile_id)
+ {
+ initInstance(i_param, i_code, i_marker_width, i_input_raster_type, i_profile_id);
+ return;
+ }
+ public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width, int i_input_raster_type)
+ {
+ initInstance(i_param, i_code, i_marker_width, i_input_raster_type, PF_NYARTOOLKIT);
+ return;
+ }
+ /**
+ * コンストラクタから呼び出す関数です。
+ * @param i_ref_param
+ * @param i_ref_code
+ * @param i_marker_width
+ * @param i_input_raster_type
+ * @param i_profile_id
+ * @throws NyARException
+ */
+ protected void initInstance(
+ NyARParam i_ref_param,
+ NyARCode i_ref_code,
+ double i_marker_width,
+ int i_input_raster_type,
+ int i_profile_id)
+ {
+ NyARRasterFilter_ARToolkitThreshold th = new NyARRasterFilter_ARToolkitThreshold(100, i_input_raster_type);
+ INyARColorPatt patt_inst;
+ INyARSquareDetector sqdetect_inst;
+ INyARTransMat transmat_inst;

+ switch (i_profile_id)
+ {
+ case PF_ARTOOLKIT_COMPATIBLE:
+ patt_inst = new NyARColorPatt_O3(i_ref_code.getWidth(), i_ref_code.getHeight());
+ sqdetect_inst = new NyARSquareDetector_ARToolKit(i_ref_param.getDistortionFactor(), i_ref_param.getScreenSize());
+ transmat_inst = new NyARTransMat_ARToolKit(i_ref_param);
+ break;
+ case PF_NYARTOOLKIT_ARTOOLKIT_FITTING:
+ patt_inst = new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(), 4, 25);
+ sqdetect_inst = new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(), i_ref_param.getScreenSize());
+ transmat_inst = new NyARTransMat_ARToolKit(i_ref_param);
+ break;
+ case PF_NYARTOOLKIT:
+ patt_inst = new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(), 4, 25);
+ sqdetect_inst = new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(), i_ref_param.getScreenSize());
+ transmat_inst = new NyARTransMat(i_ref_param);
+ break;
+ default:
+ throw new NyARException();
+ }
+ base.initInstance(patt_inst, sqdetect_inst, transmat_inst,th, i_ref_param, i_ref_code, i_marker_width);
+ return;
+ }
+
+
+
+
+ /**
+ * i_imageにマーカー検出処理を実行し、結果を記録します。
+ *
+ * @param i_raster
+ * マーカーを検出するイメージを指定します。イメージサイズは、カメラパラメータ
+ * と一致していなければなりません。
+ * @return マーカーが検出できたかを真偽値で返します。
+ * @throws NyARException
+ */
+ public bool detectMarkerLite(INyARRgbRaster i_raster, int i_threshold)
+ {
+ ((NyARRasterFilter_ARToolkitThreshold)this._tobin_filter).setThreshold(i_threshold);
+ return base.detectMarkerLite(i_raster);
+ }
+ }
+
}
\ No newline at end of file
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Point2d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Point2d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Point2d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Point3d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Point3d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Point3d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARFixedFloat24Matrix33.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARFixedFloat24Matrix33.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARFixedFloat24Matrix33.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARFixedFloat16Matrix33.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARFixedFloat16Matrix33.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARFixedFloat16Matrix33.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARI64Matrix22.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARI64Matrix22.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARI64Matrix22.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARI64Matrix33.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARI64Matrix33.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/matrix/NyARI64Matrix33.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARFixedFloat16Point2d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARFixedFloat16Point2d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARFixedFloat16Point2d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARFixedFloat16Point3d.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARFixedFloat16Point3d.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARFixedFloat16Point3d.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Linear.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Linear.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/types/NyARI64Linear.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkit
+ * PROJECT: NyARToolkitCS(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
@@ -61,7 +54,7 @@
}
public int createHistgramImpl(INyARBufferReader i_reader, NyARIntSize i_size, int[] o_histgram)
{
- Debug.Assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));
+ Debug.Assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));

int sum = 0;
int[] input = (int[])i_reader.getBuffer();
@@ -183,6 +176,69 @@
return sum;
}
}
+ /**
+ * WORD1D_R5G6B5_16LEのヒストグラム計算クラス
+ *
+ */
+ class CreateHistgramImpl_WORD1D_R5G6B5_16LE : ICreateHistgramImpl
+ {
+ private int _v_interval;
+ public CreateHistgramImpl_WORD1D_R5G6B5_16LE(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_WORD1D_R5G6B5_16LE));
+ short[] input = (short[])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;
+ int x, v;
+ for (x = pix_count - 1; x >= pix_mod_part; x--)
+ {
+ v =(int)input[pt];
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ pt++;
+ }
+ //タイリング
+ for (; x >= 0; x -= 8)
+ {
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ v =(int)input[pt];pt++;
+ v = (((v & 0xf800) >> 8) + ((v & 0x07e0) >> 3) + ((v & 0x001f) << 3))/3;
+ o_histgram[v]++;
+ }
+ }
+ return sum;
+ }
+ }
private int _persentage;
private int _threshold;
private ICreateHistgramImpl _histgram;
@@ -202,12 +258,15 @@
case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
this._histgram = new CreateHistgramImpl_BYTE1D_RGB_24(i_vertical_interval);
break;
- case INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8:
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_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;
+ case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:
+ this._histgram = new CreateHistgramImpl_WORD1D_R5G6B5_16LE(i_vertical_interval);
+ break;
default:
throw new NyARException();
}
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/INyARRasterThresholdAnalyzer.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/INyARRasterThresholdAnalyzer.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/core2/rasteranalyzer/threshold/INyARRasterThresholdAnalyzer.cs (revision 304)
@@ -1,32 +1,25 @@
/*
- * PROJECT: NyARToolkit
+ * PROJECT: NyARToolkitCS(Extension)
* --------------------------------------------------------------------------------
- * 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 NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo Iizuka
*
- * 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/NyARException.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/NyARException.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCS/cs/NyARException.cs (revision 304)
@@ -7,26 +7,25 @@
* HITLab, University of Washington, Seattle
* http://www.hitl.washington.edu/artoolkit/
*
- * The NyARToolkit is Java version ARToolkit class library.
- * Copyright (C)2008 R.Iizuka
+ * The NyARToolkitCS is C# edition ARToolKit class library.
+ * Copyright (C)2008-2009 Ryo 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 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 3 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For further information please contact.
* http://nyatla.jp/nyatoolkit/
- * <airmail(at)ebony.plala.or.jp>
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
*
*/
using System;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/DsBGRX32Raster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/DsBGRX32Raster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/DsBGRX32Raster.cs (revision 304)
@@ -68,6 +68,14 @@
}
return;
}
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ NyARException.notImplement();
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
}

private INyARRgbPixelReader _rgb_reader;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/DsRGB565Raster.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/DsRGB565Raster.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/DsRGB565Raster.cs (revision 304)
@@ -74,6 +74,14 @@
i_rgb[i * 3 + 2] = (int)((pixcel & 0x001f) << 3);//B
}
}
+ public void setPixel(int i_x, int i_y, int[] i_rgb)
+ {
+ NyARException.notImplement();
+ }
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb)
+ {
+ NyARException.notImplement();
+ }
}
private INyARRgbPixelReader _rgb_reader;
private INyARBufferReader _buffer_reader;
Index: D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/NyARD3dUtil.cs
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/NyARD3dUtil.cs (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/forFW2.0/NyARToolkitCSUtils/NyAR/NyARD3dUtil.cs (revision 304)
@@ -110,18 +110,18 @@
o_d3d_projection.M12 = (float)(q[1, 0] * trans[0][0] + q[1, 1] * trans[1][0] + q[1, 2] * trans[2][0]);
o_d3d_projection.M13 = (float)(q[2, 0] * trans[0][0] + q[2, 1] * trans[1][0] + q[2, 2] * trans[2][0]);
o_d3d_projection.M14 = (float)(q[3, 0] * trans[0][0] + q[3, 1] * trans[1][0] + q[3, 2] * trans[2][0]);
- o_d3d_projection.M21 = (float)(q[0, 1] * trans[0][1] + q[0, 1] * trans[1][1] + q[0, 2] * trans[2][1]);
- o_d3d_projection.M22 = (float)(q[1, 1] * trans[0][1] + q[1, 1] * trans[1][1] + q[1, 2] * trans[2][1]);
- o_d3d_projection.M23 = (float)(q[2, 1] * trans[0][1] + q[2, 1] * trans[1][1] + q[2, 2] * trans[2][1]);
- 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.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]);
- o_d3d_projection.M44 = (float)(q[3, 3] * trans[0][3] + q[3, 1] * trans[1][3] + q[3, 2] * trans[2][3] + q[3, 3]);
+ o_d3d_projection.M21 = (float)(q[0, 0] * trans[0][1] + q[0, 1] * trans[1][1] + q[0, 2] * trans[2][1]);
+ o_d3d_projection.M22 = (float)(q[1, 0] * trans[0][1] + q[1, 1] * trans[1][1] + q[1, 2] * trans[2][1]);
+ o_d3d_projection.M23 = (float)(q[2, 0] * trans[0][1] + q[2, 1] * trans[1][1] + q[2, 2] * trans[2][1]);
+ o_d3d_projection.M24 = (float)(q[3, 0] * trans[0][1] + q[3, 1] * trans[1][1] + q[3, 2] * trans[2][1]);
+ o_d3d_projection.M31 = (float)(q[0, 0] * trans[0][2] + q[0, 1] * trans[1][2] + q[0, 2] * trans[2][2]);
+ o_d3d_projection.M32 = (float)(q[1, 0] * trans[0][2] + q[1, 1] * trans[1][2] + q[1, 2] * trans[2][2]);
+ o_d3d_projection.M33 = (float)(q[2, 0] * trans[0][2] + q[2, 1] * trans[1][2] + q[2, 2] * trans[2][2]);
+ o_d3d_projection.M34 = (float)(q[3, 0] * trans[0][2] + q[3, 1] * trans[1][2] + q[3, 2] * trans[2][2]);
+ o_d3d_projection.M41 = (float)(q[0, 0] * 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, 0] * 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, 0] * trans[0][3] + q[2, 1] * trans[1][3] + q[2, 2] * trans[2][3] + q[2, 3]);
+ o_d3d_projection.M44 = (float)(q[3, 0] * trans[0][3] + q[3, 1] * trans[1][3] + q[3, 2] * trans[2][3] + q[3, 3]);
return;
}
public void toD3dMatrix(NyARTransMatResult i_ny_result,ref Matrix o_result)
Index: D:/project.sorceforge/NyARToolkitCS/trunk/readme.ja.txt
===================================================================
--- D:/project.sorceforge/NyARToolkitCS/trunk/readme.ja.txt (revision 252)
+++ D:/project.sorceforge/NyARToolkitCS/trunk/readme.ja.txt (revision 304)
@@ -1,10 +1,11 @@
ARToolkit C# class library NyARToolkitCS.
Copyright (C)2008-2009 R.Iizuka

-version 2.3.0
+version 2.4.0

-http://nyatla.jp/
+http://nyatla.jp/nyartoolkit/
airmail(at)ebony.plala.or.jp
+wm(at)nyatla.jp
--------------------------------------------------


@@ -13,7 +14,7 @@
NyARToolkitCSは、純粋なC#のみで実装したNyARToolkit互換の
クラスライブラリです。

-ARToolkit 2.72.1及び、NyARToolkit version 2.3.0
+ARToolkit 2.72.1及び、NyARToolkit version 2.4.0
をベースにしています。

※NyARToolkitのcore2パッケージの一部は実装されていません。
@@ -26,7 +27,7 @@
http://www.hitl.washington.edu/artoolkit/

NyARToolkitはARToolkit 2.72.1をベースに開発された、ARToolKit互換の
-演算結果を持つ、Javaクラスライブラリです。
+機能を持つ、Javaクラスライブラリです。
詳しくはこちらをご覧下さい。
http://nyatla.jp/nyartoolkit/

@@ -198,7 +199,17 @@


・ライセンス
+
+NyARToolkitCS本体は、商用ライセンスとGPLv3以降のデュアルライセンスを採用しています。
+(Version/2.4.0より、GPLv3ライセンスになりました。)
extlib以下のものは、各モジュールのライセンスに従ってください。
-NyARToolkitは、特にソースに表記の無い限り、GPLライセンスです。
-詳しくはLICENCE.txtをみてください。

+ -GPL
+ GPLについては、LICENCE.txtをお読みください。
+
+ -商用ライセンス
+ 商用ライセンスについては、ARToolWorks社に管理を委託しております。
+ http://www.artoolworks.com/Home.html
+
+ 日本国内での販売については、下記にお問い合わせ下さい。
+ http://www.msoft.co.jp/pressrelease/press090928-1.html