3d cam with mobile phone as viewfinder and controller

3D photo and video processing questions
User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

3d cam with mobile phone as viewfinder and controller

Post by stereomii »

I am an ethousiastic 3D Photographer and Cineast. I own a Fuji W3 stereocamera with which I made lots of picures and video's. Since it became clear that Fuji dropped 3D I searched for alternatives. StereoPi seems promising. The more because I own several Raspberry Pi's and use them as home server, camera server (with "motion" package) and energy monitor.
Last week I received my StereoPi DeLuxe kit. The supplied SLP image looks like a good starting point to realise my first objectives for a setup to enable the following:
1. Have a robust portable 3D camera
2. Use my mobile phone as viewvinder and controller
The first objective can be reached with a 3D-printed case (found on the wiki) and a suitable powerbank to run theb system from. I found an 8000 mAh bank that can deliver 2.4 A. This can provide over 10 Hours of power for the system (as the system mostly uses 700 to 800 mA).
Out of the box I can use my phone via the webinterface to view the images from the cameras and to turn recording on and off via the settings. I will try to find a way to provide an extra button and indicator to start/stop recording (help most appreciated).

I prepared a 16Gb SD-card with the SLP image, extended partition 2 with an extra 2 Gb to be able to install extra software if needed, and added a third FAT32 partition to store recordings.
My Samsung S8 is able to tether its WiFi connection so I use its hotspot to connect the StereoPi's WiFi. I also can use my laptop to connect to this hotspot. The SLP image has cifs installed so I am also able to connect a shared folder on my laptop to the StereoPi. This comes in handy for transferring recordings from StereoPi to laptop.

Upon boot the SLP image reformats the FAT32 partition and deletes all recordings. To avoid this I had to comment out a statement in (/etc/rc-local, 20190514 correction) /opt/StereoPi/run.sh .

* SSH into the StereoPi
* remount / as read/write

Code: Select all

	root>mount -o rw,remount /
* start mc and navigate to /opt/StereoPi
(this is also a good opportunity to set mc options as "use internal editor" and "always pause after a command" and save them since the root filesystem is read/write now)
* navigate to run.sh and (F4 or esc followed by 4) open it for editing
* find the next lines:

Code: Select all

	if [ "$?" != "0" ]; then
		echo "Record partion not found"
		echo "Creating new FAT32 partition"
		sudo echo -e "n\np\n3\n3932160\n\nt\n3\nc\nw\n" | fdisk /dev/mmcblk0
		reboot
	else
		sudo mkfs.vfat -F 32 /dev/mmcblk0p3 > /dev/null 2>&1
		sudo mount /dev/mmcblk0p3 /media > /dev/null 2>&1
	fi
comment-out the line after "else" so it reads:

Code: Select all

	#	sudo mkfs.vfat -F 32 /dev/mmcblk0p3 > /dev/null 2>&1
* Maybe it is a good idea to also create some folders under /mnt to mount a (cifs) shared folder under /mnt, fe:

Code: Select all

	mkdir /mnt/laptop
	mkdir /mnt/<any other mountpoint you might need>
* remount the root filesystem as read-only again

Code: Select all

	root>mount -o ro,remount /
(or simply reboot the StereoPi: root>reboot)

If you want to mount a folder on your Windows laptop you first have to define a folder as "full control" for Everybody, then:

Code: Select all

	mount -t cifs -o username=<user> //192.168.43.130/stereopi /mnt/laptop
(<user> : windows user name
192.168.43.130 : your laptops ip address
stereopi : the name of your shared folder)
Now you can use mc to easily transfer your recordings to your laptop
Last edited by stereomii on Tue May 14, 2019 12:22 pm, edited 1 time in total.
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

stereomii wrote:
Mon May 13, 2019 8:39 pm
Upon boot the SLP image reformats the FAT32 partition and deletes all recordings. To avoid this I had to comment out a statement in /etc/rc-local.
Hmmm... Before formatting, system checks if it is any FAT32 partition, and should not format or delete anything if partition exists. Our setups has a hundreds of reboots and all recordings are safe. May be your fixed partition size or other changed settings affects on this behavior.

As for start-stop buttons and phone-controlled 3D camera, I planned to do next article in our "The Art Of Stereoscopic Photo" series right with this purpose. :D
Eugene a.k.a. Realizator

Mr-Qu33f
Posts: 13
Joined: Mon Apr 29, 2019 12:52 pm

Re: 3d cam with mobile phone as viewfinder and controller

Post by Mr-Qu33f »

FYI, I found this powerbank which is also a wirless router and very small!
https://www.amazon.co.uk/HooToo-Wireles ... B00VBAE5Y0

