HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Thu Sep 21, 2017 10:13 am

For a minimalist Pi Zero (W) mobile project I needed to mount v1 camera firmly on Pi Zero. The screw hole spacings on camera and Pi Zero did not match, but were not that much distinct. I tried to screw two small screws diagonally and was successful in getting firm mount:
Image

The advantage of mounting on top of CSI-2 connector is, that the plastic connector avoids any electric shortcuts between camera and Zero boards. I thought this might be useful to have for others as well,

Hermann.
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

User avatar
RaTTuS
Posts: 9895
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Thu Sep 21, 2017 10:30 am

use imgur.com to post images
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Thu Sep 21, 2017 10:36 am

> use imgur.com to post images
>
Why? I used twitter links to images I posted there, and they disappeared after some time. I can be sure that images will not disappear and produce broken links when hosted on my own website.
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

User avatar
RaTTuS
Posts: 9895
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Thu Sep 21, 2017 10:44 am

ok use better images as that is just a blur to me
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Thu Sep 21, 2017 12:17 pm

> ok use better images as that is just a blur to me
>
Fair point. I thought the image was the best I could get because I did not know how to use the 5MP camera of my new Android phone. Therefore I used previous 3MP Android phone camera without better images. Finally I used a firmly mounted Raspberry v1 camera and soldering 3rd hand, but the problems remain. This is the best I can get with v1 camera, no idea how to get a better focus on the scene:
Image

As said, the whole story is just about using small screws diagonally to make screw hole spacings fit for a firm mount.
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

User avatar
DougieLawson
Posts: 32670
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Sat Sep 23, 2017 8:21 am

You need to get your camera serviced, the focussing system on it is very badly broken. Nothing you've posted on here is in focus.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Sun Sep 24, 2017 1:31 pm

I continued the minimalist way, the 9x1 ILI9341 to 4x2 Pi Zero connector as well as how to stream from Pi camera v1 to 320x240 TFT is described in this posting:
viewtopic.php?f=63&t=157618&p=1214626#p1214626

I just added a single M3 screw to connect the ILI9341 display to Pi Zero. To my surprise the screw hole of Pi Zero was so tight, that no screw nut was needed for firm connection. And I added a rubber band for fixating a 1200mAh LiPo, which gets connected to pin 02 5V and pin 06 GND.

This is the display side view of streaming Pi Zero:
Image

This is camera side view:
Image

Starting streaming on bootup is done in /etc/rc.local:

Code: Select all

pi@raspberrypi:~ $ tail -5 /etc/rc.local 
fi

/home/pi/stream.fb1 &

exit 0
pi@raspberrypi:~ $ cat stream.fb1 
#!/bin/bash
sudo modprobe fbtft_device name=rpi-display gpios=reset:25,dc:24,led:27 rotate=90
sleep 1
sudo tail --bytes 153600 /home/pi/giraffe.565 > /dev/fb1
sudo modprobe bcm2835-v4l2
sleep 2
sudo gst-launch-1.0 -v v4l2src device=/dev/video0 do-timestamp=true ! video/x-raw,width=320,height=240 ! videoconvert ! fbdevsink device=/dev/fb1 2>&1 >/dev/null
pi@raspberrypi:~ $ 
I will use this device for live testing of gstreamer plugins as well as raspiraw modifications
viewtopic.php?t=189661
for line detection in images like this:
Image

Hermann.

P.S:
Turning behavior surprised me first:
https://www.youtube.com/watch?v=v9k0_Ou ... e=youtu.be
Image
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Mon Sep 25, 2017 4:47 pm

For simply testing edge detection I setup a stationary scene, with USB2ethernet allowing to ssh into Pi Zero. I inserted "edgetv" gstreamer plugin just before videoconvert into above gstreamer pipeline:

Code: Select all

...ight=240 ! edgetv ! videoconvert ! fb...
On top half you can see the result, bottom half is just for comparison (right click for zoom):
Image

Next step is to make raspiraw stream to /dev/fb1 instead of storing on SD card,

Hermann.
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Mon Sep 25, 2017 9:29 pm

The camera ribbon cable can be bended and stored below rubber band. This reduces vertical size by a quarter and allows to take pictures just above ground like a robot mounted camera will do later:
Image

I took an outdoor youtube video of edge detection:
https://www.youtube.com/watch?v=5yAsjLe ... e=youtu.be
Image

Edge detection seems to be what I need to determine borders of sidewalk for autonomous caterpillar robot driving 900m round around our house (30fps full HD video taken long ago with joystick controlled caterpillar robot mounted Raspberry v1 camera):
https://www.youtube.com/watch?v=slxG7Y09XXE&t=57s
Image

