Permalink
Browse files

auto import from //depot/cupcake/@135843

  • Loading branch information...
1 parent dceec76 commit 7f81d9b6fa7f2ec161b682622db577a28c90b49f The Android Open Source Project committed Mar 4, 2009
Showing with 19,844 additions and 0 deletions.
  1. +136 −0 Android.mk
  2. +32 −0 Embedded/common/conf/b_BasicEm/LibConfig.h
  3. BIN Embedded/common/data/APIEm/Modules/RFFprec_501.bmd
  4. BIN Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd
  5. BIN Embedded/common/data/APIEm/Modules/RFFstd_501.bmd
  6. +499 −0 Embedded/common/src/b_APIEm/BFFaceFinder.c
  7. +256 −0 Embedded/common/src/b_APIEm/BFFaceFinder.h
  8. +238 −0 Embedded/common/src/b_APIEm/DCR.c
  9. +150 −0 Embedded/common/src/b_APIEm/DCR.h
  10. +264 −0 Embedded/common/src/b_APIEm/FaceFinder.c
  11. +161 −0 Embedded/common/src/b_APIEm/FaceFinder.h
  12. +282 −0 Embedded/common/src/b_APIEm/FaceFinderRef.c
  13. +123 −0 Embedded/common/src/b_APIEm/FaceFinderRef.h
  14. +316 −0 Embedded/common/src/b_APIEm/Functions.c
  15. +92 −0 Embedded/common/src/b_APIEm/Functions.h
  16. +84 −0 Embedded/common/src/b_APIEm/Types.h
  17. +136 −0 Embedded/common/src/b_BasicEm/APh.c
  18. +95 −0 Embedded/common/src/b_BasicEm/APh.h
  19. +232 −0 Embedded/common/src/b_BasicEm/APhArr.c
  20. +125 −0 Embedded/common/src/b_BasicEm/APhArr.h
  21. +173 −0 Embedded/common/src/b_BasicEm/Basic.h
  22. +164 −0 Embedded/common/src/b_BasicEm/Complex.c
  23. +102 −0 Embedded/common/src/b_BasicEm/Complex.h
  24. +233 −0 Embedded/common/src/b_BasicEm/ComplexArr.c
  25. +122 −0 Embedded/common/src/b_BasicEm/ComplexArr.h
  26. +80 −0 Embedded/common/src/b_BasicEm/Config.h
  27. +410 −0 Embedded/common/src/b_BasicEm/Context.c
  28. +229 −0 Embedded/common/src/b_BasicEm/Context.h
  29. +301 −0 Embedded/common/src/b_BasicEm/DynMemManager.c
  30. +124 −0 Embedded/common/src/b_BasicEm/DynMemManager.h
  31. +274 −0 Embedded/common/src/b_BasicEm/Functions.c
  32. +111 −0 Embedded/common/src/b_BasicEm/Functions.h
  33. +287 −0 Embedded/common/src/b_BasicEm/Int16Arr.c
  34. +139 −0 Embedded/common/src/b_BasicEm/Int16Arr.h
  35. +246 −0 Embedded/common/src/b_BasicEm/Int32Arr.c
  36. +126 −0 Embedded/common/src/b_BasicEm/Int32Arr.h
  37. +252 −0 Embedded/common/src/b_BasicEm/Int8Arr.c
  38. +126 −0 Embedded/common/src/b_BasicEm/Int8Arr.h
  39. +1,282 −0 Embedded/common/src/b_BasicEm/Math.c
  40. +202 −0 Embedded/common/src/b_BasicEm/Math.h
  41. +349 −0 Embedded/common/src/b_BasicEm/MathSSE2.c
  42. +415 −0 Embedded/common/src/b_BasicEm/MemSeg.c
  43. +168 −0 Embedded/common/src/b_BasicEm/MemSeg.h
  44. +435 −0 Embedded/common/src/b_BasicEm/MemTbl.c
  45. +139 −0 Embedded/common/src/b_BasicEm/MemTbl.h
  46. +207 −0 Embedded/common/src/b_BasicEm/Memory.c
  47. +66 −0 Embedded/common/src/b_BasicEm/Memory.h
  48. +332 −0 Embedded/common/src/b_BasicEm/Phase.c
  49. +137 −0 Embedded/common/src/b_BasicEm/Phase.h
  50. +286 −0 Embedded/common/src/b_BasicEm/String.c
  51. +73 −0 Embedded/common/src/b_BasicEm/String.h
  52. +262 −0 Embedded/common/src/b_BasicEm/UInt16Arr.c
  53. +129 −0 Embedded/common/src/b_BasicEm/UInt16Arr.h
  54. +246 −0 Embedded/common/src/b_BasicEm/UInt32Arr.c
  55. +125 −0 Embedded/common/src/b_BasicEm/UInt32Arr.h
  56. +251 −0 Embedded/common/src/b_BasicEm/UInt8Arr.c
  57. +125 −0 Embedded/common/src/b_BasicEm/UInt8Arr.h
  58. +153 −0 Embedded/common/src/b_BitFeatureEm/BitParam.c
  59. +96 −0 Embedded/common/src/b_BitFeatureEm/BitParam.h
  60. +339 −0 Embedded/common/src/b_BitFeatureEm/Feature.c
  61. +150 −0 Embedded/common/src/b_BitFeatureEm/Feature.h
  62. +58 −0 Embedded/common/src/b_BitFeatureEm/Functions.c
  63. +53 −0 Embedded/common/src/b_BitFeatureEm/Functions.h
  64. +260 −0 Embedded/common/src/b_BitFeatureEm/I04Dns2x2Ftr.c
  65. +112 −0 Embedded/common/src/b_BitFeatureEm/I04Dns2x2Ftr.h
  66. +289 −0 Embedded/common/src/b_BitFeatureEm/I04Dns2x4Ftr.c
  67. +112 −0 Embedded/common/src/b_BitFeatureEm/I04Dns2x4Ftr.h
  68. +282 −0 Embedded/common/src/b_BitFeatureEm/I04Tld2x4Ftr.c
  69. +112 −0 Embedded/common/src/b_BitFeatureEm/I04Tld2x4Ftr.h
  70. +268 −0 Embedded/common/src/b_BitFeatureEm/L01Dns2x4Ftr.c
  71. +108 −0 Embedded/common/src/b_BitFeatureEm/L01Dns2x4Ftr.h
  72. +219 −0 Embedded/common/src/b_BitFeatureEm/L01Tld1x1Ftr.c
  73. +108 −0 Embedded/common/src/b_BitFeatureEm/L01Tld1x1Ftr.h
  74. +275 −0 Embedded/common/src/b_BitFeatureEm/L01Tld2x4Ftr.c
  75. +108 −0 Embedded/common/src/b_BitFeatureEm/L01Tld2x4Ftr.h
  76. +241 −0 Embedded/common/src/b_BitFeatureEm/L04Dns2x2Ftr.c
  77. +111 −0 Embedded/common/src/b_BitFeatureEm/L04Dns2x2Ftr.h
  78. +273 −0 Embedded/common/src/b_BitFeatureEm/L04Dns2x4Ftr.c
  79. +108 −0 Embedded/common/src/b_BitFeatureEm/L04Dns2x4Ftr.h
  80. +293 −0 Embedded/common/src/b_BitFeatureEm/L04Dns3x3Ftr.c
  81. +108 −0 Embedded/common/src/b_BitFeatureEm/L04Dns3x3Ftr.h
  82. +278 −0 Embedded/common/src/b_BitFeatureEm/L04Tld2x4Ftr.c
  83. +109 −0 Embedded/common/src/b_BitFeatureEm/L04Tld2x4Ftr.h
  84. +299 −0 Embedded/common/src/b_BitFeatureEm/L06Dns3x3Ftr.c
  85. +108 −0 Embedded/common/src/b_BitFeatureEm/L06Dns3x3Ftr.h
  86. +315 −0 Embedded/common/src/b_BitFeatureEm/L06Dns4x4Ftr.c
  87. +108 −0 Embedded/common/src/b_BitFeatureEm/L06Dns4x4Ftr.h
  88. +324 −0 Embedded/common/src/b_BitFeatureEm/L06DnsNx4x4Ftr.c
  89. +111 −0 Embedded/common/src/b_BitFeatureEm/L06DnsNx4x4Ftr.h
  90. +745 −0 Embedded/common/src/b_BitFeatureEm/LocalScanDetector.c
  91. +207 −0 Embedded/common/src/b_BitFeatureEm/LocalScanDetector.h
  92. +807 −0 Embedded/common/src/b_BitFeatureEm/LocalScanner.c
  93. +248 −0 Embedded/common/src/b_BitFeatureEm/LocalScanner.h