its 10,400mah and highly portable. I use it when I'm travelling and have found it perfect for mobile stereopi applications
Deluxe Stereopi + CM3 lite

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Realizator wrote:
Mon May 13, 2019 9:34 pm
As for start-stop buttons and phone-controlled 3D camera, I planned to do next article in our "The Art Of Stereoscopic Photo" series right with this purpose. :D
:D Excellent :!:
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

stereomaton
Posts: 215
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomaton »

Realizator wrote:
Mon May 13, 2019 9:34 pm
Hmmm... Before formatting, system checks if it is any FAT32 partition, and should not format or delete anything if partition exists. Our setups has a hundreds of reboots and all recordings are safe. May be your fixed partition size or other changed settings affects on this behavior.
I confirm the behavior observed by stereomii. It is the same on my board.
The relevant code from /opt/StereoPi/run.sh (l.16-25) is here:

Code: Select all

df /dev/mmcblk0p3 > /dev/null 2>&1
if [ "$?" != "0" ]; then
	echo "Record partion not found"
	echo "Creating new FAT32 partition"
	sudo echo -e "n\np\n3\n3932160\n\nt\n3\nc\nw\n" | fdisk /dev/mmcblk0
	reboot
else
	#sudo mkfs.vfat -F 32 /dev/mmcblk0p3 > /dev/null 2>&1 # Commented to disable data erasing at startup
	sudo mount /dev/mmcblk0p3 /media > /dev/null 2>&1
fi
As you can see, it checks if the partition exists, but... it whether "creates it and reboots" if not existing, or "format and mount" if partition exists (regardless of previously existing filesystem, in particular the one created at the last boot). Thus data are effectively erased at boot.
Your working system does probably not have the same content as the one actually shipped.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

Well, stereomii and stereomaton, looks like it is our bug. I will check all versions we have to find release this mistake appears. After that we'll roll out an update.
Eugene a.k.a. Realizator

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

stereomii and stereomaton, Gol created an update for S.L.P. image. Can you please test it?

1. Where to download: https://wiki.stereopi.com/downloads/
2. What should you download: stereopi-0.2.2.tar.gz (2.2 Mb size)
3. How to install: put this file in BOOT partition on micro SD, reboot. Update will be installed automatically, and file will be deleted from the BOOT partition.
4. Changelog:
- FAT32 wrong partition formatting logic fixed
- "Take a photo" icon added in a web interface

Stereomii, please test "Take a photo" icon. As we trying to keep script-based solution (not binary) for others can see and change our code, there are some tricks in logic. For example, system try to kill all raspivid instances in memory, and after that runs raspistill. After raspistill finished his job, raspivid starts again automatically. It means, that if you enabled video recording, system will pause video, take a shot, and then continue recording video. I will be pleased if you can check these features, before we put our first official S.L.P. update to others.
Eugene a.k.a. Realizator

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Realizator wrote:
Thu May 23, 2019 10:19 am
stereomii and stereomaton, Gol created an update for S.L.P. image. Can you please test it?
Thank you Realizator for the update.
I just had time for a quick test, it will not be before sunday that I can test again I expect.
The results:
  • the update installs and a camera icon appears below the settings icon
  • If I click the camera icon a message "taking a photo" appears, followed bij apparently a pictuere file id ("photo[datetim].jpg", quotes from memory)
but
  • no photo can be found in the FAT partition
  • if I change anything in settings and click save nothing is saved
  • I started with recording disabled an can not record any video at all
Seems that stereopi.conf is not handled correctly by settings dialogue. I testet booting with recording enabled an found that I could not switch it off

So far my first results. Unfortunately I have no time to dig deeper now but thought it important enough to shre these first results.
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

stereomaton
Posts: 215
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomaton »

Realizator wrote:
Thu May 23, 2019 10:19 am
stereomii and stereomaton, Gol created an update for S.L.P. image. Can you please test it?
My schedule is busy these days and the coming ones, so I have not enough time to test this kind of things, sorry.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi (v1) Standard Edition + CM3Lite module + a few cameras

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Is there any way to enable logging on the S.L.P. system? I tried to start rsyslogd but this results in an error msg without starting the daemon.
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Realizator wrote:
Thu May 23, 2019 10:19 am
stereomii and stereomaton, Gol created an update for S.L.P. image. Can you please test it?
Today I had time to conduct a well documented test on the update. Starting from a fresh install of S.L.P.

Conclusion so far:
1. a camera icon appears in web interface, clicking it shows text photo-[date]-[time].jpg but no picture file appears.
2. any changes made by clicking settings-icon (followed by clicking SAVE after changes) are ignored.


This is my log of the test:

1* prepared 16Gb SD card (spi test) with SLP image from wiki (slp-raspbian-190301.img.zip) using Win32DiskImager v 1.0 in Windows.