Hermann.

P.S:
edgetv gstreamer module might be useful for linefollowing robot as well:
https://www.youtube.com/watch?v=moj6aR8 ... e=youtu.be
Image
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Mon Oct 02, 2017 8:38 pm

I realized that the 4th corner screw hole of Pi Zero was still unused and tried to connect and use a 2nd display. A second M3 screw allowed to do that, this is back view showing both displays just after bootup with "/dev/fbi" framebuffer indicators:
Image

First I learned how to connect a ili9341 display to SPI1 instead of SPI0 in this posting:
viewtopic.php?f=44&t=22608&p=1216154#p1216154

Then it was not that easy to drive two displays with Pi Zero because the "sudo modprobe fbtft_device ..." method allows for one framebuffer only. I asked and got great help from DirkS on how to use device tree overlay to bring up one display during boot in this thread:
viewtopic.php?f=63&t=194423

Here you can see front view. As you can see I superglued a 2nd 2x4+1 Pi Zero SPI to 9x1 ili9341 connector:
Image

On pins 33-40 there are two GND and no 3V3. Therefore I used 7 male pins on the Pi side, and a female connector on pin 34 which therefore has no connection to GND and is just there for the compact 2x4 form factor. I soldered a small cable to it on the side, connecting with 3V3 on pin 01.


In the thread where I got help from DirkS you can find the device tree overlay I created for the first ili9341 display connected to SPI0. These are the relevant lines of "/boot/config.txt":

Code: Select all

...
dtparam=spi=on
dtoverlay=spi1-3cs
...
dtoverlay=rpi-displa0
dtparam=rotate=90
...
The first two lines enable SPI, and enable SPI1 interface with 3 chip select lines. Then the dtoverlay and dtparam lines enable first display on SPI0.


The last lines of "/etc/rc.local" show how the display startup works, especially how the 2nd display on SPI1 gets stared, and how gstreamer pipeline gets started:

Code: Select all

pi@raspberrypi:~ $ tail -11 /etc/rc.local 
fi

tail --bytes 153600 /home/pi/fb1.565.bmp> /dev/fb1

sleep 1
sudo modprobe fbtft_device name=rpi-display gpios=reset:13,dc:26,led:28 rotate=270 cs=2 busnum=1
tail --bytes 153600 /home/pi/fb2.565.bmp> /dev/fb2

sudo gst-launch-1.0 -v v4l2src device=/dev/video0 do-timestamp=true ! video/x-raw,width=320,height=240,framerate=10/1 ! tee name=t ! queue ! edgedetect ! videoconvert ! fbdevsink device=/dev/fb1 t. ! clockoverlay shaded-background=true font-desc="Sans, 48" ! videoconvert ! fbdevsink device=/dev/fb2 2>&1 > /dev/null

exit 0
pi@raspberrypi:~ $ 
For the gstreamer pipeline to work, v4l2 module needs to be loaded during boot:

Code: Select all

pi@raspberrypi:~ $ tail -1 /etc/modules-load.d/modules.conf 
bcm2835-v4l2
pi@raspberrypi:~ $ 
That is all, the gstreamer pipeline uses two plugins in order to create two views on the two displays of the video taken from v1 Raspberry camera. On left display you see the video with clockoverlay plugin, on the right you see edge detection plugin "edgetv" at work. "tee" plugin allows to do both in same pipeline:
Image

Of couse the 2nd display can be used differently, eg. for displaying statistics of the video from first display.

Hermann,
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Mon Oct 23, 2017 12:56 pm

I gave a 5min lightning talk on this at GStreamer 2017 conference in Prague on Saturday, audio and slides here:
https://twitter.com/HermannSW/status/922243947606487045
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

HermannSW
Posts: 672
Joined: Fri Jul 22, 2016 9:09 pm

Re: Minimalist firm camera mount "on" CSI-2 connector of Pi Zero (W)

Tue Oct 24, 2017 6:18 pm

Just posted thread "Smartphone as terminal for Pi Zero(!)":
viewtopic.php?f=36&t=196057

I used that technique for this thread's debugging device as well, see the posting for details.
This is photo combined with smartphone screenshot for sharpness.
The minimal setup is nice by its simplicity:
Image
--> Raspberry camera / gstreamer / raspivid / raspiraw (bookmark list):
https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/fork-raspiraw      https://github.com/Hermann-SW/userland      https://twitter.com/HermannSW

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 17 guests