Sorry, we could not display the entire diff because it was too big.
View
136 Android.mk
@@ -0,0 +1,136 @@
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ FaceDetector_jni.cpp \
+ Embedded/common/src/b_APIEm/DCR.c \
+ Embedded/common/src/b_APIEm/BFFaceFinder.c \
+ Embedded/common/src/b_APIEm/FaceFinder.c \
+ Embedded/common/src/b_APIEm/FaceFinderRef.c \
+ Embedded/common/src/b_APIEm/Functions.c \
+ Embedded/common/src/b_BasicEm/APh.c \
+ Embedded/common/src/b_BasicEm/APhArr.c \
+ Embedded/common/src/b_BasicEm/Complex.c \
+ Embedded/common/src/b_BasicEm/ComplexArr.c \
+ Embedded/common/src/b_BasicEm/Context.c \
+ Embedded/common/src/b_BasicEm/DynMemManager.c \
+ Embedded/common/src/b_BasicEm/Functions.c \
+ Embedded/common/src/b_BasicEm/Int16Arr.c \
+ Embedded/common/src/b_BasicEm/Int32Arr.c \
+ Embedded/common/src/b_BasicEm/Int8Arr.c \
+ Embedded/common/src/b_BasicEm/Math.c.arm \
+ Embedded/common/src/b_BasicEm/MemSeg.c \
+ Embedded/common/src/b_BasicEm/MemTbl.c \
+ Embedded/common/src/b_BasicEm/Memory.c \
+ Embedded/common/src/b_BasicEm/Phase.c \
+ Embedded/common/src/b_BasicEm/String.c \
+ Embedded/common/src/b_BasicEm/UInt16Arr.c \
+ Embedded/common/src/b_BasicEm/UInt32Arr.c \
+ Embedded/common/src/b_BasicEm/UInt8Arr.c \
+ Embedded/common/src/b_BitFeatureEm/BitParam.c \
+ Embedded/common/src/b_BitFeatureEm/Feature.c \
+ Embedded/common/src/b_BitFeatureEm/Functions.c \
+ Embedded/common/src/b_BitFeatureEm/I04Dns2x2Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/I04Dns2x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/I04Tld2x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L01Dns2x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L01Tld1x1Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L01Tld2x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L04Dns2x2Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L04Dns2x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L04Dns3x3Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L04Tld2x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L06Dns3x3Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L06Dns4x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/L06DnsNx4x4Ftr.c \
+ Embedded/common/src/b_BitFeatureEm/LocalScanDetector.c \
+ Embedded/common/src/b_BitFeatureEm/LocalScanner.c \
+ Embedded/common/src/b_BitFeatureEm/ScanDetector.c \
+ Embedded/common/src/b_BitFeatureEm/Scanner.c \
+ Embedded/common/src/b_BitFeatureEm/Sequence.c \
+ Embedded/common/src/b_ImageEm/APhImage.c \
+ Embedded/common/src/b_ImageEm/ComplexImage.c \
+ Embedded/common/src/b_ImageEm/Flt16Image.c \
+ Embedded/common/src/b_ImageEm/Functions.c \
+ Embedded/common/src/b_ImageEm/HistoEq.c \
+ Embedded/common/src/b_ImageEm/UInt16ByteImage.c \
+ Embedded/common/src/b_ImageEm/UInt16BytePyrImage.c \
+ Embedded/common/src/b_ImageEm/UInt8Image.c \
+ Embedded/common/src/b_ImageEm/UInt32Image.c \
+ Embedded/common/src/b_ImageEm/UInt8PyramidalImage.c \
+ Embedded/common/src/b_TensorEm/Alt.c \
+ Embedded/common/src/b_TensorEm/Cluster2D.c \
+ Embedded/common/src/b_TensorEm/Cluster3D.c \
+ Embedded/common/src/b_TensorEm/CompactAlt.c \
+ Embedded/common/src/b_TensorEm/CompactMat.c \
+ Embedded/common/src/b_TensorEm/Flt16Alt2D.c \
+ Embedded/common/src/b_TensorEm/Flt16Alt3D.c \
+ Embedded/common/src/b_TensorEm/Flt16Mat2D.c \
+ Embedded/common/src/b_TensorEm/Flt16Mat3D.c \
+ Embedded/common/src/b_TensorEm/Flt16Vec.c \
+ Embedded/common/src/b_TensorEm/Flt16Vec2D.c \
+ Embedded/common/src/b_TensorEm/Flt16Vec3D.c \
+ Embedded/common/src/b_TensorEm/Functions.c \
+ Embedded/common/src/b_TensorEm/IdCluster2D.c \
+ Embedded/common/src/b_TensorEm/Int16Mat2D.c \
+ Embedded/common/src/b_TensorEm/Int16Rect.c \
+ Embedded/common/src/b_TensorEm/Int16Vec2D.c \
+ Embedded/common/src/b_TensorEm/Int16Vec3D.c \
+ Embedded/common/src/b_TensorEm/Int32Mat.c \
+ Embedded/common/src/b_TensorEm/MapSequence.c \
+ Embedded/common/src/b_TensorEm/Mat.c \
+ Embedded/common/src/b_TensorEm/Normalizer.c \
+ Embedded/common/src/b_TensorEm/RBFMap2D.c \
+ Embedded/common/src/b_TensorEm/SubVecMap.c \
+ Embedded/common/src/b_TensorEm/Uint32Rect.c \
+ Embedded/common/src/b_TensorEm/VectorMap.c \
+ FaceRecEm/common/src/b_FDSDK/DCR.c \
+ FaceRecEm/common/src/b_FDSDK/FaceFinder.c \
+ FaceRecEm/common/src/b_FDSDK/SDK.c
+##
+
+LOCAL_CFLAGS += -Depl_LINUX
+
+LOCAL_C_INCLUDES += \
+ external/neven/FaceRecEm/common/src/b_FDSDK \
+ $(JNI_H_INCLUDE) \
+ $(call include-path-for, corecg graphics) \
+ $(LOCAL_PATH)/FaceRecEm/common/src \
+ $(LOCAL_PATH)/Embedded/common/conf \
+ $(LOCAL_PATH)/Embedded/common/src \
+ $(LOCAL_PATH)/unix/src
+
+LOCAL_SHARED_LIBRARIES := \
+ libandroid_runtime \
+ libnativehelper \
+ libutils \
+ libcorecg \
+ libsgl \
+ libcutils
+
+LOCAL_MODULE:= libFFTEm
+
+ALL_PREBUILT += $(TARGET_OUT)/usr/share/bmd/RFFspeed_501.bmd
+$(TARGET_OUT)/usr/share/bmd/RFFspeed_501.bmd : $(LOCAL_PATH)/Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd | $(ACP)
+ $(transform-prebuilt-to-target)
+
+ALL_PREBUILT += $(TARGET_OUT)/usr/share/bmd/RFFstd_501.bmd
+$(TARGET_OUT)/usr/share/bmd/RFFstd_501.bmd : $(LOCAL_PATH)/Embedded/common/data/APIEm/Modules/RFFstd_501.bmd | $(ACP)
+ $(transform-prebuilt-to-target)
+
+
+include $(BUILD_SHARED_LIBRARY)
View
32 Embedded/common/conf/b_BasicEm/LibConfig.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef bbs_LIB_CONFIG_H
+#define bbs_LIB_CONFIG_H
+
+/* ----------------- library tags --------------------------- */
+
+/* ----------------- other tags ----------------------------- */
+
+#define bbs_MINIMIZE_FRQ_IMG
+
+#define bbs_USE_FRQ_IMG_SYMMETRY
+
+/*#define bbs_COMPACT_MESSAGE_HANDLING*/
+
+#define bbs_ENABLE_BIT_FEATURE
+
+#endif /* bbs_LIB_CONFIG_H */
View
BIN Embedded/common/data/APIEm/Modules/RFFprec_501.bmd
Binary file not shown.
View
BIN Embedded/common/data/APIEm/Modules/RFFspeed_501.bmd
Binary file not shown.
View
BIN Embedded/common/data/APIEm/Modules/RFFstd_501.bmd
Binary file not shown.
View
499 Embedded/common/src/b_APIEm/BFFaceFinder.c
@@ -0,0 +1,499 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_APIEm/BFFaceFinder.h"
+#include "b_APIEm/Functions.h"
+#include "b_APIEm/DCR.h"
+#include "b_BasicEm/Functions.h"
+#include "b_BasicEm/Math.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_init( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA )
+{
+ bpi_FaceFinder_init( cpA, &ptrA->baseE );
+ ptrA->baseE.typeE = ( uint32 )bpi_FF_BF_FACE_FINDER;
+ ptrA->baseE.vpSetParamsE = bpi_BFFaceFinder_setParams;
+ ptrA->baseE.vpSetRangeE = bpi_BFFaceFinder_setRange;
+ ptrA->baseE.vpProcessE = bpi_BFFaceFinder_processDcr;
+ ptrA->baseE.vpPutDcrE = bpi_BFFaceFinder_putDcr;
+ ptrA->baseE.vpGetDcrE = bpi_BFFaceFinder_getDcr;
+
+ ptrA->detectedFacesE = 0;
+ ptrA->availableFacesE = 0;
+ ptrA->faceDataBufferE = NULL;
+ bbf_ScanDetector_init( cpA, &ptrA->detectorE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_exit( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA )
+{
+ ptrA->detectedFacesE = 0;
+ ptrA->availableFacesE = 0;
+ ptrA->faceDataBufferE = NULL;
+ bbf_ScanDetector_exit( cpA, &ptrA->detectorE );
+
+ bpi_FaceFinder_exit( cpA, &ptrA->baseE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_copy( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ const struct bpi_BFFaceFinder* srcPtrA )
+{
+ bpi_FaceFinder_copy( cpA, &ptrA->baseE, &srcPtrA->baseE );
+ bbf_ScanDetector_copy( cpA, &ptrA->detectorE, &srcPtrA->detectorE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bpi_BFFaceFinder_equal( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ const struct bpi_BFFaceFinder* srcPtrA )
+{
+ if( !bpi_FaceFinder_equal( cpA, &ptrA->baseE, &srcPtrA->baseE ) ) return FALSE;
+ if( !bbf_ScanDetector_equal( cpA, &ptrA->detectorE, &srcPtrA->detectorE ) ) return FALSE;
+ return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_getMinEyeDistance( const struct bpi_BFFaceFinder* ptrA )
+{
+ return ( ( ptrA->detectorE.refDistanceE >> 8 ) * ( ptrA->detectorE.minScaleE >> 12 ) ) >> 16;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_getMaxEyeDistance( const struct bpi_BFFaceFinder* ptrA )
+{
+ return ( ( ptrA->detectorE.refDistanceE >> 8 ) * ( ptrA->detectorE.maxScaleE >> 12 ) ) >> 16;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setMinEyeDistance( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ uint32 distA )
+{
+ ptrA->detectorE.minScaleE = ( ( distA << 16 ) / ( ptrA->detectorE.refDistanceE >> 8 ) ) << 12;
+ if( ptrA->detectorE.minScaleE < 0x100000 /* 1.0 */ ) ptrA->detectorE.minScaleE = 0x100000;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setMaxEyeDistance( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ uint32 distA )
+{
+ if( distA > 0x0FFFF )
+ {
+ ptrA->detectorE.maxScaleE = 0; /* unlimited */
+ }
+ else
+ {
+ ptrA->detectorE.maxScaleE = ( ( distA << 16 ) / ( ptrA->detectorE.refDistanceE >> 8 ) ) << 12;
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_memSize( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder *ptrA )
+{
+ uint32 memSizeL = 0;
+ memSizeL += bbs_SIZEOF16( uint32 );
+ memSizeL += bbs_SIZEOF16( uint32 ); /* version */
+ memSizeL += bpi_FaceFinder_memSize( cpA, &ptrA->baseE );
+ memSizeL += bbf_ScanDetector_memSize( cpA, &ptrA->detectorE );
+ memSizeL += bbs_SIZEOF16( uint16 ); /* csa */
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_memWrite( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ uint16* memPtrA )
+{
+ uint32 memSizeL = bpi_BFFaceFinder_memSize( cpA, ptrA );
+ memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+ memPtrA += bbs_memWriteUInt32( bpi_BF_FACE_FINDER_VERSION, memPtrA );
+ memPtrA += bpi_FaceFinder_memWrite( cpA, &ptrA->baseE, memPtrA );
+ memPtrA += bbf_ScanDetector_memWrite( cpA, &ptrA->detectorE, memPtrA );
+ memPtrA += bpi_memWriteCsa16( memPtrA, memSizeL, 0xFFFF );
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_memRead( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ const uint16* memPtrA,
+ struct bbs_MemTbl* mtpA )
+{
+ uint32 memSizeL, versionL;
+ if( bbs_Context_error( cpA ) ) return 0;
+ memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+ memPtrA += bbs_memReadVersion32( cpA, &versionL, bpi_BF_FACE_FINDER_VERSION, memPtrA );
+ memPtrA += bpi_FaceFinder_memRead( cpA, &ptrA->baseE, memPtrA );
+ if( bbs_Context_error( cpA ) ) return 0;
+
+ memPtrA += bbf_ScanDetector_memRead( cpA, &ptrA->detectorE, memPtrA, mtpA );
+ if( bbs_Context_error( cpA ) ) return 0;
+ memPtrA += bpi_memReadCsa16( memPtrA );
+
+/* if( memSizeL != bpi_BFFaceFinder_memSize( cpA, ptrA ) )
+ {
+ bbs_ERROR0( "uint32 bpi_BFFaceFinder_memRead( .... ):\n"
+ "Module file is corrupt or incorrect. Please check if the face finder module is still supported." );
+ return 0;
+ }
+*/
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_BFFaceFinder_process( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ void* imagePtrA,
+ uint32 imageWidthA,
+ uint32 imageHeightA,
+ const struct bts_Int16Rect* roiPtrA,
+ struct bts_Int16Vec2D* offsPtrA,
+ struct bts_IdCluster2D* idClusterPtrA )
+{
+ int32 xL = 0; /* 16.16 */
+ int32 yL = 0; /* 16.16 */
+ uint32 scaleL = 0;
+ int32 actL = 0;
+ int32* outArrL;
+
+ struct bts_Flt16Alt2D altL;
+ struct bts_Flt16Vec2D centerL;
+
+ struct bpi_BFFaceFinder* ptrL = ( struct bpi_BFFaceFinder* )ptrA;
+
+ /* reset multi face imformation so they are not accidentally used */
+ ptrL->detectedFacesE = 0;
+ ptrL->availableFacesE = 0;
+ ptrL->faceDataBufferE = NULL;
+
+ bbf_ScanDetector_process( cpA, ( struct bbf_ScanDetector* )&ptrA->detectorE, imagePtrA, imageWidthA, imageHeightA, roiPtrA, &outArrL );
+
+ xL = outArrL[ 0 ]; /* 16.16 */
+ yL = outArrL[ 1 ]; /* 16.16 */
+ scaleL = outArrL[ 2 ]; /* 12.20 */
+ actL = outArrL[ 3 ]; /* 4.28 */
+
+ if( bbs_Context_error( cpA ) ) return 0;
+
+ offsPtrA->xE = xL >> 16;
+ offsPtrA->yE = yL >> 16;
+ xL -= ( ( int32 )offsPtrA->xE << 16 );
+ yL -= ( ( int32 )offsPtrA->yE << 16 );
+
+ centerL = bts_Flt16Vec2D_create32( 0, 0, 0 );
+ altL = bts_Flt16Alt2D_createScale( scaleL, 20, &centerL );
+ altL.vecE = bts_Flt16Vec2D_create32( xL, yL, 16 );
+
+ /* compute cluster */
+ {
+ uint32 eyeDistL = ( ( ptrA->detectorE.refDistanceE >> 16 ) * scaleL ) >> 20;
+ uint32 logEyeDistL = bbs_intLog2( eyeDistL );
+ int32 bbpL = 11 - logEyeDistL;
+ bbpL = bbpL < 0 ? 0 : bbpL;
+ bbpL = bbpL > 6 ? 6 : bbpL;
+ bts_IdCluster2D_copyTransform( cpA, idClusterPtrA, &ptrA->detectorE.refClusterE, altL, bbpL );
+ }
+
+
+ return ( actL + 0x10000000 ) >> 5; /*output range 0...1 in 8.24*/
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_multiProcess( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ void* imagePtrA,
+ uint32 imageWidthA,
+ uint32 imageHeightA,
+ const struct bts_Int16Rect* roiPtrA )
+{
+ struct bpi_BFFaceFinder* ptrL = ( struct bpi_BFFaceFinder* )ptrA;
+ ptrL->detectedFacesE = bbf_ScanDetector_process( cpA, ( struct bbf_ScanDetector* )&ptrA->detectorE, imagePtrA, imageWidthA, imageHeightA, roiPtrA, &ptrL->faceDataBufferE );
+ ptrL->availableFacesE = ptrA->detectedFacesE > 0 ? ptrA->detectedFacesE : 1;
+ if( bbs_Context_error( cpA ) ) return 0;
+ return ptrL->detectedFacesE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_BFFaceFinder_getFace( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ uint32 indexA,
+ struct bts_Int16Vec2D* offsPtrA,
+ struct bts_IdCluster2D* idClusterPtrA )
+{
+ bbs_DEF_fNameL( "bpi_BFFaceFinder_getFace" )
+ int32 xL = 0; /* 16.16 */
+ int32 yL = 0; /* 16.16 */
+ uint32 scaleL = 0;
+ int32 actL = 0;
+ struct bts_Flt16Alt2D altL;
+ struct bts_Flt16Vec2D centerL;
+
+ if( bbs_Context_error( cpA ) ) return 0;
+
+ if( ptrA->availableFacesE == 0 || ptrA->faceDataBufferE == NULL )
+ {
+ bbs_ERROR1( "%s:\nNo faces are availabe. This function was called before the face finder could detect multiple faces in an image", fNameL );
+ return 0;
+ }
+
+ if( indexA >= ptrA->availableFacesE )
+ {
+ bbs_ERROR1( "%s:\nface index exceeds number of available faces", fNameL );
+ return 0;
+ }
+
+ xL = ptrA->faceDataBufferE[ indexA * 4 + 0 ]; /* 16.16 */
+ yL = ptrA->faceDataBufferE[ indexA * 4 + 1 ]; /* 16.16 */
+ scaleL = ptrA->faceDataBufferE[ indexA * 4 + 2 ]; /* 12.20 */
+ actL = ptrA->faceDataBufferE[ indexA * 4 + 3 ]; /* 4.28 */
+
+ offsPtrA->xE = xL >> 16;
+ offsPtrA->yE = yL >> 16;
+
+ xL -= ( ( int32 )offsPtrA->xE << 16 );
+ yL -= ( ( int32 )offsPtrA->yE << 16 );
+
+ centerL = bts_Flt16Vec2D_create32( 0, 0, 0 );
+ altL = bts_Flt16Alt2D_createScale( scaleL, 20, &centerL );
+ altL.vecE = bts_Flt16Vec2D_create32( xL, yL, 16 );
+
+ /* compute cluster */
+ {
+ uint32 eyeDistL = ( ( ptrA->detectorE.refDistanceE >> 16 ) * scaleL ) >> 20;
+ uint32 logEyeDistL = bbs_intLog2( eyeDistL );
+ int32 bbpL = 11 - logEyeDistL;
+ bbpL = bbpL < 0 ? 0 : bbpL;
+ bbpL = bbpL > 6 ? 6 : bbpL;
+ bts_IdCluster2D_copyTransform( cpA, idClusterPtrA, &ptrA->detectorE.refClusterE, altL, bbpL );
+ }
+
+ return ( actL + 0x10000000 ) >> 5; /*output range 0...1 in 8.24*/
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_getFaceDCR( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA )
+{
+ int32 confL = bpi_BFFaceFinder_getFace( cpA, ptrA, indexA, &dcrPtrA->offsE, &dcrPtrA->mainClusterE );
+ bts_IdCluster2D_copy( cpA, &dcrPtrA->sdkClusterE, &dcrPtrA->mainClusterE );
+ dcrPtrA->confidenceE = confL;
+ dcrPtrA->approvedE = confL > ( ( int32 )1 << 23 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setMaxImageSize( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA )
+{
+ ptrA->detectorE.maxImageWidthE = maxImageWidthA;
+ ptrA->detectorE.maxImageHeightE = maxImageHeightA;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setParams( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA )
+{
+ bbs_DEF_fNameL( "bpi_BFFaceFinder_setParams" );
+
+ if( bbs_Context_error( cpA ) ) return;
+
+ if( ptrA->typeE != bpi_FF_BF_FACE_FINDER )
+ {
+ bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+ return;
+ }
+ bpi_BFFaceFinder_setMaxImageSize( cpA, ( struct bpi_BFFaceFinder* )ptrA, maxImageWidthA, maxImageHeightA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_setRange( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ uint32 minEyeDistanceA,
+ uint32 maxEyeDistanceA )
+{
+ bbs_DEF_fNameL( "bpi_BFFaceFinder_setParams" );
+
+ if( bbs_Context_error( cpA ) ) return;
+
+ if( ptrA->typeE != bpi_FF_BF_FACE_FINDER )
+ {
+ bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+ return;
+ }
+ bpi_BFFaceFinder_setMinEyeDistance( cpA, ( struct bpi_BFFaceFinder* )ptrA, minEyeDistanceA );
+ bpi_BFFaceFinder_setMaxEyeDistance( cpA, ( struct bpi_BFFaceFinder* )ptrA, maxEyeDistanceA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_BFFaceFinder_processDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ struct bpi_DCR* dcrPtrA )
+{
+ bbs_DEF_fNameL( "bpi_BFFaceFinder_processDcr" );
+
+ if( bbs_Context_error( cpA ) ) return 0;
+
+ if( ptrA->typeE != bpi_FF_BF_FACE_FINDER )
+ {
+ bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+ return 0;
+ }
+
+ return bpi_BFFaceFinder_process( cpA,
+ ( const struct bpi_BFFaceFinder* )ptrA,
+ dcrPtrA->imageDataPtrE,
+ dcrPtrA->imageWidthE,
+ dcrPtrA->imageHeightE,
+ &dcrPtrA->roiRectE,
+ &dcrPtrA->offsE,
+ &dcrPtrA->mainClusterE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_BFFaceFinder_putDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ struct bpi_DCR* dcrPtrA )
+{
+ bbs_DEF_fNameL( "bpi_BFFaceFinder_putDcr" );
+
+ if( bbs_Context_error( cpA ) ) return 0;
+
+ if( ptrA->typeE != bpi_FF_BF_FACE_FINDER )
+ {
+ bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+ return 0;
+ }
+
+ return bpi_BFFaceFinder_multiProcess( cpA,
+ ( const struct bpi_BFFaceFinder* )ptrA,
+ dcrPtrA->imageDataPtrE,
+ dcrPtrA->imageWidthE,
+ dcrPtrA->imageHeightE,
+ &dcrPtrA->roiRectE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_BFFaceFinder_getDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA )
+{
+ bbs_DEF_fNameL( "bpi_BFFaceFinder_getDcr" );
+
+ if( bbs_Context_error( cpA ) ) return;
+
+ if( ptrA->typeE != bpi_FF_BF_FACE_FINDER )
+ {
+ bbs_ERROR1( "%s:\nObject type mismatch", fNameL );
+ return;
+ }
+
+ bpi_BFFaceFinder_getFaceDCR( cpA, ( const struct bpi_BFFaceFinder* )ptrA, indexA, dcrPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
View
256 Embedded/common/src/b_APIEm/BFFaceFinder.h
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef bpi_BF_FACE_FINDER_EM_H
+#define bpi_BF_FACE_FINDER_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_APIEm/FaceFinder.h"
+#include "b_BitFeatureEm/ScanDetector.h"
+
+/* ---- related objects --------------------------------------------------- */
+
+struct bpi_DCR;
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* data format version number */
+#define bpi_BF_FACE_FINDER_VERSION 100
+
+/* ---- object definition -------------------------------------------------- */
+
+/** Face Finder using ractangle features */
+struct bpi_BFFaceFinder
+{
+ /* ---- private data --------------------------------------------------- */
+
+ /** base object */
+ struct bpi_FaceFinder baseE;
+
+ /* number of detected faces in last call of multiProcess in face data buffer */
+ uint32 detectedFacesE;
+
+ /* number of available faces in last call of multiProcess in face data buffer */
+ uint32 availableFacesE;
+
+ /* pointer to face data buffer */
+ int32* faceDataBufferE;
+
+ /* ---- public data ---------------------------------------------------- */
+
+ /* detector */
+ struct bbf_ScanDetector detectorE;
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes module */
+void bpi_BFFaceFinder_init( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA );
+
+/** destroys module */
+void bpi_BFFaceFinder_exit( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copies module */
+void bpi_BFFaceFinder_copy( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ const struct bpi_BFFaceFinder* srcPtrA );
+
+/** determines equality of parameters */
+flag bpi_BFFaceFinder_equal( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ const struct bpi_BFFaceFinder* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/** minimum eye distance (pixel) */
+uint32 bpi_BFFaceFinder_getMinEyeDistance( const struct bpi_BFFaceFinder* ptrA );
+
+/** maximum eye distance (pixel) */
+uint32 bpi_BFFaceFinder_getMaxEyeDistance( const struct bpi_BFFaceFinder* ptrA );
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** minimum eye distance (pixel) */
+void bpi_BFFaceFinder_setMinEyeDistance( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ uint32 distA );
+
+/** maximum eye distance (pixel) */
+void bpi_BFFaceFinder_setMaxEyeDistance( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ uint32 distA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** size object needs when written to memory */
+uint32 bpi_BFFaceFinder_memSize( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA );
+
+/** writes object to memory; returns number of 16-bit words written */
+uint32 bpi_BFFaceFinder_memWrite( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ uint16* memPtrA );
+
+/** reads object from memory; returns number of 16-bit words read
+ * Note: Before executing this function the maximum image dimensions must be specified
+ * through function bpi_BFFaceFinder_setMaxImageSize. This is to ensure proper allocation
+ * of internal memory. Otherwise this function will cause an exception.
+ */
+uint32 bpi_BFFaceFinder_memRead( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ const uint16* memPtrA,
+ struct bbs_MemTbl* mtpA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** processes image for single face detection;
+ * returns confidence ( 8.24 )
+ * fills external id cluster with node positions and ids
+ *
+ * If roiPtrA is NULL, the whole image is considered for processsing
+ * otherwise *roiPtrA specifies a section of the original image to which
+ * processing is limited. All coordinates refer to that section and must
+ * eventually be adjusted externally.
+ * The roi rectangle must not include pixels outside of the original image
+ * (checked -> error). The rectangle may be of uneven width.
+ *
+ * offsPtrA points to an offset vector (whole pixels) that is to be added to
+ * cluster coordinates in order to obtain image coordinates
+ *
+ */
+int32 bpi_BFFaceFinder_process( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ void* imagePtrA,
+ uint32 imageWidthA,
+ uint32 imageHeightA,
+ const struct bts_Int16Rect* roiPtrA,
+ struct bts_Int16Vec2D* offsPtrA,
+ struct bts_IdCluster2D* idClusterPtrA );
+
+/** Processes integral image for multiple face detection;
+ * returns number of faces detected
+ * return pointer to faceBuffer (intermediate data format)
+ * call getFace() to retrieve face information from buffer.
+ * *faceDataBufferPtrA is set to the address of an internal buffer that is valid until the next image processing
+ *
+ * Positions are sorted by confidence (highest confidence first)
+ *
+ * When this function returns 0 (no face detected) faceDataBuffer
+ * still contains one valid entry retrievable by getFace() that
+ * represents the most likely position. The confidence is then below
+ * or equal 0.5.
+ *
+ * If roiPtrA is NULL, the whole image is considered for processsing
+ * otherwise *roiPtrA specifies a section of the original image to which
+ * processing is limited. All coordinates refer to that section and must
+ * eventually be adjusted externally.
+ * The roi rectangle must not include pixels outside of the original image
+ * (checked -> error). The rectangle may be of uneven width.
+ */
+uint32 bpi_BFFaceFinder_multiProcess( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ void* imagePtrA,
+ uint32 imageWidthA,
+ uint32 imageHeightA,
+ const struct bts_Int16Rect* roiPtrA );
+
+/** Extracts a single face from a face buffer that was previously filled with face data by function
+ * multiProcess().
+ * returns confidence ( 8.24 )
+ * Fills external id cluster with node positions and ids
+ *
+ * offsPtrA points to an offset vector (whole pixels) that is to be added to
+ * cluster coordinates in order to obtain image coordinates
+ */
+uint32 bpi_BFFaceFinder_getFace( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ uint32 indexA,
+ struct bts_Int16Vec2D* offsPtrA,
+ struct bts_IdCluster2D* idClusterPtrA );
+
+/** Extracts a single face from a face buffer that was previously filled with face data by function
+ * multiProcess().
+ * returns confidence ( 8.24 )
+ * provides
+ * - id cluster with node positions and ids
+ * - confidence
+ */
+void bpi_BFFaceFinder_getFaceDCR( struct bbs_Context* cpA,
+ const struct bpi_BFFaceFinder* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA );
+
+/** this function must be executed before calling _memRead */
+void bpi_BFFaceFinder_setMaxImageSize( struct bbs_Context* cpA,
+ struct bpi_BFFaceFinder* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA );
+
+/** initializes some parameters prior to reading
+ * Overload of vpSetParams
+ * wraps function setMaxImageSize
+ */
+void bpi_BFFaceFinder_setParams( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA );
+
+/** sets detection range
+ * Overload of vpSetParams
+ */
+void bpi_BFFaceFinder_setRange( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ uint32 minEyeDistanceA,
+ uint32 maxEyeDistanceA );
+
+/** Single face processing function; returns confidence (8.24)
+ * Overload of vpProcess
+ * wraps function process
+ */
+int32 bpi_BFFaceFinder_processDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ struct bpi_DCR* dcrPtrA );
+
+/** Multiple face processing function; returns number of faces detected
+ * Overload of vpPutDcr
+ * wraps function multiProcess
+ */
+int32 bpi_BFFaceFinder_putDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ struct bpi_DCR* dcrPtrA );
+
+/** Retrieves indexed face from face finder after calling PutDCR
+ * Overload of vpGetDcr
+ * wraps function getFaceDCR
+ */
+void bpi_BFFaceFinder_getDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA );
+
+#endif /* bpi_BF_FACE_FINDER_EM_H */
View
238 Embedded/common/src/b_APIEm/DCR.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_APIEm/DCR.h"
+#include "b_BasicEm/Functions.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_init( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA )
+{
+ ptrA->maxImageWidthE = 0;
+ ptrA->maxImageHeightE = 0;
+ ptrA->imageDataPtrE = NULL;
+ ptrA->imageWidthE = 0;
+ ptrA->imageHeightE = 0;
+ bts_Int16Vec2D_init( &ptrA->offsE );
+ bts_IdCluster2D_init( cpA, &ptrA->mainClusterE );
+ bts_IdCluster2D_init( cpA, &ptrA->sdkClusterE );
+ ptrA->confidenceE = 0;
+ ptrA->approvedE = FALSE;
+ ptrA->idE = 0;
+ ptrA->roiRectE = bts_Int16Rect_create( 0, 0, 0, 0 );
+ bbs_UInt16Arr_init( cpA, &ptrA->cueDataE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_exit( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA )
+{
+ ptrA->maxImageWidthE = 0;
+ ptrA->maxImageHeightE = 0;
+ ptrA->imageDataPtrE = NULL;
+ ptrA->imageWidthE = 0;
+ ptrA->imageHeightE = 0;
+ bts_Int16Vec2D_exit( &ptrA->offsE );
+ bts_IdCluster2D_exit( cpA, &ptrA->mainClusterE );
+ bts_IdCluster2D_exit( cpA, &ptrA->sdkClusterE );
+ ptrA->confidenceE = 0;
+ ptrA->approvedE = FALSE;
+ ptrA->idE = 0;
+ bbs_UInt16Arr_exit( cpA, &ptrA->cueDataE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_create( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA,
+ uint32 imageWidthA,
+ uint32 imageHeightA,
+ uint32 cueSizeA,
+ struct bbs_MemTbl* mtpA )
+{
+ struct bbs_MemTbl memTblL = *mtpA;
+ struct bbs_MemSeg* espL =
+ bbs_MemTbl_fastestSegPtr( cpA, &memTblL,
+ bpi_DCR_MAX_CLUSTER_SIZE * bbs_SIZEOF16( struct bts_Int16Vec2D ) );
+ if( bbs_Context_error( cpA ) ) return;
+
+ bts_IdCluster2D_create( cpA, &ptrA->mainClusterE, bpi_DCR_MAX_CLUSTER_SIZE, espL );
+ bts_IdCluster2D_size( cpA, &ptrA->mainClusterE, 0 );
+ if( bbs_Context_error( cpA ) ) return;
+ bts_IdCluster2D_create( cpA, &ptrA->sdkClusterE, bpi_DCR_MAX_SDK_CLUSTER_SIZE, espL );
+ bts_IdCluster2D_size( cpA, &ptrA->sdkClusterE, 0 );
+ if( bbs_Context_error( cpA ) ) return;
+ if( bbs_Context_error( cpA ) ) return;
+ bbs_UInt16Arr_create( cpA, &ptrA->cueDataE, cueSizeA, espL );
+ bbs_UInt16Arr_size( cpA, &ptrA->cueDataE, 0 );
+
+ ptrA->maxImageWidthE = imageWidthA;
+ ptrA->maxImageHeightE = imageHeightA;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_assignGrayByteImage( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA,
+ const void* bufferPtrA,
+ uint32 widthA,
+ uint32 heightA )
+{
+ bbs_DEF_fNameL( "void bpi_DCR_assignGrayByteImage( struct bbs_Context* cpA, struct bpi_DCR* ptrA, const void* bufferPtrA, uint32 widthA, uint32 heightA )" )
+
+ if( widthA > ptrA->maxImageWidthE || heightA > ptrA->maxImageHeightE )
+ {
+ bbs_ERROR5( "%s:\nSize of assigned image (%ix%i) exceeds maximum size defined at DCR initialization (%ix%i).",
+ fNameL,
+ widthA, heightA,
+ ptrA->maxImageWidthE, ptrA->maxImageHeightE );
+ return;
+ }
+
+ if( ( widthA & 1 ) != 0 )
+ {
+ bbs_ERROR1( "%s:\nWidth of image must be even.\n", fNameL );
+ return;
+ }
+
+ ptrA->imageDataPtrE = ( void* )bufferPtrA;
+ ptrA->imageWidthE = widthA;
+ ptrA->imageHeightE = heightA;
+
+ /* reset some data */
+ ptrA->roiRectE = bts_Int16Rect_create( 0, 0, widthA, heightA );
+ bts_IdCluster2D_size( cpA, &ptrA->mainClusterE, 0 );
+ bts_IdCluster2D_size( cpA, &ptrA->sdkClusterE, 0 );
+ bbs_UInt16Arr_size( cpA, &ptrA->cueDataE, 0 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_DCR_assignGrayByteImageROI( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA,
+ const void* bufferPtrA,
+ uint32 widthA,
+ uint32 heightA,
+ const struct bts_Int16Rect* pRectA )
+{
+ bbs_DEF_fNameL( "void bpi_DCR_assignGrayByteImageROI( struct bpi_DCR* ptrA, const void* bufferPtrA, uint32 widthA, uint32 heightA )" )
+
+ if( widthA > ptrA->maxImageWidthE || heightA > ptrA->maxImageHeightE )
+ {
+ bbs_ERROR5( "%s:\nSize of assigned image (%ix%i) exceeds maximum size defined at DCR initialization (%ix%i).",
+ fNameL,
+ widthA, heightA,
+ ptrA->maxImageWidthE, ptrA->maxImageHeightE );
+ return;
+ }
+
+ if( ( widthA & 1 ) != 0 )
+ {
+ bbs_ERROR1( "%s:\nWidth of image must be even.\n",
+ fNameL );
+ return;
+ }
+
+ if( pRectA->x2E < pRectA->x1E || pRectA->y2E < pRectA->y1E ||
+ pRectA->x1E < 0 || pRectA->y1E < 0 ||
+ pRectA->x2E > ( int32 )widthA || pRectA->y2E > ( int32 )heightA )
+ {
+ bbs_ERROR1( "%s:\nInvalid ROI rectangle.\n", fNameL );
+ return;
+ }
+
+ ptrA->imageDataPtrE = ( void* )bufferPtrA;
+ ptrA->imageWidthE = widthA;
+ ptrA->imageHeightE = heightA;
+
+ /* reset some data */
+ ptrA->roiRectE = *pRectA;
+ bts_IdCluster2D_size( cpA, &ptrA->mainClusterE, 0 );
+ bts_IdCluster2D_size( cpA, &ptrA->sdkClusterE, 0 );
+ bbs_UInt16Arr_size( cpA, &ptrA->cueDataE, 0 );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_DCR_confidence( struct bbs_Context* cpA,
+ const struct bpi_DCR* ptrA )
+{
+ return ptrA->confidenceE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
View
150 Embedded/common/src/b_APIEm/DCR.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef bpi_DCR_EM_H
+#define bpi_DCR_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/MemTbl.h"
+#include "b_ImageEm/UInt16ByteImage.h"
+#include "b_ImageEm/UInt32Image.h"
+#include "b_TensorEm/IdCluster2D.h"
+#include "b_TensorEm/RBFMap2D.h"
+#include "b_BitFeatureEm/Scanner.h"
+
+
+/* ---- related objects --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/** maximum size of dcr cluster */
+#define bpi_DCR_MAX_CLUSTER_SIZE 60
+
+/** maximum size of dcr sdk cluster */
+#define bpi_DCR_MAX_SDK_CLUSTER_SIZE 24
+
+/* ---- object definition -------------------------------------------------- */
+
+/** data carrier */
+struct bpi_DCR
+{
+ /* ---- temporary data ------------------------------------------------- */
+
+ /* ---- private data --------------------------------------------------- */
+
+ /* ---- public data ---------------------------------------------------- */
+
+ /** maximum allowed image width */
+ uint32 maxImageWidthE;
+
+ /** maximum allowed image height */
+ uint32 maxImageHeightE;
+
+ /** pointer to original image data */
+ void* imageDataPtrE;
+
+ /** width of original image */
+ uint32 imageWidthE;
+
+ /** height of original image */
+ uint32 imageHeightE;
+
+ /** offset refering to main and sdk clusters */
+ struct bts_Int16Vec2D offsE;
+
+ /** main cluster */
+ struct bts_IdCluster2D mainClusterE;
+
+ /** output cluster accessible by sdk users */
+ struct bts_IdCluster2D sdkClusterE;
+
+ /** confidence value ( 8.24 ) */
+ int32 confidenceE;
+
+ /** approval flag */
+ flag approvedE;
+
+ /** (image) id value */
+ int32 idE;
+
+ /** region of interest */
+ struct bts_Int16Rect roiRectE;
+
+ /** cue data */
+ struct bbs_UInt16Arr cueDataE;
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes data carrier */
+void bpi_DCR_init( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA );
+
+/** destroys data carrier */
+void bpi_DCR_exit( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/** create a data carrier */
+void bpi_DCR_create( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA,
+ uint32 imageWidthA,
+ uint32 imageHeightA,
+ uint32 cueSizeA,
+ struct bbs_MemTbl* mtpA );
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** references external byte gray image through memory block referenced by bufferPtrA to be used as input image */
+void bpi_DCR_assignGrayByteImage( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA,
+ const void* bufferPtrA,
+ uint32 widthA,
+ uint32 heightA );
+
+/** assigns external byte gray image as input image and region of interest.
+ *
+ * bufferPtrA: pointer to memory block of imput image
+ * pRectA: rectangle describing region of interest
+ */
+void bpi_DCR_assignGrayByteImageROI( struct bbs_Context* cpA,
+ struct bpi_DCR* ptrA,
+ const void* bufferPtrA,
+ uint32 widthA,
+ uint32 heightA,
+ const struct bts_Int16Rect* pRectA );
+
+/** returns confidence 8.24 fixed format */
+int32 bpi_DCR_confidence( struct bbs_Context* cpA,
+ const struct bpi_DCR* ptrA );
+
+#endif /* bpi_DCR_EM_H */
View
264 Embedded/common/src/b_APIEm/FaceFinder.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_APIEm/FaceFinder.h"
+#include "b_APIEm/BFFaceFinder.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinder_init( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA )
+{
+ ptrA->typeE = 0;
+ ptrA->vpSetParamsE = NULL;
+ ptrA->vpSetRangeE = NULL;
+ ptrA->vpProcessE = NULL;
+ ptrA->vpPutDcrE = NULL;
+ ptrA->vpGetDcrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinder_exit( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA )
+{
+ ptrA->typeE = 0;
+ ptrA->vpSetParamsE = NULL;
+ ptrA->vpSetRangeE = NULL;
+ ptrA->vpProcessE = NULL;
+ ptrA->vpPutDcrE = NULL;
+ ptrA->vpGetDcrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinder_copy( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ const struct bpi_FaceFinder* srcPtrA )
+{
+ ptrA->typeE = srcPtrA->typeE;
+ ptrA->vpSetParamsE = srcPtrA->vpSetParamsE;
+ ptrA->vpSetRangeE = srcPtrA->vpSetRangeE;
+ ptrA->vpProcessE = srcPtrA->vpProcessE;
+ ptrA->vpPutDcrE = srcPtrA->vpPutDcrE;
+ ptrA->vpGetDcrE = srcPtrA->vpGetDcrE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bpi_FaceFinder_equal( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ const struct bpi_FaceFinder* srcPtrA )
+{
+
+ if( ptrA->typeE != srcPtrA->typeE ) return FALSE;
+ if( ptrA->vpSetParamsE != srcPtrA->vpSetParamsE ) return FALSE;
+ if( ptrA->vpSetRangeE != srcPtrA->vpSetRangeE ) return FALSE;
+ if( ptrA->vpProcessE != srcPtrA->vpProcessE ) return FALSE;
+ if( ptrA->vpPutDcrE != srcPtrA->vpPutDcrE ) return FALSE;
+ if( ptrA->vpGetDcrE != srcPtrA->vpGetDcrE ) return FALSE;
+ return TRUE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinder_memSize( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA )
+{
+ uint32 memSizeL = 0;
+ memSizeL += bbs_SIZEOF16( ptrA->typeE );
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinder_memWrite( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ uint16* memPtrA )
+{
+ uint32 memSizeL = bpi_FaceFinder_memSize( cpA, ptrA );
+ memPtrA += bbs_memWrite32( &ptrA->typeE, memPtrA );
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinder_memRead( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ const uint16* memPtrA )
+{
+ bbs_DEF_fNameL( "uint32 bpi_FaceFinder_memRead( struct bbs_Context* cpA, struct bpi_FaceFinder* ptrA, const uint16* memPtrA )" )
+ uint32 typeL;
+
+ if( bbs_Context_error( cpA ) ) return 0;
+ memPtrA += bbs_memRead32( &typeL, memPtrA );
+
+ if( typeL != ptrA->typeE )
+ {
+ bbs_ERROR1( "%s:\nObject type mismatch! Attempt to read an incorrect object.", fNameL );
+ return 0;
+ }
+
+ return bpi_FaceFinder_memSize( cpA, ptrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_faceFinderInit( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ enum bpi_FaceFinderType typeA )
+{
+ switch( typeA )
+ {
+ case bpi_FF_BF_FACE_FINDER: bpi_BFFaceFinder_init( cpA, ( struct bpi_BFFaceFinder* )ptrA ); return;
+
+ default: bbs_ERROR0( "bpi_faceFinderInit: invalid type" );
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_faceFinderExit( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA )
+{
+ switch( ptrA->typeE )
+ {
+ case bpi_FF_BF_FACE_FINDER: bpi_BFFaceFinder_exit( cpA, ( struct bpi_BFFaceFinder* )ptrA ); return;
+
+ default: bbs_ERROR0( "bpi_faceFinderExit: invalid type" );
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderMemSize( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA )
+{
+ switch( ptrA->typeE )
+ {
+ case bpi_FF_BF_FACE_FINDER: return bpi_BFFaceFinder_memSize( cpA, ( struct bpi_BFFaceFinder* )ptrA );
+
+ default: bbs_ERROR0( "bpi_faceFinderExit: invalid type" );
+ }
+ return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderMemWrite( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA, uint16* memPtrA )
+{
+ switch( ptrA->typeE )
+ {
+ case bpi_FF_BF_FACE_FINDER: return bpi_BFFaceFinder_memWrite( cpA, ( struct bpi_BFFaceFinder* )ptrA, memPtrA );
+
+ default: bbs_ERROR0( "bpi_faceFinderMemWrite: invalid type" );
+ }
+ return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderMemRead( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ const uint16* memPtrA,
+ struct bbs_MemTbl* mtpA )
+{
+ switch( ptrA->typeE )
+ {
+ case bpi_FF_BF_FACE_FINDER: return bpi_BFFaceFinder_memRead( cpA, ( struct bpi_BFFaceFinder* )ptrA, memPtrA, mtpA );
+
+ default: bbs_ERROR0( "bpi_faceFinderMemRead: invalid type" );
+ }
+ return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_faceFinderSizeOf16( struct bbs_Context* cpA, enum bpi_FaceFinderType typeA )
+{
+ switch( typeA )
+ {
+ case bpi_FF_BF_FACE_FINDER: return bbs_SIZEOF16( struct bpi_BFFaceFinder );
+
+ default: bbs_ERROR0( "bpi_faceFinderSizeOf16: invalid type" );
+ }
+ return 0;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
View
161 Embedded/common/src/b_APIEm/FaceFinder.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef bpi_FACE_FINDER_EM_H
+#define bpi_FACE_FINDER_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Context.h"
+#include "b_BasicEm/Basic.h"
+#include "b_BasicEm/MemTbl.h"
+#include "b_TensorEm/Flt16Vec.h"
+#include "b_TensorEm/IdCluster2D.h"
+#include "b_APIEm/DCR.h"
+
+/* ---- related objects --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/** Object Type */
+enum bpi_FaceFinderType
+{
+ bpi_FF_UNDEFINED = 0,
+ bpi_FF_BF_FACE_FINDER /* bitfeature based faceFinder */
+};
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** base object for face finder modules (occurs as first element in all face finder objects) */
+struct bpi_FaceFinder
+{
+ /* ---- private data --------------------------------------------------- */
+
+ /* ---- public data ---------------------------------------------------- */
+
+ /** object type */
+ uint32 typeE;
+
+ /* ---- virtual functions ---------------------------------------------- */
+
+ /** initializes some parameters prior to reading */
+ void ( *vpSetParamsE )( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA );
+
+ /** sets detection range */
+ void ( *vpSetRangeE )( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ uint32 minEyeDistanceA,
+ uint32 maxEyeDistanceA );
+
+ /** single face processing function; returns confidence (8.24) */
+ int32 ( *vpProcessE )( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ struct bpi_DCR* dcrPtrA );
+
+ /** multiple face processing function; returns number of faces detected */
+ int32 ( *vpPutDcrE )( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ struct bpi_DCR* dcrPtrA );
+
+ /** retrieves indexed face from face finder after calling PutDCR */
+ void ( *vpGetDcrE )( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA );
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bpi_FaceFinder */
+void bpi_FaceFinder_init( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA );
+
+/** resets bpi_FaceFinder */
+void bpi_FaceFinder_exit( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bpi_FaceFinder_copy( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ const struct bpi_FaceFinder* srcPtrA );
+
+/** equal operator */
+flag bpi_FaceFinder_equal( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ const struct bpi_FaceFinder* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** word size (16-bit) object needs when written to memory */
+uint32 bpi_FaceFinder_memSize( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA );
+
+/** writes object to memory; returns number of words (16-bit) written */
+uint32 bpi_FaceFinder_memWrite( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA, uint16* memPtrA );
+
+/** reads object from memory; returns number of words (16-bit) read */
+uint32 bpi_FaceFinder_memRead( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA, const uint16* memPtrA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** virtual init function */
+void bpi_faceFinderInit( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ enum bpi_FaceFinderType typeA );
+
+/** virtual exit function */
+void bpi_faceFinderExit( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA );
+
+/** virtual mem size function */
+uint32 bpi_faceFinderMemSize( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA );
+
+/** virtual mem write function */
+uint32 bpi_faceFinderMemWrite( struct bbs_Context* cpA,
+ const struct bpi_FaceFinder* ptrA,
+ uint16* memPtrA );
+
+/** virtual mem read function */
+uint32 bpi_faceFinderMemRead( struct bbs_Context* cpA,
+ struct bpi_FaceFinder* ptrA,
+ const uint16* memPtrA,
+ struct bbs_MemTbl* mtpA );
+
+/** virtual sizeof operator for 16bit units */
+uint32 bpi_faceFinderSizeOf16( struct bbs_Context* cpA,
+ enum bpi_FaceFinderType typeA );
+
+#endif /* bpi_FACE_FINDER_EM_H */
+
View
282 Embedded/common/src/b_APIEm/FaceFinderRef.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/Functions.h"
+#include "b_APIEm/FaceFinderRef.h"
+#include "b_APIEm/Functions.h"
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ auxiliary functions } ---------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ constructor / destructor } ----------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_init( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA )
+{
+ bbs_UInt16Arr_init( cpA, &ptrA->objBufE );
+ ptrA->faceFinderPtrE = NULL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_exit( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA )
+{
+ if( ptrA->faceFinderPtrE != NULL ) bpi_faceFinderExit( cpA, ptrA->faceFinderPtrE );
+ bbs_UInt16Arr_exit( cpA, &ptrA->objBufE );
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ operators } -------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_copy( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ const struct bpi_FaceFinderRef* srcPtrA )
+{
+ bbs_ERROR0( "bpi_FaceFinderRef_copy: function is not implemented" );
+}
+
+/* ------------------------------------------------------------------------- */
+
+flag bpi_FaceFinderRef_equal( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ const struct bpi_FaceFinderRef* srcPtrA )
+{
+ bbs_ERROR0( "bpi_FaceFinderRef_equal: function is not implemented" );
+ return FALSE;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ query functions } -------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ I/O } -------------------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinderRef_memSize( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA )
+{
+ uint32 memSizeL = 0;
+ memSizeL += bbs_SIZEOF16( uint32 ); /* mem size */
+ memSizeL += bbs_SIZEOF16( flag ); /* object presence flag */
+ if( ptrA->faceFinderPtrE != NULL ) memSizeL += bpi_faceFinderMemSize( cpA, ptrA->faceFinderPtrE );
+ memSizeL += bbs_SIZEOF16( uint16 ); /* csa */
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinderRef_memWrite( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ uint16* memPtrA )
+{
+ uint32 memSizeL = bpi_FaceFinderRef_memSize( cpA, ptrA );
+ flag objPresentL = ptrA->faceFinderPtrE != NULL;
+ memPtrA += bbs_memWrite32( &memSizeL, memPtrA );
+ memPtrA += bbs_memWrite32( &objPresentL, memPtrA );
+ if( objPresentL ) memPtrA += bpi_faceFinderMemWrite( cpA, ptrA->faceFinderPtrE, memPtrA );
+ memPtrA += bpi_memWriteCsa16( memPtrA, memSizeL, 0xFFFF );
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+uint32 bpi_FaceFinderRef_memRead( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA,
+ const uint16* memPtrA,
+ struct bbs_MemTbl* mtpA )
+{
+ uint32 memSizeL;
+ flag objPresentL;
+ struct bbs_MemTbl memTblL = *mtpA;
+ struct bbs_MemSeg* espL = bbs_MemTbl_segPtr( cpA, &memTblL, 0 );
+ if( bbs_Context_error( cpA ) ) return 0;
+ memPtrA += bbs_memRead32( &memSizeL, memPtrA );
+ memPtrA += bbs_memRead32( &objPresentL, memPtrA );
+
+ /* check object & allocate data buffer */
+ {
+ const uint16* memPtrL = memPtrA;
+ uint32 dataSizeL = 0;
+
+ if( objPresentL )
+ {
+ enum bpi_FaceFinderType typeL = ( enum bpi_FaceFinderType )bbs_memPeek32( memPtrL + 4 );
+ dataSizeL += bpi_faceFinderSizeOf16( cpA, typeL );
+ memPtrL += bbs_memPeek32( memPtrL );
+ }
+
+ bbs_UInt16Arr_create( cpA, &ptrA->objBufE, dataSizeL, espL );
+ }
+
+ /* load object */
+ {
+ uint16* dataPtrL = ptrA->objBufE.arrPtrE;
+
+ if( objPresentL )
+ {
+ enum bpi_FaceFinderType typeL = ( enum bpi_FaceFinderType )bbs_memPeek32( memPtrA + 4 );
+ ptrA->faceFinderPtrE = ( struct bpi_FaceFinder* )dataPtrL;
+ bpi_faceFinderInit( cpA, ptrA->faceFinderPtrE, typeL );
+ ptrA->faceFinderPtrE->vpSetParamsE( cpA, ptrA->faceFinderPtrE, maxImageWidthA, maxImageHeightA );
+ memPtrA += bpi_faceFinderMemRead( cpA, ptrA->faceFinderPtrE, memPtrA, &memTblL );
+ dataPtrL += bpi_faceFinderSizeOf16( cpA, typeL );
+ }
+ else
+ {
+ ptrA->faceFinderPtrE = NULL;
+ }
+ }
+
+ memPtrA += bpi_memReadCsa16( memPtrA );
+
+ return memSizeL;
+}
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_setParams( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA )
+{
+ bbs_DEF_fNameL( "bpi_FaceFinderRef_setParams" );
+ if( ptrA->faceFinderPtrE == NULL )
+ {
+ bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+ return;
+ }
+ ptrA->faceFinderPtrE->vpSetParamsE( cpA, ptrA->faceFinderPtrE, maxImageWidthA, maxImageHeightA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_setRange( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ uint32 minEyeDistanceA,
+ uint32 maxEyeDistanceA )
+{
+ bbs_DEF_fNameL( "bpi_FaceFinderRef_setRange" );
+ if( ptrA->faceFinderPtrE == NULL )
+ {
+ bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+ return;
+ }
+ ptrA->faceFinderPtrE->vpSetRangeE( cpA, ptrA->faceFinderPtrE, minEyeDistanceA, maxEyeDistanceA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_FaceFinderRef_process( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ struct bpi_DCR* dcrPtrA )
+{
+ bbs_DEF_fNameL( "bpi_FaceFinderRef_process" );
+ if( ptrA->faceFinderPtrE == NULL )
+ {
+ bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+ return 0;
+ }
+ return ptrA->faceFinderPtrE->vpProcessE( cpA, ptrA->faceFinderPtrE, dcrPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_FaceFinderRef_putDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ struct bpi_DCR* dcrPtrA )
+{
+ bbs_DEF_fNameL( "bpi_FaceFinderRef_putDcr" );
+ if( ptrA->faceFinderPtrE == NULL )
+ {
+ bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+ return 0;
+ }
+ return ptrA->faceFinderPtrE->vpPutDcrE( cpA, ptrA->faceFinderPtrE, dcrPtrA );
+}
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_FaceFinderRef_getDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA )
+{
+ bbs_DEF_fNameL( "bpi_FaceFinderRef_getDcr" );
+ if( ptrA->faceFinderPtrE == NULL )
+ {
+ bbs_ERROR1( "%s:\nNo face finder object was loaded", fNameL );
+ return;
+ }
+ ptrA->faceFinderPtrE->vpGetDcrE( cpA, ptrA->faceFinderPtrE, indexA, dcrPtrA );
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+
View
123 Embedded/common/src/b_APIEm/FaceFinderRef.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef bpi_FACE_FINDER_REF_EM_H
+#define bpi_FACE_FINDER_REF_EM_H
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_BasicEm/UInt16Arr.h"
+#include "b_APIEm/FaceFinder.h"
+
+/* ---- related objects --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ---- object definition -------------------------------------------------- */
+
+/** type independent reference to a faceFinder module */
+struct bpi_FaceFinderRef
+{
+ /* ---- private data --------------------------------------------------- */
+
+ /* ---- public data ---------------------------------------------------- */
+
+ /** object buffer */
+ struct bbs_UInt16Arr objBufE;
+
+ /** faceFinder pointer */
+ struct bpi_FaceFinder* faceFinderPtrE;
+
+ /* ---- functions ------------------------------------------------------ */
+
+};
+
+/* ---- associated objects ------------------------------------------------- */
+
+/* ---- external functions ------------------------------------------------- */
+
+/* ---- \ghd{ constructor/destructor } ------------------------------------- */
+
+/** initializes bpi_FaceFinderRef */
+void bpi_FaceFinderRef_init( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA );
+
+/** resets bpi_FaceFinderRef */
+void bpi_FaceFinderRef_exit( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA );
+
+/* ---- \ghd{ operators } -------------------------------------------------- */
+
+/** copy operator */
+void bpi_FaceFinderRef_copy( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ const struct bpi_FaceFinderRef* srcPtrA );
+
+/** equal operator */
+flag bpi_FaceFinderRef_equal( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ const struct bpi_FaceFinderRef* srcPtrA );
+
+/* ---- \ghd{ query functions } -------------------------------------------- */
+
+/* ---- \ghd{ modify functions } ------------------------------------------- */
+
+/* ---- \ghd{ memory I/O } ------------------------------------------------- */
+
+/** word size (16-bit) object needs when written to memory */
+uint32 bpi_FaceFinderRef_memSize( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA );
+
+/** writes object to memory; returns number of words (16-bit) written */
+uint32 bpi_FaceFinderRef_memWrite( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA, uint16* memPtrA );
+
+/** reads object from memory; returns number of words (16-bit) read */
+uint32 bpi_FaceFinderRef_memRead( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ uint32 maxImageWidthA,
+ uint32 maxImageHeightA,
+ const uint16* memPtrA,
+ struct bbs_MemTbl* mtpA );
+
+/* ---- \ghd{ exec functions } --------------------------------------------- */
+
+/** sets detection range */
+void bpi_FaceFinderRef_setRange( struct bbs_Context* cpA,
+ struct bpi_FaceFinderRef* ptrA,
+ uint32 minEyeDistanceA,
+ uint32 maxEyeDistanceA );
+
+/** single face processing function; returns confidence (8.24) */
+int32 bpi_FaceFinderRef_process( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ struct bpi_DCR* dcrPtrA );
+
+/** multiple face processing function; returns number of faces detected */
+int32 bpi_FaceFinderRef_putDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ struct bpi_DCR* dcrPtrA );
+
+/** retrieves indexed face from face finder after calling PutDCR */
+void bpi_FaceFinderRef_getDcr( struct bbs_Context* cpA,
+ const struct bpi_FaceFinderRef* ptrA,
+ uint32 indexA,
+ struct bpi_DCR* dcrPtrA );
+
+#endif /* bpi_FACE_FINDER_REF_EM_H */
+
View
316 Embedded/common/src/b_APIEm/Functions.c
@@ -0,0 +1,316 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ---- includes ----------------------------------------------------------- */
+
+#include "b_APIEm/Functions.h"
+#include "b_BasicEm/Memory.h"
+
+
+/* ---- related objects --------------------------------------------------- */
+
+/* ---- typedefs ----------------------------------------------------------- */
+
+/* ---- constants ---------------------------------------------------------- */
+
+/* ------------------------------------------------------------------------- */
+
+/* ========================================================================= */
+/* */
+/* ---- \ghd{ external functions } ----------------------------------------- */
+/* */
+/* ========================================================================= */
+
+/* ------------------------------------------------------------------------- */
+
+void bpi_normalizeSimilarities( struct bbs_Context* cpA,
+ const int32* rawSimArrA,
+ const int32* rawIdArrA,
+ uint32 rawSizeA,
+ const int32* refSimArrA,
+ const int32* refIdArrA,
+ uint32 refSizeA,
+ enum bpi_SimType simTypeA,
+ int32* outSimArrA )
+{
+ /* 8.24 */
+ int32 refSimL = 0;
+ uint32 iL, jL, kL;
+ int32* outPtrL = outSimArrA;
+ const int32* rawPtrL = rawSimArrA;
+
+ switch( simTypeA )
+ {
+ case bpi_RAW_SIM:
+ {
+ /* nothing to do */
+ }
+ break;
+
+ case bpi_SUB_MEAN:
+ {
+ int32 shiftL = 0;
+ int32 roundL = 0;
+ refSimL = 0;
+ for( iL = 0; iL < refSizeA; iL++ )
+ {
+ refSimL += ( refSimArrA[ iL ] + roundL ) >> shiftL;
+ if( refSimL > 0x40000000 )
+ {
+ refSimL = ( refSimL + 1 ) >> 1;
+ shiftL++;
+ roundL = ( int32 )1 << ( shiftL - 1 );
+ }
+ }
+ refSimL = ( refSimL / refSizeA ) << shiftL;
+ }
+ break;
+
+ case bpi_SUB_MAX_2:
+ {
+ int32 maxL = 0;
+ uint32 maxIndexL = 0;
+ int32 idL = 0;
+
+ /* find raw maximum */
+ for( iL = 0; iL < rawSizeA; iL++ )
+ {
+ if( maxL < rawSimArrA[ iL ] )
+ {
+ maxL = refSimArrA[ iL ];
+ maxIndexL = iL;
+ }
+ }
+
+ /* consider id of maximum equal to probe id */
+ idL = rawIdArrA[ maxIndexL ];
+
+ /* find maximum similarity in ref array of different id */
+ for( iL = 0; iL < refSizeA; iL++ )
+ {
+ if( refIdArrA[ iL ] != idL )
+ {
+ refSimL = ( refSimL > refSimArrA[ iL ] ) ? refSimL : refSimArrA[ iL ];
+ }
+ }
+ }
+ break;
+
+ case bpi_SUB_16_MAX_2:
+ {
+ int32 maxL = 0;
+ uint32 maxIndexL = 0;
+ int32 idL = 0;
+
+ int32 maxSimArrL[ 16 ];
+ bbs_memset32( maxSimArrL, ( uint32 )-1, bbs_SIZEOF32( maxSimArrL ) );
+
+ /* find raw maximum */
+ for( iL = 0; iL < rawSizeA; iL++ )
+ {
+ if( maxL < rawSimArrA[ iL ] )
+ {
+ maxL = rawSimArrA[ iL ];
+ maxIndexL = iL;
+ }
+ }
+
+ /* consider id of maximum equal to probe id */
+ idL = rawIdArrA[ maxIndexL ];
+
+ /* find 16 maximum similarities of different id in ref array */
+ for( iL = 0; iL < refSizeA; iL++ )
+ {
+ if( refIdArrA[ iL ] != idL )
+ {
+ int32 simL = refSimArrA[ iL ];
+ for( jL = 0; jL < 16; jL++ )
+ {
+ if( simL > maxSimArrL[ jL ] ) break;
+ }
+ for( kL = 15; kL > jL; kL-- )
+ {
+ maxSimArrL[ kL ] = maxSimArrL[ kL - 1 ];
+ }
+ if( jL < 16 ) maxSimArrL[ jL ] = simL;
+ }
+ }
+
+ refSimL = 0;
+ for( jL = 0; jL < 16; jL++ )
+ {
+ if( maxSimArrL[ jL ] == -1 ) break;
+ refSimL += maxSimArrL[ jL ];
+ }
+
+ if( jL > 0 )
+ {
+ refSimL /= jL;
+ }
+ }
+ break;
+
+ default:
+ {
+ bbs_ERROR1( "void bpi_Identifier_normalizeSimilarities(): simTypeA '%i' is handled", simTypeA );
+ return;
+ }
+ }
+
+ /* refSimL -= 1.0 */
+ refSimL -= ( (uint32)1 << 24 );
+
+ for( iL = rawSizeA; iL > 0; iL-- )
+ {
+ *outPtrL++ = ( *rawPtrL++ - refSimL + 1 ) >> 1;
+ }
+
+}
+
+/* ------------------------------------------------------------------------- */
+
+int32 bpi_normalizedSimilarity( struct bbs_Context* cpA,
+ int32 rawSimA,
+ int32 rawIdA,
+ const int32* refSimArrA,
+ const int32* refIdArrA,
+ uint32 refSizeA,
+ enum bpi_SimType simTypeA )
+{
+ /* 8.24 */
+ int32 refSimL = 0;
+ uint32 iL, jL, kL;
+
+ switch( simTypeA )
+ {
+ case bpi_RAW_SIM:
+ {
+ /* nothing to do */
+ return rawSimA; /* return without adjustment of value range */
+ }