(http://www.cognotics.com/opencv/servo_2007_series/part_5/fig_10_thumb.png)
Am I right translating it?
Quote
isless MACRO r1:req, r2:req
LOCAL error, true, false, clear
; Gregg macro, greg is MASM32 forum member
finit
fld r2
fld r1
fcom
fstsw ax
fwait
sahf
jpe error
ja false
jb true
jz false
error:
mov eax, -1
jmp clear
true:
mov eax, 1
jmp clear
false:
xor eax, eax
clear:
fstp st(0)
fstp st(0)
EXITM <eax>
ENDM
I changed the line 15 to distSq += d_i*d_i/eigenValMat->data.fl
;
Quote
fCVFindNearestNeighbor proc lpStruct:dword,lpProjectedFace:dword,lpResult:dword
LOCAL leastDistSq,distSq:qword
LOCAL i, iTrain, iNearest:dword
LOCAL PTF,PTFM,d_i:dword
LOCAL lDiS,DiS:real10
LOCAL buff[256]:dword
fld CDBL(8.9884656743115775e+307)
fstp leastDistSq
mov esi,lpStruct
xor ecx,ecx
mov iTrain,ecx
mov i,ecx
xor eax,eax
dec eax
mov iNearest,eax
loop_iTrain:
fld CDBL(0.0)
fstp distSq
loop_i:
;--------------------------------------------------IN HERE------------------------------------------
mov ecx,i
mov eax,lpProjectedFace
fld dword ptr[eax+ecx*4]
mov eax,iTrain
mov ecx,[esi].fMem.nEigens
mul ecx
add eax,i
mov edx,[esi].fMem.projectedTrainFaceMat
mov edx,[edx].CvMat.data.fl
fsub dword ptr [edx+eax*4]
fmul st(0),st(0) ;distSq += d_i*d_i/eigenValMat->data.fl;
mov eax,[esi].fMem.eigenValMat
mov eax,[eax].CvMat.data.fl
mov ecx,i
fdiv dword ptr [eax+ecx*4]
fadd distSq
fstp distSq
;----------------------------------------------------------End Here----------------------------------------
inc i
mov eax,i
cmp eax,[esi].fMem.nEigens
jl loop_i
fld distSq
fstp DiS
fld leastDistSq
fstp lDiS
mov eax,isless(DiS,lDiS)
.if eax==TRUE
fld distSq
fstp leastDistSq
push iTrain
pop iNearest
.endif
xor ecx,ecx
mov i,ecx
inc iTrain
mov eax,iTrain
cmp eax,[esi].fMem.nTrainFaces
jl loop_iTrain
mov eax,lpResult
fld leastDistSq
fstp qword ptr[eax]
mov eax,iNearest
ret
fCVFindNearestNeighbor endp