Shop OBEX P1 Docs P2 Docs Learn Events
Image Parsing using the Propeller ( C or Spin ) — Parallax Forums

Image Parsing using the Propeller ( C or Spin )

ValeTValeT Posts: 308
edited 2015-04-17 10:07 in Propeller 1
In my CS class, I am working on an independent study to make a "smart" robot for the FTC competition. I am *hoping* to use some vision sensor to grab images and parse through them. This got me thinking....Could I use the Propeller to parse through images? I am thinking though that it might take too much computation or too much memory for the Propeller to actually be useful ( parsing at least 1 frame per couple of seconds ).

Anyone done this before or worked on it?

Comments

  • KyeKye Posts: 2,200
    edited 2015-03-11 17:27
    http://www.cmucam.org/boards/7/topics/2072

    The CMUcam4 can be used to grab grey scale 128x96 images and store them in RAM with this firmware.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2015-03-11 18:29
    You might also consider the PropCAM. Here's a thread that details some image-processing software that I wrote for it:
    -Phil
  • banjobanjo Posts: 447
    edited 2015-04-15 08:35
    Is there any C code for the PropCam? Searched the OBEX and the forum but did not find any.
    If not, is it possible to run Spin and C in parallel on the Propeller Activity Board? E.g. using Spin to grab an image and then C for everything else on the ActivyBot, Ping, XBee, servos etc.

    My scenario is that I'd like to grab an image through PropCam, if needed save it to a SD-card, and send the image through XBee Wi-Fi (later perhaps XBee Pro HP) to a laptop or iPad. I'm fully aware it won't be fast with 9600 Baud, so any kind of tele-presence.

    Do note that I have only the DB-expander, the Propeller Backpack was not available when I bought the PropCam and seems to still be out of stock at my favourite seller (Parallax).

    Edit: What about spin2cpp, would that be able to turn Phil's Spin-code, drivers etc. to usable C?
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-04-15 16:13
    banjo wrote: »
    Is there any C code for the PropCam? Searched the OBEX and the forum but did not find any.
    If not, is it possible to run Spin and C in parallel on the Propeller Activity Board? E.g. using Spin to grab an image and then C for everything else on the ActivyBot, Ping, XBee, servos etc.

    My scenario is that I'd like to grab an image through PropCam, if needed save it to a SD-card, and send the image through XBee Wi-Fi (later perhaps XBee Pro HP) to a laptop or iPad. I'm fully aware it won't be fast with 9600 Baud, so any kind of tele-presence.

    Do note that I have only the DB-expander, the Propeller Backpack was not available when I bought the PropCam and seems to still be out of stock at my favourite seller (Parallax).

    Edit: What about spin2cpp, would that be able to turn Phil's Spin-code, drivers etc. to usable C?

    spin2cpp is definitely the way to go. Start with that and then use your own intellect to enhance the output. Spin2cpp is awesome, but it isn't perfect and has no comprehension of "good" code. For instance - it's going to take the assembly and create a binary blob instead of a separate assembly file. My recommendation would be to copy/paste the DAT section into a *.S file.

    Also, be sure to use C++ (classes) not C. Spin uses objects and there's no reason to undo that hard work.

    In case you haven't found it yet, I list 3 different options for reading from an SD card with C/C++ in this post.
  • banjobanjo Posts: 447
    edited 2015-04-15 22:22
    Thx, I'll give spin2cpp a try.

    So it's 'impossible' to run Spin and C/C++ in parallel then?
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-04-16 04:28
    Not impossible. I don't remember how though. Hopefully someone who does will chime in
  • RaymanRayman Posts: 14,666
    edited 2015-04-17 06:23
    I've been thinking about how to do this with my new Manta board (coming soon). It has a SSD1921 image processor that can acquire images from a camera module easily.
    But, I think the Propeller may be too slow to do much processing with it.
    Still, I'm wondering if you could dumb the image down to very low resolution and then maybe it could be used as a line follower.

    What might be better is to send the image data to an Edison module over hardware, or send it to a real computer over wireless to analyze and send back instructions.
    The SSD1921 can also compress the image to jpg, so that might help to increase the transfer rate to the external processor...

    I have a dream of turning my Manta board into a line following robot one of these ways. May never get the time, but I can dream about it anyway...
  • ersmithersmith Posts: 6,054
    edited 2015-04-17 09:54
    spin2cpp is definitely the way to go. Start with that and then use your own intellect to enhance the output. Spin2cpp is awesome, but it isn't perfect and has no comprehension of "good" code. For instance - it's going to take the assembly and create a binary blob instead of a separate assembly file. My recommendation would be to copy/paste the DAT section into a *.S file.
    spin2cpp does have a --gas option to convert the DAT assembly to GCC assembly. But you're right that no tool is perfect, and it's good to review the output (and perhaps manually tweak it).

    David Betz also wrote a tool (called spinwrap) to allow the use of Spin code directly from C. IIRC it starts a Spin interpreter in another COG. I haven't used it myself, but it might be worth looking in to -- David certainly knows what he is doing. The URL is: https://github.com/parallaxinc/spinwrap.


    Eric
  • banjobanjo Posts: 447
    edited 2015-04-17 10:07
    Sweet, more options to look into, thx! I'll try to make time for trying spin2cpp and spinwrap this weekend.
Sign In or Register to comment.