Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:DavidSie/MotionVectorEstimator i…
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
David Siecinski committed Jun 14, 2016
2 parents 4c34d6c + a0c9a16 commit e814c49
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions logsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,27 @@ def placeholder(self):
# self.numOfcomparedMacroblocks=0


def __sumOfAbsoluteDifferences__(self,n,m):
def __sumOfAbsoluteDifferences__(self,n,m,isInterpolated):
sum=0.0
current_picture=None
if isInterpolated:
current_picture=self.current_picture_interpolated
else:
current_picture=self.current_picture

for i in range(self.n):
for j in range(self.n):
y_n, x_m = self.__position___(i+n,j+m)
y, x = self.__position___(i,j)
if x_m>=len(self.current_picture[0]) or x_m<0 or y_n>=len(self.current_picture) or y_n<0:
if x_m>=len(current_picture[0]) or x_m<0 or y_n>=len(current_picture) or y_n<0:
sum =sum + sys.float_info.max/10
elif x>=len(self.current_picture[0]) or x<0 or y>=len(self.current_picture) or y<0:
elif x>=len(current_picture[0]) or x<0 or y>=len(current_picture) or y<0:
sum =sum + sys.float_info.max/10
else:
#print "makroblok(",i,",",j,")=",self.__makroBlock__(i,j),"makroBlok(",i+n,",",j+m,")=",self.__makroBlock__(i+n,j+m,isCurrent=False)
sum = sum + (self.__makroBlock__(i,j)-self.__makroBlock__(i+n,j+m,isCurrent=False))*(self.__makroBlock__(i,j)-self.__makroBlock__(i+n,j+m,isCurrent=False))
# print "makroblok(",i,",",j,")=",self.__makroBlock__(i,j),"makroblok(",i+n,",",j+m,")=",self.__makroBlock__(i+n,j+m,isCurrent=False)
sum = sum + (self.__makroBlock__(i,j,isInterpolated=isInterpolated)-self.__makroBlock__(i+n,j+m,isCurrent=False,isInterpolated=isInterpolated))*(self.__makroBlock__(i,j,isInterpolated=isInterpolated)-self.__makroBlock__(i+n,j+m,isCurrent=False,isInterpolated=isInterpolated))
self.numOfcomparedMacroblocks=self.numOfcomparedMacroblocks+1
#print "macroblock",self.__position___(0,0),"for vector[",n,",",m,"] sum=",sum
# print "macroblock",self.__position___(0,0),"for vector[",n,",",m,"] sum=",sum
return sum

def motionVector(self,isInterpolated=False):
Expand All @@ -49,22 +55,22 @@ def motionVector(self,isInterpolated=False):
step = 8
while(stop==0):
#print "WHILE LOOP STARTS HERE ------------"
# print "Step size = ",step
#print "Step size = ",step

min_value = self.__sumOfAbsoluteDifferences__(n,m)
min_value = self.__sumOfAbsoluteDifferences__(n,m, isInterpolated)
iteration=iteration+1
#print 'Set min value for center point [',n,',',m,'] = ', min_value


for i in range(n-step,n+step+1,step):
if(i==n):
for j in range(m-step,m+step+1,step):
value = self.__sumOfAbsoluteDifferences__(i,j)
value = self.__sumOfAbsoluteDifferences__(i,j,isInterpolated)
#print 'value[',i,',',j,']= ', value
[n,m,value,min_value]=self.findMinLocation(n,m,i,j,value,min_value)
#print [n,m,value,min_value]
else:
value = self.__sumOfAbsoluteDifferences__(i,m)
value = self.__sumOfAbsoluteDifferences__(i,m,isInterpolated)
#print 'value[',i,',',m,']= ', value
temp=m
[n,m,value,min_value]=self.findMinLocation(n,m,i,temp,value,min_value)
Expand All @@ -84,12 +90,12 @@ def motionVector(self,isInterpolated=False):


#print "Step = 1 ---> find min from 8 points around center point"
min_value = self.__sumOfAbsoluteDifferences__(n,m)
min_value = self.__sumOfAbsoluteDifferences__(n,m,isInterpolated)
iteration=iteration+1
#print 'inicial min value[',n,',',m,']= ', min_value
for i in range(n-step,n+step+1,step):
for j in range(m-step,m+step+1,step):
value = self.__sumOfAbsoluteDifferences__(i,j)
value = self.__sumOfAbsoluteDifferences__(i,j,isInterpolated)
#print 'value[',i,',',j,']= ', value
[n,m,value,min_value]=self.findMinLocation(n,m,i,j,value,min_value)
#print [n,m,value,min_value]
Expand Down

0 comments on commit e814c49

Please sign in to comment.