2* backed up /opt and /var/www to 190526optwww, some symlinks not backuppd.

3* set WiFi parameters, 3D mode and decimation in stereopi.conf

4* boot stereopi, switched on brouwserstream to get preview-image in brouwser, still no preview-image,

5* refreshed browser, had to provide ip-address to connect, browser stream setting in settings disapeared. Set it again and the system reboots. after some time brouwser reconnects and now the the preview-image appears.

6* switch on recording in settings and a recording appears in /media/DCIM (viewed via SSH connection to StereoPi)

7* click SAVE in settings and a new recording appears in DCIM

8* switch recording off followed by SAVE and last recording stops growing

9* ftp'd both recordings to raspberry server, both recording are correct and play in VLC, also in stereopi web interface

10* shutdown (via SSH) stereopi and disconnected power

(I remember from first boot of the supplies 8 Gb SD card something similar happened, however did not detailed document this)

11* connect power again, boots normal, preview-image visible in browser, recording ok, recordings can be played.

12* shutdown -h now via SSH, then disconnect power

13* copied (on Windows) stereopi-0.2.2.tar.gz to first (/boot) partition on SD card

14* power-on stereopi, SHH into it, the .tar.gz file has disappeared from boot

15* start webinterface, a camera icon appears under settings icon, hovering over displays text "Make a photo". Preview-image is visible.

16* click on camera icon. A brief time some text appears, too short to read, then text "photo-20190526-193459.jpg" appears.
I now expect a file photo-20190526-193459.jpg in /media/DCIM but this is not the case.
The previous recordings are still present, inspection reveals that /opt/StereoPi/run.sh is changed so partition 3 is not formatted every boot.

17* click settings icon and toggle recording on, then click SAVE. no new recording appears in /media/DCIM . Inspection of symlink /opt/StereoPi/config.conf (->/run/sterepi.conf) shows record_enabled=0 . Clicking middle of preview screen and then settins-icon shows recording mark unset. Set video resolution fron 1280 to 1920x1080 and FPS fom 30 to 20, then click SAVE. Clicking middle of preview screen and then settins-icon shows the unchanged values. Also the original values for these parameters are shown in /opt/StereoPi/config.conf
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

Hi Stereomii,
Thank you for detailed tests!
1. I did the same clear S.L.P. installation and installed update as you do and tested Gol's update with some fixes yesterday.
2. My fixes:
"Camera" icon actually runs this script:
/var/www/make_photo.php
By default Gol puts there a very simple raspistill row:
raspistill -3d sbs -o ...
With this settings raspistill does 5 seconds preview, and after that takes a photo. I fixed it this way:
raspistill -n -t 1 -cs 1 -3d sbs ...
I added -cs 1 to swap cameras, and removed delay before taking photo.
3. Video recording was always on in my case.
4. Also I connected StereoPi to my phone's access point, and used it as a viewfinder.

My results:
1. I had browser livestream on my phone as a preview, and I used phone as a viewfinder.
2. After clicking photo icon I see "taking a photo" less that 1 second. After that I see a link with the name of photo taken. If I click it - new browser window with this photo appears.
3. When I press "photo" icon, video preview paused for ~2 seconds. Video file written at this moment also have ~2 seconds freeze, but continues recording right after shoot is finished.
4. After several reboots all photos and videos taken are at their places (not erased).

Inconveniences I faced with:
1. Settings of the video stream are not using for photo shooting. Image resolution is set at maximum for V1 camera by default (and it is Ok). But the main problem is that "flip-rotate" options are not synced, so all my taken photos was upside-down in comparison with video preview and recordings.
2. On my phone (iPhone X) only a part of the video preview is seen on the screen. I need to scroll my screen to see top and bottom of my preview.
3. Only several parts of the visible browser page are responsive to touches (for scrolling page).
4. Icons are not seen on a black background - we need to add white contours to icons.

To-dos:
1. Add white contours around icons.
2. Add implementation of flip/rotate from video settings to photo settings.
3. Fix raspistill options (add -n -t 1...)
4. Browser screen scrollability issue

Some photos
It was cloudy day at St. Petersburg, so colors are not so shine. But I was able to take about 80 photos. I also used Stereo PhotoMaker to align taken images (and recompress them with 70 quality). I used two V1 cameras (as in our Starter kit). Here are some photos from my test.

Image

Image

Image

Image

Image


And my setup:
Image

You may download 17 archived photos here: https://wiki.stereopi.com/files/2019-05-26-test.zip
Eugene a.k.a. Realizator

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Thank you Eugene for your tests. The pictures look fine.

It puzzles me that you actually get recorded pictures while in my test nothing is recorded. Maybe you used a different S.L.P. image to start with.

