@@ -33,13 +33,32 @@ void matrixLerp(ARdouble src[3][4], ARdouble dst[3][4],
3333}
3434
3535int ARToolKitNFT::passVideoData (py::array_t <uint8_t > videoFrame, py::array_t <uint8_t > videoLuma) {
36- auto videoFramePtr = static_cast < uint8_t *>( videoFrame.request (). ptr );
37- auto videoLumaPtr = static_cast < uint8_t *>( videoLuma.request (). ptr );
36+ auto frame_info = videoFrame.request ();
37+ auto luma_info = videoLuma.request ();
3838
39- std::copy (videoFramePtr, videoFramePtr + videoFrame.size (), this ->videoFrame .get ());
40- std::copy (videoLumaPtr, videoLumaPtr + videoLuma.size (), this ->videoLuma .get ());
39+ ARLOGi (" Video Frame Debug:\n " );
40+ ARLOGi (" Dimensions: %ld\n " , frame_info.ndim );
41+ ARLOGi (" Shape: Total elements: %ld\n " , frame_info.shape [0 ]);
42+ ARLOGi (" Total size: %ld bytes\n " , frame_info.size );
43+ ARLOGi (" Item size: %ld bytes\n " , frame_info.itemsize );
4144
42- return 0 ;
45+ ARLOGi (" Video Luma Debug:\n " );
46+ ARLOGi (" Dimensions: %ld\n " , luma_info.ndim );
47+ ARLOGi (" Shape: Total elements: %ld\n " , luma_info.shape [0 ]);
48+ ARLOGi (" Total size: %ld bytes\n " , luma_info.size );
49+ ARLOGi (" Item size: %ld bytes\n " , luma_info.itemsize );
50+
51+ uint8_t * frame_ptr = static_cast <uint8_t *>(frame_info.ptr );
52+ uint8_t * luma_ptr = static_cast <uint8_t *>(luma_info.ptr );
53+
54+ // Copy flattened data
55+ std::copy (frame_ptr, frame_ptr + frame_info.size , this ->videoFrame .get ());
56+ std::copy (luma_ptr, luma_ptr + luma_info.size , this ->videoLuma .get ());
57+
58+ ARLOGi (" First few frame bytes: %u %u %u %u %u\n " , frame_ptr[0 ], frame_ptr[1 ], frame_ptr[2 ], frame_ptr[3 ], frame_ptr[4 ]);
59+ ARLOGi (" First few luma bytes: %u %u %u %u %u\n " , luma_ptr[0 ], luma_ptr[1 ], luma_ptr[2 ], luma_ptr[3 ], luma_ptr[4 ]);
60+
61+ return 0 ;
4362}
4463
4564py::dict ARToolKitNFT::getNFTMarkerInfo (int markerIndex) {
@@ -124,17 +143,30 @@ int ARToolKitNFT::detectNFTMarker() {
124143 int kpmResultNum = -1 ;
125144
126145 if (this ->detectedPage == -2 ) {
146+ ARLOGi (" detectedPage = %d\n " , this ->detectedPage );
127147 kpmMatching (this ->kpmHandle .get (), this ->videoLuma .get ());
128148 kpmGetResult (this ->kpmHandle .get (), &kpmResult, &kpmResultNum);
129-
149+ if (kpmResultNum > 0 ) {
150+ ARLOGi (" kpmMatching found %d results.\n " , kpmResultNum);
151+ for (int i = 0 ; i < kpmResultNum; i++) {
152+ ARLOGi (" kpmResult[%d]: pageNo = %d, error = %f, inlierNum = %d, camPoseF = %d\n " ,
153+ i,
154+ kpmResult[i].pageNo ,
155+ kpmResult[i].error ,
156+ kpmResult[i].inlierNum ,
157+ kpmResult[i].camPoseF );
158+ }
159+ } else {
160+ ARLOGi (" No kpmResults found." );
161+ }
130162#if WITH_FILTERING
131163 this ->ftmi = arFilterTransMatInit (this ->filterSampleRate ,
132164 this ->filterCutoffFrequency );
133165#endif
134166
135167 for (int i = 0 ; i < kpmResultNum; i++) {
136168 if (kpmResult[i].camPoseF == 0 ) {
137-
169+ ARLOGi ( " kpmResult[i].pageNo = %d \n " , kpmResult[i]. pageNo );
138170 float trans[3 ][4 ];
139171 this ->detectedPage = kpmResult[i].pageNo ;
140172 std::copy (&kpmResult[i].camPose [0 ][0 ], &kpmResult[i].camPose [0 ][0 ] + 3 * 4 , &trans[0 ][0 ]);
@@ -178,8 +210,8 @@ int ARToolKitNFT::setupAR2() {
178210 this ->ar2Handle = tempHandle;
179211
180212 // Settings for devices with single-core CPUs.
181- ar2SetTrackingThresh (this ->ar2Handle , 5 .0 );
182- ar2SetSimThresh (this ->ar2Handle , 0.50 );
213+ ar2SetTrackingThresh (this ->ar2Handle , 2 .0 ); // Lowering tolerance.
214+ ar2SetSimThresh (this ->ar2Handle , 0.3 ); // Increase similarity tolerance.
183215 ar2SetSearchFeatureNum (this ->ar2Handle , 16 );
184216 ar2SetSearchSize (this ->ar2Handle , 6 );
185217 ar2SetTemplateSize1 (this ->ar2Handle , 6 );
0 commit comments