From e75e2adedf5b30d29d60752a1fd353fbdc5add51 Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Wed, 27 Oct 2021 01:28:30 +0200 Subject: [PATCH] Kreuzkorrelation nicht mehr mit Rot-Kanal, sondern auf dem Grau-Bild (R+G+B) --- detect.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/detect.cc b/detect.cc index 17c0d61..59e7b59 100644 --- a/detect.cc +++ b/detect.cc @@ -213,7 +213,7 @@ void Detect::InputDetect(int *posx, int *posy) { } } -inline float calc_vector(uint8_t a1, uint8_t a2, uint8_t b1, uint8_t b2, uint8_t c1, uint8_t c2, uint8_t d1, uint8_t d2) { +inline float calc_vector(uint16_t a1, uint16_t a2, uint16_t b1, uint16_t b2, uint16_t c1, uint16_t c2, uint16_t d1, uint16_t d2) { return a1 * a2 + b1 * b2 + c1 * c2 + d1 * d2; // __m64 m1 = _mm_set_pi16 (a1, b1, c1, d1); // __m64 m2 = _mm_set_pi16 (a2, b2, c2, d2); @@ -223,7 +223,7 @@ inline float calc_vector(uint8_t a1, uint8_t a2, uint8_t b1, uint8_t b2, uint8_t // return data[0] + data[1]; } -#define OBJSIZE 50 +#define OBJSIZE 52 #define MAXSHIFT 20 void Detect::InputDetectCrossC(int *posx, int *posy) { unsigned char *pxi; // input image @@ -271,10 +271,20 @@ void Detect::InputDetectCrossC(int *posx, int *posy) { for (x = 0; x < OBJSIZE; x++, oldi += 3, ini += 3, oldx++, inx++) { if (oldx >= 0 && oldy >= 0 && oldx < oldFrame.w && oldy <= oldFrame.h && inx >= 0 && inx < inFrame.w && iny >= 0 && iny < inFrame.h) { - f += calc_vector( pxo[oldi+0], pxi[ini+0], - pxo[oldi+3], pxi[ini+3], - pxo[oldi+6], pxi[ini+6], - pxo[oldi+9], pxi[ini+9]); + uint16_t ogray[4]; + uint16_t igray[4]; + ogray[0] = pxo[oldi+0] + pxo[oldi+1] + pxo[oldi+2]; + ogray[1] = pxo[oldi+3] + pxo[oldi+4] + pxo[oldi+5]; + ogray[2] = pxo[oldi+6] + pxo[oldi+7] + pxo[oldi+8]; + ogray[3] = pxo[oldi+9] + pxo[oldi+10] + pxo[oldi+11]; + igray[0] = pxi[oldi+0] + pxi[ini+1] + pxi[ini+2]; + igray[1] = pxi[oldi+3] + pxi[ini+4] + pxi[ini+5]; + igray[2] = pxi[oldi+6] + pxi[ini+7] + pxi[ini+8]; + igray[3] = pxi[oldi+9] + pxi[ini+10] + pxi[ini+11]; + f += calc_vector( ogray[0], igray[0], + ogray[1], igray[1], + ogray[2], igray[2], + ogray[3], igray[3]); x+=3; oldi += 9; ini += 9; oldx+=3; inx+=3; } }