3D-Pic

Paint programs, vector editors, 3d modelers, animation editors, etc.
Post Reply
Message
Author
User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

3D-Pic

#1 Post by MU »

This is a small commandlineprogram written in C using the GDK library.

If you have a 3D Television or Monitor like the LG Cinema 3D models, this might be nice for you.

You can use your webcam with a program like "ucview" (search forum) to create a foto.
Then slide the webcam some cm aside, and take another foto.

So you usually now have something like
/root/Image_00000.jpg
/root/Image_00001.jpg

To convert them to a 3D Foto, type in a consolewindow:

Code: Select all

cd /root
3dpic Image_00000.jpg Image_00001.jpg out.jpg
The resulting "out.jpg" has merged both in one file, side by side, scaled down to the half width.

As the program is jus a quick hack, it has no further options.
The resulting picture has HDTV resolution (1920x1080).The Jpeg Quality is 100, to avoid loosing quality.

To view the picture in 3D, use your favorite Pictureviewer like gqview, press "f" to see it fullscreen.
Then on LG Monitors, press the "3D" button on the remote control, and use the 3D-Mode "2 pictures side by side".

Enjoy!

I attach a test jpeg I just created.

More fotos will be added here:

http://noforum.de/pics/3dpics/


Note: the program was compiled in Fluppy 013.
If it does not work on other puppys, you can recompile it like this:

Code: Select all

cd /usr/local/3dpic/source
./install
This requires to have a "devx" development SFS for your Puppy installed.

Mark
Attachments
3dpic.pet
License: GPL V3 (not included)
(3.21 KiB) Downloaded 593 times
Last edited by MU on Sat 23 Jun 2012, 23:01, edited 3 times in total.
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

Here is another example, now with close objects.
You will see with the unsharp "Asus" logo on the top right, that positioning of the camera is critical.

I think I will build a mechanical "slider" for it this week to avoid, that the cam moves up or down when moving it.

Still impressioning though on a 3Dmonitor, will be nice to fotograph some model spaceships somewhen this week :)

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#3 Post by vovchik »

Dear Mark,

Glad to see you back here. :)

With kind regards,
vovchik

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#4 Post by MU »

Hello Vovchik,

Thank you :)
I just have time to look in temporarily, as I work fulltime on Computers.
So after work I am often fed up with them, and do not program any more in my spare time.

However if there are smaller tools I write to simplify the usage of my main operating system (Fluppy013 actually), I of course share them here :)

Cheers, Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#5 Post by Flash »

Yes Mark, it's good to see that you haven't quit the forum altogether. :)

Depending on the effect you're after in the 3-D picture, you might want everything in the picture to be in focus. I don't know what the depth of field of a webcam is, and I don't think you have any control over it. If you take the pictures with a camera that allows you to fiddle with the lens aperture, shutter speed and ASA or iso speed, you can set the lens aperture to its smallest opening (highest number on the dial) to get the greatest depth of field and bring more of the picture into sharp focus. Pinhole cameras have almost infinite depth of field. A 3-D camera made with pinhole "lenses" would be an interesting thing to try. Everything in the picture would be in sharp focus. Well, more or less; pinhole images aren't quite as sharp as those made with a regular lens.

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#6 Post by Ted Dog »

Can this be used for DIY cross your eyes old school 3D?

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#7 Post by MU »

Ted Dog wrote:Can this be used for DIY cross your eyes old school 3D?
Hi Ted, yes almost.
For "cross your eyes" you need both images in the original aspect ratio, while 3D Monitors need them scaled to half width.

Here are examples of your method:
http://wolfatmidnight.blogspot.de/2012/ ... -eyes.html

The sourcecode of my program had to be slightlly modified for this.
It had to load a black jpg first (as background), and then place the 2 fotos on that, scaled down in width and (new) in height, too.

Maybe I can upload a corresponding version tomorrow.


-------------------------------------------
I made more 3D tests. If you have TWO cameras, you also could watch their stream in 3D.

Such a script will do it:

Code: Select all

#!/bin/bash

#-- LEFT cam

mplayer tv:// -tv driver=v4l2:width=1280:height=720:device=/dev/video0:outfmt=uyvy -vf scale=960:1080 -zoom -x 960 -y 1080 -geometry 0:0 &


#-- RIGHT cam

mplayer tv:// -tv driver=v4l2:width=1280:height=720:device=/dev/video1:outfmt=uyvy -vf scale=960:1080 -zoom -x 960 -y 1080 -geometry 960:0 &
The "outfmt=uyvy" avoids that an error comes up with the second cam:
v4l2: ioctl streamon failed: No space left on device
v4l2: ioctl set mute failed: Invalid argument
Instead of yuyv you also can try mjpeg or YUY2.

