10

I'm trying to model a snake, which I can do very basically if I do it manually, first getting the x,y coordinates from image tools, then guessing z coordinates (using @J. M.'s ennui 's plotTube function (though it won't seem to accept Piecewise):

pts2 = {{1, 5.5, 2}, {2, 5.5, 2}, {3, 6, 1}, {4, 6, 0}, {5, 
6, -2}, {4, 7, 2}, {5, 7, 3}, {7, 7, 2}, {5, 5, 1}, {2, 4, 0}, {4,
 3, -2}, {6, 6, -3}, {5, 8, 1}, {6, 9, 4}, {9, 7, 3}, {7, 4, 
0}, {8, 3, -1}, {10, 4, -2}, {9, 5, 0}, {9, 3, 2}, {8, 1, 0}, {6, 
2, 0}, {5, 2, 0}};
c1 = RGBColor[#/255, #2/255, #3/255] & @@ {142, 189, 61};
c2 = RGBColor[#/255, #2/255, #3/255] & @@ {208, 218, 61};
g = Graphics[{c1, Thickness[.5], Line@{{0, 0}, {1, 0}}}, 
Background -> c2, PlotRangePadding -> 0];
f = BSplineFunction[pts2, SplineDegree -> 4];
Import["https://upload.wikimedia.org/wikipedia/en/5/5e/Trimeresurus_\salazar.jpg"]
Show[plotTube[
   f[t], (3 (1 - .1^5) + (t^.25 - .1^.25) (3 (1 - .1^5)/.1^.25)) circ@
    u, {t, 0, .1}, {u, 0, 2 \[Pi]}, PlotPoints -> 200, 
  ImageSize -> Medium, ViewPoint -> {1, -.2, 3}, 
  ViewVertical -> {.1, 1, 0}, Mesh -> False, Boxed -> False, 
  Axes -> False, PlotStyle -> Texture[g], 
  TextureCoordinateScaling -> True, 
  TextureCoordinateFunction -> Function[{x, y, a, b}, {a, 20 b}], 
  PlotRange -> All], 
 plotTube[f[t], 3 (1 - t^5) circ@u, {t, .1, 1}, {u, 0, 2 \[Pi]}, 
  PlotPoints -> 200, ImageSize -> Medium, ViewPoint -> {1, -.2, 3}, 
  ViewVertical -> {.1, 1, 0}, Mesh -> False, Boxed -> False, 
  Axes -> False, PlotStyle -> Texture[g], 
  TextureCoordinateScaling -> True, 
  TextureCoordinateFunction -> Function[{x, y, a, b}, {a, 180 b}], 
  PlotRange -> All], Background -> Black, PlotRange -> All]

But I'd really like MMA to suggest 3d coordinates from image detection tools. Tried all sorts, but manually was quickest for me, albeit basic.

martin
  • 8,678
  • 4
  • 23
  • 70
  • 3
    Here's a few neural nets that estimate this sort of thing: https://resources.wolframcloud.com/NeuralNetRepository/resources/Single-Image-Depth-Perception-Net-Trained-on-NYU-Depth-V2-Data/ https://resources.wolframcloud.com/NeuralNetRepository/resources/Single-Image-Depth-Perception-Net-Trained-on-Depth-in-the-Wild-Data/ https://resources.wolframcloud.com/NeuralNetRepository/resources/Single-Image-Depth-Perception-Net-Trained-on-NYU-Depth-V2-and-Depth-in-the-Wild-Data/ – Greg Hurst Mar 09 '21 at 18:37
  • What is the problem here? Do you try to reproduce image in 3D by adjusting parameters of your model or you asking about 3D coordinates of snake image? – Alex Trounev Mar 12 '21 at 12:16
  • @Alex Trounev yes, I'd like mathematica to suggest 3d coordinates from original image, given that the basic structure of the snake is known – martin Mar 12 '21 at 14:42

0 Answers0