LBP

Discussion related to "under the hood" OpenMV topics.
User avatar
chrisPyres66
Posts: 144
Joined: Mon Jul 16, 2018 9:22 am
Location: France

LBP

Postby chrisPyres66 » Mon May 06, 2019 10:49 am

Dear All,

I use lbp descriptor to recognize a pattern and, to filter local noise, i divide the image in several part with each a lbp descriptor.
My problem is if i use more than 4 lbp pattern, whatever the resolution, i have frequently deconnexion and it does not seem stable.

Do you have any knowledge about this problem and advice to do it better ?
Thanks,
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: LBP

Postby iabdalkader » Mon May 06, 2019 1:55 pm

Code ?
User avatar
chrisPyres66
Posts: 144
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: LBP

Postby chrisPyres66 » Tue May 07, 2019 8:27 am

Below is the simplified code, where you can define the number of line and column which define the number of areas where the lbp is defined and checked.
I tested the M7 and H7 camera, and both get problem if i increase the number of line and column.

With openmv 2.2.0 :
For M7 (rev 3.4.1), in VGA :
- 1 line and 1 column works
- 1 line and 2 column works
- 2 line and 1 column does not work
- 2 line and 2 column does not work
It stops at the lbp save step.

For H7 (rev 3.4.1), in VGA :
- 3 lines and 3 columns works but disconnect

Code: Select all

import sensor, image

# Reset sensor
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=1000)

# Variable to define
nline = 4
ncolumn = 4
thres = 15000
stext = 2

# Size definition
zoneW = sensor.width()
zoneH = sensor.height()
wcolumn = int(zoneW / ncolumn)
hline = int(zoneH / nline)

# Save lbp features
mode = "save"  #0
if mode == "save" :
   print("save -------------")
   img = sensor.snapshot()
   for i in range(0,nline) :
      for j in range(0,ncolumn) :
         dn = img.find_lbp( (int(j*wcolumn), int(i*hline), int(wcolumn), int(hline)) )
         n = i*ncolumn+j
         filename = "lbp" + str(n) + ".lbp"
         if image.save_descriptor(dn, "%s" % filename) == False :
            print("Error : ", filename)

print("check -------------")
while (True):
   img = sensor.snapshot()
   OK = 0
   for i in range(0, nline) :
      for j in range(0, ncolumn) :
         d1 = img.find_lbp( ( int(j*wcolumn), int(i*hline), int(wcolumn), int(hline) ) )
         filename = "lbp%d.lbp" % int(i*ncolumn+j)
         dn = image.load_descriptor("%s" % filename)
         dist = image.match_descriptor(dn, d1)
         img.draw_string(int(j*wcolumn), int(i*hline) + 10, "%d" % dist, color=(0,0,0), scale=stext)
         if dist < thres :
            OK += 1

   if OK > 0 :
      print( "O_Ok : %d" % OK)
   else :
      print("Nok")
It seems to be a memory problem, but i dont know how free memory.

Thanks for help,
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: LBP

Postby iabdalkader » Tue May 07, 2019 1:14 pm

It's a bug in LBP ROI. Can you test the attached image ?
Attachments
firmware.zip
(923.11 KiB) Downloaded 196 times
User avatar
chrisPyres66
Posts: 144
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: LBP

Postby chrisPyres66 » Thu May 09, 2019 9:01 am

Wowwwww, i tested a 6x6 lbp on M7, and it works fine.
Which file from github i have to update to get this ?
Thanks,
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: LBP

Postby iabdalkader » Thu May 09, 2019 9:19 am

lbp.c
User avatar
chrisPyres66
Posts: 144
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: LBP

Postby chrisPyres66 » Thu May 09, 2019 10:44 am

Thanks,
I red lbp.c and i discovered the weight are optimized for face recognition.
I would like to use for another use, what is the default values, and how can i define it to my own case ?
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: LBP

Postby iabdalkader » Thu May 09, 2019 11:14 am

chrisPyres66 wrote:
Thu May 09, 2019 10:44 am
Thanks,
I red lbp.c and i discovered the weight are optimized for face recognition.
I would like to use for another use, what is the default values, and how can i define it to my own case ?
I think it depends on the application, you should search for LBP papers.
User avatar
chrisPyres66
Posts: 144
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: LBP

Postby chrisPyres66 » Fri May 10, 2019 6:16 am

Well i understand than lbp_weights has a high value around eyes, medium value for mouth and ear, then low level for cheeks.
If i want to have a neutral use, i can set 1 for all the 7x7 matrix.

I dont understand what is for the uniform_tbl matrix ?
User avatar
iabdalkader
Posts: 1143
Joined: Sun May 24, 2015 3:53 pm

Re: LBP

Postby iabdalkader » Fri May 10, 2019 8:50 am

Please see the "Face Recognition with Local Binary Patterns" paper if you want more details.
User avatar
chrisPyres66
Posts: 144
Joined: Mon Jul 16, 2018 9:22 am
Location: France

Re: LBP

Postby chrisPyres66 » Mon May 13, 2019 5:04 am

well, the uniform matrix is to reduce the number of lbp (256 possibility) to 59 most common.
So it is not usefull to change for specific use.
Thanks,

Return to “Technical Discussion”

Who is online

Users browsing this forum: MSN [Bot], pcls1026 and 3 guests