Skip to main content
. 2024 Jul 26;24(15):4861. doi: 10.3390/s24154861
Algorithm 2 Search for parallel straight edges
  • 1:

    dmax(px)=physicalmax(cm)×focal(px)depth(cm)

  • 2:

    if n2 then

  • 3:

        Calculate distance Di for all Ei from (xc,yc)

  • 4:

        Sort Ei by Di (ascending)

  • 5:

        for θmax=min to max do                                                ▹ user-defined min/max

  • 6:

            for i=1 to n1 do

  • 7:

               for j=i+1 to n do

  • 8:

                   Δθ=|θEiθEj|

  • 9:

                   if Δθθmax then

  • 10:

                       Draw linedi between Ei,Ej

  • 11:

                       Check |θlineθi| θdiff_min

  • 12:

                       Check didmax

  • 13:

                       if suitable then

  • 14:

                           Break

  • 15:

                       else

  • 16:

                           j=j+1

  • 17:

               if no suitable pair then

  • 18:

                   i=i+1

  • 19:

            if no suitable pair then

  • 20:

               θmax=θmax+step                                                ▹ user-defined step

  • 21:

        if pair found then

  • 22:

            Optimize grasp position

  • 23:

        else

  • 24:

            Sort Ei by length lEi (descending)

  • 25:

            for i=1 to n do

  • 26:

               K = Project (xEi,yEi) to other side of P

  • 27:

               Distance K to (xEi,yEi)dmax

  • 28:

               if suitable then

  • 29:

                   Break

  • 30:

               else

  • 31:

                   i=i+1