اذهب إلى المحتوى
  • 0

كيف أستطيع جعل تطبيقي يقارن الصورة التي يلتقطها بأخرى موجودة database؟

RadwaAyad

السؤال

Recommended Posts

  • 1

بصرف النظر عن اللغة المستعملة، أنصحك بالبحث في لغةPython حيث أنها تتوفر على مكتبة مخصصة لهذا الغرض، أي مقارنة صورتين وأشياء أخرى، وأتحدث هنا عن OpenCv، وتعتمد هذة المكتبة على تقسيم الصورة إلى مجموعة نقط بالاعتماد على خوارزميات معقدة نوعا ما، ليتن مقارنة مختلف النقط الموجودة على الصورتين، وفي حالة تواجد تطابق بنسبة كبيرة، آنذاك يمكن القول بأن الصورتين متشابهتين.

يمكنك الاستفادة من هذا الكود:

#original data, two 2x2 images, normalized
x = rand(2,2)
x/=sum(x)
y = rand(2,2)
y/=sum(y)

#initial guess of the flux matrix
# just the product of the image x as row for the image y as column
#This is a working flux, but is not an optimal one
F = (y.flatten()*x.flatten().reshape((y.size,-1))).flatten()

#distance matrix, based on euclidean distance
row_x,col_x = meshgrid(range(x.shape[]),range(x.shape[1]))
row_y,col_y = meshgrid(range(y.shape[]),range(y.shape[1]))
rows = ((row_x.flatten().reshape((row_x.size,-1)) - row_y.flatten().reshape((-1,row_x.size)))**2)
cols = ((col_x.flatten().reshape((row_x.size,-1)) - col_y.flatten().reshape((-1,row_x.size)))**2)
D = np.sqrt(rows+cols)

D = D.flatten()
x = x.flatten()
y = y.flatten()
#COST=sum(F*D)

#cost function
fun = lambda F: sum(F*D)
jac = lambda F: D
#array of constraint
#the constraint of sum one is implicit given the later constraints
cons  = []
#each row and columns should sum to the value of the start and destination array
cons += [ {'type': 'eq', 'fun': lambda F:  sum(F.reshape((x.size,y.size))[i,:])-x[i]}     for i in range(x.size) ]
cons += [ {'type': 'eq', 'fun': lambda F:  sum(F.reshape((x.size,y.size))[:,i])-y[i]} for i in range(y.size) ]
#the values of F should be positive
bnds = (, None)*F.size

*ملاحظة في حال كنت تستخدم تطبيق ويب بلغة php يمكنك استخدام python أيضا، وذلك عن طريق الدالة exec.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...