I used the image downloaded from the wiki some time ago, slp-raspbian-190301.img.zip as a starting point. I noticed it had a slightly lower version number than the shipped 8 Gb SD card.

Also see a line

Code: Select all

shell_exec('killall -q raspivid');
in make_photo.php

As make_photo runs as user nobody this could result in errors if some other user started those processes.

Can you give me a download link for the image you started with?
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

For our micro SD in Starter and Deluxe kits we used this image: [deleted - look at updated Wiki links for download]
Looks like I did not updated it in Wiki, I'm doing this right now. Sorry for that.
We changed file manager, and also added lock/unlock filesystem links at the top of filemenager to avoid terminal-style unlocking.
UPD> I've updated image links in our Wiki, so I deleted our temp link I posted here before.
Eugene a.k.a. Realizator

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

stereomii wrote:
Mon May 27, 2019 9:22 am

Also see a line

Code: Select all

shell_exec('killall -q raspivid');
in make_photo.php

As make_photo runs as user nobody this could result in errors if some other user started those processes.
We didn't faced a troubles with that. Bu the way, raspivid process is auto-restarted in our scripts. It was done to automatically re-enable all work if something goes wrong "in the field". So you do not need to restart it - it starts as soon as raspistill releases resources it uses for capturing photo.
Eugene a.k.a. Realizator

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Realizator wrote:
Mon May 27, 2019 11:07 am
Looks like I did not updated it in Wiki, I'm doing this right now.
Thank you for the update. Taking photo's works now. Also the problem with not updating stereopi.conf and the inability to record videos is solved with this image and the update.
Last edited by stereomii on Mon May 27, 2019 9:00 pm, edited 1 time in total.
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

stereomii wrote:
Mon May 27, 2019 9:22 am
Also see a line

Code: Select all

shell_exec('killall -q raspivid');
in make_photo.php

As make_photo runs as user nobody this could result in errors if some other user started those processes.
I am not fluent with nginx but Inspection of /etc/nginx/nginx.conf suggests that the webserver runs as user root. So my remark is not relevant
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

Stereomii, I faced with some issue while using "-t 1" option. Looks like in this mode camera has not enough time to do right settings for photo capture. It is critical in a low light conditions.
Here are two photos to demonstrate this. One taken with "-t 1" and another with "-t 1000".

-t 1
Image

-t 1000
Image

Also in my last settings I got upside-down images. It was uncomfortable to view captured photos on-the-go in a browser.
So my current row in "/var/www/make_photo.php" is:

shell_exec('raspistill -n -t 1000 -vf -hf -3d sbs -o ' . $path.$filename);

Please notice I removed "-cs 1", as these "-hf -vf" options do some tricks. :-)

So now we have enough improvements to do next update for S.L.P., and I plan to write next article in "The Art of Stereoscopic Photo" series.
Eugene a.k.a. Realizator

User avatar
Realizator
Site Admin
Posts: 912
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by Realizator »

Well, in my previous post there were two test photos with a bad quality.
Here is a good one to add more aesthetic to this thread :-)
Image

Full-size: Green Bear
Eugene a.k.a. Realizator

User avatar
stereomii
Posts: 37
Joined: Mon May 13, 2019 3:11 pm
Location: Apeldoorn, The Netherlands
Contact:

Re: 3d cam with mobile phone as viewfinder and controller

Post by stereomii »

Realizator wrote:
Thu May 30, 2019 10:55 am
Stereomii, I faced with some issue while using "-t 1" option. Looks like in this mode camera has not enough time to do right settings for photo capture. It is critical in a low light conditions.
Hello Eugene,
I noticed that "-t 1" option not only gave problems in low but also in full sunlight conditions the pictures were heavily overexposed. "-t 5" did not improve results. Thanks to Stereomaton viewtopic.php?f=11&t=43&p=165#p165 I learned that the time after -t is in milliseconds (not seconds as I first assumed). So now my options for raspistill are "-t 500" (noticed no significant difference between 500 and 1000 milliseconds). I also added "-w 5184 -h 1944" to get a full resolution sbs picture.

I still have another problem. I noticed one occasion where I could not play the concurrently taken video's. Looks like these are in some cases not correctly closed. Still can not reproduce these. It is NOT because power was cut while recording. The automatically closed videos by recording time were unreadable.
Six consecutive videos of 5 minutes were not playable while the last one, closed by switching off recording, could be played in VLC. As said I cannot up till now reproduce this.
I tought maybe my battery providing too low voltage could be the problem but yesterday evening I let it run recording 1 minute and later 5 minute vid's for a couple of hours on battery and all were playable.
Jan a.k.a. stereomii
StereoPi with Waveshare 160deg cams

Post Reply