Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add new primitives? #10

Closed
7 tasks done
cserteGT3 opened this issue Apr 24, 2020 · 2 comments
Closed
7 tasks done

How to add new primitives? #10

cserteGT3 opened this issue Apr 24, 2020 · 2 comments

Comments

@cserteGT3
Copy link
Owner

cserteGT3 commented Apr 24, 2020

What needs to be done, to add a new shape primitive? (Just gathering the tasks, syntax and names are subject to change.)

  • struct NewShape <: FittedShape: a new type
  • fitshape(::Type{NewShape},...): a function that fits the primitive
  • compatibles(shape::NewShape): compute the compatible points
  • scorecandidate() - is it even necessary?
  • refitshape()
  • a way to add the new primitive to the list of primitives, that are fitted in an iteration (i.e. to RANSACParameters)
  • parameters for the new shape !!! - this is the major issue
@cserteGT3
Copy link
Owner Author

Parameters solved:
A nested NamedTuple and the @extract macro from ExtractMacro.jl:

julia> using ExtractMacro

julia> plane_par ==10, ϵ=0.1, other_par = 11.3)
(α = 10, ϵ = 0.1, other_par = 11.3)

julia> sphere_par ==5, ϵ=0.05, )
(α = 5, ϵ = 0.05)

julia> iter_par1 = (maxit=100, p = 0.99)
(maxit = 100, p = 0.99)

julia> new_shape ==1, ϵ=15, oth="A")
(α = 1, ϵ = 15, oth = "A")

julia> ransacpars = (plane=plane_par, sphere=sphere_par, iterations=iter_par1)
(plane == 10, ϵ = 0.1, other_par = 11.3), sphere == 5, ϵ = 0.05), iterations = (maxit = 100, p = 0.99))

julia> function test1(p)
       @extract p : sphere_p=sphere plane_p=plane
       @show sphere_p
       @show plane_p
       end
test1 (generic function with 1 method)

julia> test1(ransacpars)
sphere_p == 5, ϵ = 0.05)
plane_p == 10, ϵ = 0.1, other_par = 11.3)
(α = 10, ϵ = 0.1, other_par = 11.3)

julia> test1(ransacpars);
sphere_p == 5, ϵ = 0.05)
plane_p == 10, ϵ = 0.1, other_par = 11.3)

julia> function test2(p)
       @extract p : sphere_p=sphere plane_p=plane
       @show sphere_p
       @show plane_p
       end
test2 (generic function with 1 method)

julia> function test2(p)
       @extract p : sphere_p=sphere plane_p=plane
       @show sphere_p
       @extract sphere_p : sphere_alpha=α
       @extract plane_p : plane_alpha = α
       @show sphere_alpha
       @show plane_alpha
       end
test2 (generic function with 1 method)

julia> test2(ransacpars);
sphere_p == 5, ϵ = 0.05)
sphere_alpha = 5
plane_alpha = 10

julia> newshape_par = (newshape=new_shape)
(α = 1, ϵ = 15, oth = "A")

julia> newshape_par = (newshape=new_shape,)
(newshape == 1, ϵ = 15, oth = "A"),)

julia> merge(ransacpars, newshape_par)
(plane == 10, ϵ = 0.1, other_par = 11.3), sphere == 5, ϵ = 0.05), iterations = (maxit = 100, p = 0.99), newshape == 1, ϵ = 15, oth = "A"))

@cserteGT3
Copy link
Owner Author

Implemented in #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant