Shop OBEX P1 Docs P2 Docs Learn Events
Spinneret + PropCAM == WebCam (User Pannable) — Parallax Forums

Spinneret + PropCAM == WebCam (User Pannable)

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2012-11-30 14:51 in Accessories
Remember the PropCAM, that forever-in-gestation, never-produced thing I came up nearly five years ago? Well, it's got a new use. Through consultation with and cooperation from David Carrier in the Spinneret's design, plus some extraordinary good luck, it turns out that the PropCAM will plug into the Spinneret's daughterboard connector almost without modification. Here are the details:

1. Consultation and cooperation: On the Propeller Backpack, the daughterboard pins connect to dedicated ports. There were not enough unused ports left over on the Spinneret to do this, though. Through consultation with David at Parallax, it was decided to bring A24 through A31 out to the daughterboard connector on the Spinneret, in that order. A28 and A29 are shared with the EEPROM's SCL and SDA pins, and A30 and A31 are shared with the PropPlug when it's plugged in. At my suggestion, all four of these are pulled up to Vdd, to correspond to similar pull-ups on the Propeller Backpack (and MoBoStamp-pe).

2. Good luck: The PropCAM is controlled via I2C; and, when plugged into the Spinneret, its SCL and SDA pins just happen to coincide with those of the EEPROM. Since the sensor chip uses a different address from that of the EEPROM, there's no conflict. This pinout is actually derived from that of the MoBoStamp-pe, whose P0/P1 and P8/P9 I2C pins are in the same position. The pin order on the Prop -- completely by accident AFAIK -- is a perfect match. I love it when things work out this way!

3. Almost without modification: The PropCAM was originally designed to operate in parallel mode only, using the four MSBs of the sensor's D7..D0 outputs, resulting in 16 gray levels. Because of its required 10 MHz dot clock, that entailed connecting D7..D4 to A3..A0 on the Prop, so the data could be read in and shifted in two instructions. For this reason, the Propeller Backpack's daughterboard connector epxresses A0 through A7. After trying in vain to read and shift A27..A24 in two instructions, I almost gave up. But then I remembered that the sensor also has a serial mode, wherein one bit of data is output on D0, while D7..D2 are tri-stated. So I connected a 680R resistor between D0 and D4 to be able to read the bit on A24. That's all it took, plus some program mods to read the serial data stream. Here's the inner read loop that packs eight four-bit nybbles into each of the 16 longs that make up a scan line:
:line         waitcnt   time,interline
              movd      :save_acc,#line_buf
              mov       long_ctr,#16
              jmp       #:long_lp

:pre_nyb      nop                               'b2
              nop
              nop                               'b1
              nop
              nop                               'b0
              jmp       #:nyb_lp

:long_lp      mov       nyb_ctr,#8

:nyb_lp       test      inpmask,ina wc          'b7
              rcl       acc,#1
              test      inpmask,ina wc          'b6
              rcl       acc,#1
              test      inpmask,ina wc          'b5
              rcl       acc,#1
              test      inpmask,ina wc          'b4
              rcl       acc,#1
              rol       acc,#24                 'b3
              djnz      nyb_ctr,#:pre_nyb
                                                'b2
              rol       acc,#4                  
:save_acc     mov       0-0,acc                 'b1
              add       :save_acc,_0x200        
              djnz      long_ctr,#:long_lp      'b0

Here's a photo of the "SpinneretCAM" at work:

attachment.php?attachmentid=78511&d=1298189815

You can see what it's looking at by going to:

I'll leave it running overnight and possibly into tomorrow. (Hopefully Browser won't mess with it while I'm asleep.) Please let me know of any glitches you encounter. BTW, the native image size is 128 x 96 pixels. The webpage displays it at 200%.

I'm glad that I had not gone into production with the PropCAM, since I can now add the needed resistor to the board layout! Maybe I'll even have a batch made! :)

-Phil
648 x 486 - 81K
«1

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-02-20 06:15
    Darn... the request timed out. I'd like to be in line for a PropCAM if you make a production run.
  • kf4ixmkf4ixm Posts: 529
    edited 2011-02-20 06:29
    Oops! Google Chrome could not find phipi.dyndns.org:3456
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-20 09:28
    Oh Smile! I posted the wrong address. (It was past my bedtime.) DynDNS is the outfit that provides the DNS service. I've edited the original post with the correct address.

    -Phil
  • Mike GMike G Posts: 2,702
    edited 2011-02-20 10:06
    Now I'm getting an "Unable to Connect" error with Firefox.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-20 10:23
    It hung, so I reset it. Try it now. BTW, it's pointed outdoors, but I need to find something more interesting to look at.

    -P.
  • Mike GMike G Posts: 2,702
    edited 2011-02-20 10:27
    There we go... worked
  • BeanBean Posts: 8,129
    edited 2011-02-20 10:57
    Phil,
    It worked fine for me.
    Very cool. What's become of the PropCam ?

    Bean
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-20 11:38
    Bean wrote:
    What's become of the PropCam ?
    As I stated above, I'm glad I didn't go into production with them without the extra resistor in the layout. Finishing it is not the path of least resistance, I'm afraid. Among the issues:

    1. The sensor chip has been discontinued. I have 1500 of them, and could do a limited edition, though. I'm also discussing with another sensor company the possibility that they could obtain an IP license from Kodak to produce it again. (Kodak bought it from National Semiconductor.)

    2. The sensor chip package is a ceramic LCC -- not the easiest thing in the world to solder and get centered properly. And they need to be baked for awhile prior to soldering. Finding an assembly house to try it, without committing the whole inventory and then finding out they can't, seems a bit daunting.

    3. There's a lot of software that still needs documenting, which means trying to figure what I wrote nearly five years ago. Ugh!

    4. I'm in a virtual orchard of much lower-hanging fruit right now. I'm also lazy. :)

    Those are really lame excuses, aren't they?

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-20 13:16
    I realized that, in broad sunlight, the picture was getting washed out. This was because I was using shutter-time-only autoexposure. I've modified the programming to include the sensor's gain setting in the loop, and things look better. BTW, here's a better photo of the Spinneret+PropCAM setup:

    attachment.php?attachmentid=78532&d=1298236587

    -Phil
    459 x 593 - 47K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 19:35
    I've mounted the SpinneretCAM on a servo for panning. Users who access it can now control both the pan position and the camera's brightness control. I've got the camera mounted in my shop, so you can look around at the mess (assuming there's enough light). Here's how the camera is mounted now:

    attachment.php?attachmentid=78664&d=1298604853

    To access it, go to: http://phipi.homelinux.org:3456

    -Phil
    571 x 728 - 91K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 20:25
    Just a note about the user-settable brightness and pan positions:
    Each client has it's own settings for these values. They are returned to the user's browser in hidden input tags. If you examine the HTML source, you can see them. So when you change one of these values, it's changed relative to the last value that you set, not that of someone else who visited the site since your last visit. But I discovered that sometimes, when person A requested a change, immediately followed by person B, that person B's settings would override person A's before person A's image was retrieved. So I modified the link to the image to include the brightness and pan position information. You can see that in the <img> tag. Hopefully it now works as if each client has an exclusive connection irrespective of what other clients are doing simultaneously.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-24 20:35
    And another thing:
    When serving dynamic content, such as webcam snapshots, it's import that the HTTP header for the image data include this line:

    Cache-Control: no-store

    This prevents the browser from being lazy and serving up images that it had retrieved previously.

    -Phil
  • Ding-BattyDing-Batty Posts: 302
    edited 2011-02-24 20:48
    Cool! My Spinnernet is supposed to arrive tomorrow, so I finally get to play too!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-25 08:22
    The camera hung during the night, so I added a timeout to the request method. I also notice that, even though the images were not supposed to be cached, my browser (Opera) would display an old version of the image until the new version was loaded from the camera. To combat what could be a confusing display, I've added the view number to the image src address. That way, no two images have the same address, and the browser no longer displays old images while waiting for a new one.

    -Phil
  • RavenkallenRavenkallen Posts: 1,057
    edited 2011-02-25 14:19
    Is that really live? Like i am actually controlling your camera? That is the coolest thing ever. I saw you sitting next to your computer and you stuck you tongue out at me:) If i didn't have a reason to buy the spinneret before, i sure do now... That is so cool!!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-25 14:25
    Yup, it's live! You're controlling the panning and the exposure value.

    -Phil
  • $WMc%$WMc% Posts: 1,884
    edited 2011-02-25 17:52
    Yup, it's live! You're controlling the panning and the exposure value.

    -Phil
    '
    This is really cool.
    '
    How do we get a PropCam?
    1024 x 771 - 73K
  • RonPRonP Posts: 384
    edited 2011-02-25 18:29
    That's Super Cool stuff Phil. :cool:
    How do we get a PropCam?

    I second the above question.

    -Ron
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-25 18:53
    How do we get a PropCam?
    Ah, the perennial question. I'll have to get some made, I guess. Again, I'm very glad that -- despite the encouragement, cajoling, and attempts to embarrass me over the years -- I did not have any made yet, as they would not have worked with the Spinneret. I've got a more pressing project to clear with my board assembler first, before turning them loose on the PropCAM. But, in the meantime, I can get some proto boards fabbed with a new layout. Unfortunately, the boards cannot be offered as a kit, since the sensor chips are nearly impossible to solder by hand. (I have to use a milled positioning jig, just to get them centered correctly for proto assembly.)

    -Phil
  • $WMc%$WMc% Posts: 1,884
    edited 2011-02-25 20:49
    Ah, the perennial question. I'll have to get some made, I guess. Again, I'm very glad that -- despite the encouragement, cajoling, and attempts to embarrass me over the years -- I did not have any made yet, as they would not have worked with the Spinneret. I've got a more pressing project to clear with my board assembler first, before turning them loose on the PropCAM. But, in the meantime, I can get some proto boards fabbed with a new layout. Unfortunately, the boards cannot be offered as a kit, since the sensor chips are nearly impossible to solder by hand. (I have to use a milled positioning jig, just to get them centered correctly for proto assembly.)

    -Phil
    '
    Mr Pilgrim:
    '
    I find your inventions to be Brillant to say the least.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-25 20:57
    Thanks. [blush] But, geez, I'm not old enough (yet) to be "Mr. Pilgrim". :)

    -Phil
  • WolfbrotherWolfbrother Posts: 129
    edited 2011-02-26 22:01
    I'd be interested in the propcam as well. I'm doing a new sculpture where I need to take a photo, interleave it with recent photos and play them back on a continuous stream. I think the propcam would work pretty well for that.

    BTW I just logged onto your site and saw you looking at me. It was like a bizarre version of skype without being able to at least say hello.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-02-26 22:40
    Yeah, it's kinda weird on my end, too. If I hear the servo or see the camera flashing its LEDs, then stick my tongue out, I have no idea who's receiving the benefit of my adolescent humor. :)

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-26 13:23
    I've upgraded the Spinneret webcam from a gray-level depth of four bits (16 values) to six bits (64 values). Here's a side-by-side comparison of the two:

    attachment.php?attachmentid=81502&d=1306441220

    The image from the PropCAM is packed in memory as five six-bit pixels per long. The entire 128x96-pixel image requires 9984 bytes of hub RAM. It's displayed on the webpage at 3X scale.

    With the new website, you can also adjust the gamma of the display to 0.5 (brightens dark stuff), 1.0 (normal linear scale), or 2.0 (darkens dark stuff). The camera can be accessed here:

    Please let me know if it gives you any trouble.

    Thanks,
    -Phil
    750 x 288 - 84K
  • Mike GMike G Posts: 2,702
    edited 2011-05-26 19:35
    Very cool Phil. No problems on my end.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-26 20:56
    Thanks, Mike! This still uses my one-socket Javascript image loader. I've followed your multi-socket escapades to some extent. Do you have a multi-socket replacement yet for the BrilIdea driver that's 100% reliable?

    Thanks,
    -Phil

    P.S. BTW, are you this Mike G?
  • Mike GMike G Posts: 2,702
    edited 2011-05-27 09:11
    Not the same Mike G lol

    Yes and no on the multi-socket. The request piece is published and working. I hit the request logic hard with Apache Bench. Well, over 40,000 requests with 2, 3 and 4 concurrent users. 5 concurrent users would cause a timeout somewhere after 8,000 requests but the server stayed up.

    There are two other pieces in development; processing (kinda' done just not wired up) and the response logic. The idea is to move the request logic and the response logic out of the main web server object. That way end users can place custom processing code in top web server object but have access to a request and response objects (header stuff).

    BUT, you still only have 4 sockets. Right now the web server is online serving up request using 3 sockets. I know that you were able to consistently reproduce issues downloading images. Please, give it a shot.
    http://spinneret.servebeer.com:5000/index.htm

    Did I muddy that up enough?
  • MicksterMickster Posts: 2,693
    edited 2012-11-30 06:24
    Did the PropCAM ever materialize?

    I have a machine vision project and would like to consider something Prop-based. Are there any other similar developments?

    Regards,

    Mickster
  • PublisonPublison Posts: 12,366
    edited 2012-11-30 07:53
    There is the Propeller based CMUcam4:

    http://www.cmucam.org/projects/cmucam4

    I
    t's now available at Robotshop.
  • MicksterMickster Posts: 2,693
    edited 2012-11-30 14:51
    Looks great!

    Thank you.

    Regards,

    Mickster
Sign In or Register to comment.