1. Dismiss Notice

Image to Track Generator

Discussion in 'Tracks' started by zeke15, Feb 3, 2018.

  1. zeke15

    zeke15 Well-Known Member Official Author

    I actually don't know c++. I know matlab, Java, and JS. Only reason I did this is we just discussed image processing in one of my labs and I realized it would be suppperrrr easy in matlab.
  2. zeke15

    zeke15 Well-Known Member Official Author

    Well I guess its a good thing I probably wont be uploading much with it. Maybe a couple troll tracks from pics of other members XD
  3. bungo

    bungo Well-Known Member

    They are all used in the real world. Plus Python is my city
  4. ShadowEagle

    ShadowEagle Well-Known Member Official Author

  5. octo

    octo Well-Known Member

    raw x86 is really the best for this type of thing
  6. zeke15

    zeke15 Well-Known Member Official Author

    Matlab was pretty simple because it imports images as an array of 8-bit unsigned integers by default. Convert to black and white and you just end up with a single row in the array. Enough that it is hella easy to determine color and draw a track based of that. I went for drawing lines across the image rather than pixels so it was a bit more complex, but doing pixels is hella easy.
  7. x86

    x86 Member

    A long time ago I examined the "classic" image to track converter, the one that was by MaxwellNurzia, written in python, and taken down eventually. It wasn't very fast and had a few bugs (namely one that forced the image to be rendered left to right, not up to down). After writing a few "line art" demos in golang, I wrote a new image converter in C++ as a demo, and quickly made it into a library for interacting with tracks. That's why the demo tracks I put out vary a lot, because my API has facilities for vector art and raster art. It didn't take long to write, the track code is pretty simple once you figure out how it works.
    Anyway, from my experience, C++ is just the best for this type of thing. One of the only reasons that the FRHD's javascript online app works so well for general purpose tracks is because the map is represented in terms of sectors (similar to Minecraft's "chunks"). However, in terms of performance with more dense tracks (like image converted ones), this method doesn't work out the best. And even then, the app is locked at 30fps so that can give you a good idea of the efficiency of this way.
    So basically what I'm getting at is that if you want a fast image to track converter, you really need to do it in a close-to-the-metal language, like C++ or even better, C. I don't know about MATLAB, but hearing about "8-bit unsigned integers" is a good sign in terms of how performant it is. Python and even GoLang are too slow in this respect. However, if it floats your boat, you can use those languages, but keep in mind that your track-making pipeline will bottleneck at image to track conversion, and not loading the tracks into FRHD like is is for me.

    And octo believe it or not, there is some handwritten x86 assembly in the library I use for the image parsing. (but I didn't write it because I'm an x86 noob)
    IsaiahRed, DeathBob1, zeke15 and 2 others like this.
  8. driveslow

    driveslow Active Member Official Author

    x86 I was wondering what `GameSettings.developerMode = true` was for without actually caring enough to ask char. Is that a representation of the the sector system you're talking about? I thought about writing a node app to convert vector.svg into track_code but never got around to it.
  9. zeke15

    zeke15 Well-Known Member Official Author

    THats a little beyond my understanding but I get where you're going. Vector graphics is for sure the way to go. Mine renders up to down right now, I could easily change it to do side to side or theoretically along any parallel axis through axes rotations. The only way I made mine decently fast was to render groups of pixels as lines rather than single pixels.

    MATLAB (Matrix Laboratory) is a matrix based coding language that was originally designed to be fast with mass linear algebra calculations. Its used a lot for large data processing, not necessarily for front end or even complex workloads. I only used it because I have to for my engineering classes at college.

Share This Page