The camera resolution is set to "1280:height=720", as on my Athlon 5050 (2 cores, 2.6 Mhz) the framerate is too low with higher resolution.
On faster systems you might try "1920:height=1080" instead.


I actually use 2 different cams, a Logitech C910 HDTV cam and an old Logitech model with pretty low resolution.

So I just experiment, if and how using 2 cams technically works. To watch the real 3D picture in usable quality, I will order another C910.

A generally interesting program for 3D purposes is "bino", see here:
http://www.murga-linux.com/puppy/viewtopic.php?t=76501


FLASH,
yes a real camera certainly would achieve even better results. I dream of a camcorder from panasonic, that has a special optional 3D lens. But the camcorder costs around 400 Euro, and the lens 460 Euro or so.
So I actually prefer to pay 80 Euro for a second HDTV cam right now. And the C910 has really great results, the fotos in the first message were made with it.

So the camcorder will wait, until I have earned some more bucks in my new job :)

Cheers, Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#8 Post by MU »

I attach a pet "3dsnapshot". It contains two usefull scripts.

My setup: two Logitech C910 HDTV webcams, pasted with some glue on a base (a piece of plastic).

I tried several types of glue, and ended up with 2 component epoxy glue, still experimenting.

The scripts:

Code: Select all

/root/3dmplayer
This will run 2 windows of mplayer (see forum for download) side by side, displaying /dev/video0 and /dev/video1 (the 2 cams).
When I used a USB-Hub, it did not work, had to attach one cam on the front of the computer, the other one on the back. I think there was a conflict because both use the same address/identifier.

So like this you can see the livestream of the cameras in 3D.
To close them, press "q" in each of them.

It is written for HDTV resolution, if you have a different resolution, you need to edit /root/3dmplayer1 and /root/3dmplayer2


Options:

Code: Select all

/root/3dmplayer low
This will use the lower "1280x720" mode of the cameras, like this they have better framerates, but worse quality.


The second script is

Code: Select all

/root/3dsnapshot
It will send both already running mplayers the command to save screenshots, and then converts them with 3dpic2, a slightly modified 3dpic from the first message.

The resulting files are stored in /root/3dsnapshots.

The modification does not use scaling to avoid as much conversion as possible for quality reasons, so requires that the pictures are in HDTV format already.
If you use a different format, edit /root/3dsnapshot to use the original 3dpic instead of 3dpic2.

The script then simply will take the two mplayer screenshots, and combine them to a side-by-side 3D-Foto for 3D-Monitors, and then display them in gqview.
If you have a different viewer, you must edit the script to use that instead. After a keypress in the console gqview is terminated (I prefer that to some mouseclicks in gqview itself).


I run 3dsnapshot on a consolewindow on second monitor (my TV), while monitor 1 displays the cameras.
If you use just one monitor, remember that you can quickly switch the windows with "alt - tab", at least using Icewm.

Mark
Attachments
3dsnapshot.pet
(5.89 KiB) Downloaded 503 times
Last edited by MU on Sun 29 Jul 2012, 14:52, edited 3 times in total.
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#9 Post by MU »

I updated 3dsnapshot.pet

new options:

Code: Select all

/root/3dmplayer quit
this simply closes the 2 running mplayers.

Code: Select all

/root/3dmplayer zoom
this sets the camera to a high resolution of 2592x1944, and then "cuts out" the HDTV resolution 1920x1080.
Like this you get a "zoom". The framerate is set to 1 fps, with higher values I got blackouts.

Code: Select all

/root/3dmplayer zoom1
Like zoom, but the cut out area now is just 1280x720, scaled up to HDTV size. So you have a "slight digital zoom" with a little quality loss.

Code: Select all

/root/3dmplayer zoom2
Like zoom2, but the cut out area now is just 960x540, scaled up to the double HDTV size. So you have a "double digital zoom" with high quality loss.

I uploaded 4 "zoom" jpegs to http://noforum.de/pics/3dpics/
so that you can see the difference.

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#10 Post by MU »

updated 3dsnapshot

new options for /root/3dmplayer:

Code: Select all

/root/3dmplayer offset=100:10
Parallax control, move one picture aside/down to adjust the cams if they are not aligned correctly.

Code: Select all

/root/3dmplayer offset2=100:10
Parallax control, move one picture aside/down (different method, with zoom)

Code: Select all

/root/3dmplayer fps=1
Set framerate to 1, use this if your system has timeouts displaying green screens.

Code: Select all

/root/3dmplayer help
show all options

Code: Select all

/root/3dmplayer left=video2 right=video3
Forces to use other devices than the defaults /dev/video0 and /dev/video1

I also updated /root/3dsnapshot, it grabs more reliable now and stores all files in the folder /root/3dsnapshots.

Mark
[url=http://murga-linux.com/puppy/viewtopic.php?p=173456#173456]my recommended links[/url]

Post Reply