texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Preview to fb1 ?

Sun May 26, 2013 10:36 am

Hi,
would it be possible to output the preview to framebuffer1 instead of the default output?
That way I could use one of my TFT display board to preview the camera's output ;)
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Sun Jun 30, 2013 9:12 am

Just bumping this thread. If anyone knows of a way, or is prepared to modify the raspistill/raspivid code to allow redirection of the preview to fb1, I'd be very grateful......
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23679
Joined: Sat Jul 30, 2011 7:41 pm

Re: Preview to fb1 ?

Sun Jun 30, 2013 9:43 am

I think that would require a copy - the preview is on its own dispmanx bitmap, so would need to be moved from there to the FB. I'm not sure how to do it. DOm might now, I'll try to remember to ask him Monday.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5331
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Preview to fb1 ?

Sun Jun 30, 2013 9:48 am

The preview normally is handed entirely by the GPU (hence the few % arm utilisation when running).
Disaplaying on framebuffer would be expensive (in cpu) and is not trivial.

If you want it, then adapting something like raspiyuv to write the pixels to framebuffer is the solution.

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Sun Jun 30, 2013 1:38 pm

Sounds like it is quite feasible then, but beyond my capabilities...............................
T.
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

cmegens
Posts: 28
Joined: Fri May 24, 2013 12:23 pm
Location: Netherlands

Re: Preview to fb1 ?

Mon Jul 01, 2013 2:33 pm

Any ideas who could be able to do this?

tasanakorn
Posts: 18
Joined: Thu May 16, 2013 3:53 pm

Re: Preview to fb1 ?

Tue Jul 16, 2013 1:58 pm

My program.

https://github.com/tasanakorn/rpi-fbcp

Just copy from /dev/fb0 to /dev/fb1 by vc_dispmanx_snapshot. It should display everything from primary display to fb1.

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Tue Jul 16, 2013 2:15 pm

Sounds great - can't wait to try it. What display did you use when developing, and what kind of framerate did you achieve?
I am assuming that this handles video as well as stills?

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

tasanakorn
Posts: 18
Joined: Thu May 16, 2013 3:53 pm

Re: Preview to fb1 ?

Tue Jul 16, 2013 2:35 pm

I'm test with 2.8" 240x320 (Renesas R61505 flexfb SPI 60Mhz).

I did not measure framerate.
It take ~ 10ms to take screenshot and copy to framebuffer.
It enought to preview camera or play video with omxplayer (better than mplayer on framebuffer). I put 50ms delay in each loop to reduce cpu usage (now 1% cpu usage).

You can adjust it and share your result.
IMG_9814_s.jpg
IMG_9814_s.jpg (33.55 KiB) Viewed 25241 times
The big problem right now is, I don't know how to sync to framebuffer refresh.

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Tue Jul 16, 2013 3:06 pm

Wow.
Got some quick instructions? Is it running as a background task and you use pi-cam commands as usual, or does your app control the pi-cam too?
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

tasanakorn
Posts: 18
Joined: Thu May 16, 2013 3:53 pm

Re: Preview to fb1 ?

Tue Jul 16, 2013 3:53 pm

This app like normal app. but it does not output any text on console (some debug message send to syslog).
You can run with & to take it in background like.

> ./fbcp &

Before use this run this app. Make sure you are run lastest raspberry pi firmware (> 2013-07-11 with dispmanx_screeshort scale).
Beware, if you update firmware with rpi-update, It will replace kernel/module with official (I don't remember how to skip kernel update). Then test your framebuffer driver again (you might need to rotate screen to landscape to match with primary screen ratio)

build
------

$ git clone https://github.com/tasanakorn/rpi-fbcp.git
$ cd rpi-fbcp
$ mkdir build
$ cd build
$ cmake ..
$ make

Run
----

$ ./fbcp &

Check Log (if you want)
-------------

$ tail -f /var/log/message



Now. you should see primary screen on framebuffer device. At this point you can run any program (raspivid, raspistill, startx or omxplayer) like on primary screen (let me know if it not).

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Tue Jul 16, 2013 6:21 pm

tasanakorn wrote:This app like normal app. but it does not output any text on console (some debug message send to syslog).
You can run with & to take it in background like.

> ./fbcp &

Before use this run this app. Make sure you are run lastest raspberry pi firmware (> 2013-07-11 with dispmanx_screeshort scale).
Beware, if you update firmware with rpi-update, It will replace kernel/module with official (I don't remember how to skip kernel update). Then test your framebuffer driver again (you might need to rotate screen to landscape to match with primary screen ratio)

build
------

$ git clone https://github.com/tasanakorn/rpi-fbcp.git
$ cd rpi-fbcp
$ mkdir build
$ cd build
$ cmake ..
$ make

Run
----

$ ./fbcp &

Check Log (if you want)
-------------

$ tail -f /var/log/message



Now. you should see primary screen on framebuffer device. At this point you can run any program (raspivid, raspistill, startx or omxplayer) like on primary screen (let me know if it not).
I needed to

Code: Select all

sudo apt-get install cmake
as well, but I still get this error :

Code: Select all

[email protected] ~/rpi-fbcp/build $ make
Scanning dependencies of target fbcp
[100%] Building C object CMakeFiles/fbcp.dir/main.c.o
In file included from /opt/vc/include/interface/vcos/vcos_assert.h:149:0,
                 from /opt/vc/include/interface/vcos/vcos.h:114,
                 from /opt/vc/include/interface/vmcs_host/vc_dispmanx.h:33,
                 from /opt/vc/include/bcm_host.h:46,
                 from /home/pi/rpi-fbcp/main.c:8:
/opt/vc/include/interface/vcos/vcos_types.h:38:33: fatal error: vcos_platform_types.h: No such file or directory
compilation terminated.
make[2]: *** [CMakeFiles/fbcp.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/fbcp.dir/all] Error 2
make: *** [all] Error 2
[email protected] ~/rpi-fbcp/build $
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

tasanakorn
Posts: 18
Joined: Thu May 16, 2013 3:53 pm

Re: Preview to fb1 ?

Wed Jul 17, 2013 2:19 am

Sorry.. missing some include path.

Code: Select all

    $ cd rpi-fbcp
    $ git pull
    $ cd build
    $ cmake ..
    $ make
    

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Wed Jul 17, 2013 8:34 am

Thankyou - that is working - and it is working very well with my display board boards on HY28A-LCDB.
I am sure that people will find this very useful,
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Aikidokajeff
Posts: 68
Joined: Fri May 25, 2012 3:31 pm

Re: Preview to fb1 ?

Wed Jul 17, 2013 10:14 pm

I sure will!
Although I'm currently tied up with work/family and trying to write a python interface so I can run without a keyboard etc.

Very cool, well done!

Jeff

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Preview to fb1 ?

Thu Jul 18, 2013 11:36 am

texy wrote:Thankyou - that is working - and it is working very well with my display board boards on HY28A-LCDB.
I am sure that people will find this very useful,
Texy
Fantastic news. Does it work well enough to use one of these little screens as a preview screen for video? That's the breakthrough I've been holding out for :lol: otherwise we're stuck with crappy car reversing screens on the composite RCA connector. :D
Alex Eames RasPi.TV, RasP.iO

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Thu Jul 18, 2013 12:53 pm

alexeames wrote:
texy wrote:Thankyou - that is working - and it is working very well with my display board boards on HY28A-LCDB.
I am sure that people will find this very useful,
Texy
Fantastic news. Does it work well enough to use one of these little screens as a preview screen for video? That's the breakthrough I've been holding out for :lol: otherwise we're stuck with crappy car reversing screens on the composite RCA connector. :D
...it most certainly does work well enough, at least with my 2.8"TFT boards. Because it now copies main output to fb1, it allows you to play video's with omxplayer at a far better framerate than direct just plain mplayer playback to fb1 ;)

In theory also raspbmc could be used with this screen...with a bit of tinkering.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

tvjon
Posts: 710
Joined: Mon Jan 07, 2013 9:11 am

Re: Preview to fb1 ?

Tue Jul 23, 2013 2:46 pm

tasanakorn wrote:This app like normal app. but it does not output any text on console (some debug message send to syslog).
......
Now. you should see primary screen on framebuffer device. At this point you can run any program (raspivid, raspistill, startx or omxplayer) like on primary screen (let me know if it not).
Thank you kindly for sharing this tasanakom.

I'm not sure the tft display would be useful to me yet without it! I've had no luck with the python side of things so far (perhaps because the only python I know is Monty :) )

It appears that:
os.environ["SDL_FBDEV"] = "/dev/fb1"
is ignored by the test code, so the only way it will work is by having no display other than the tft.

It's rather impractical for my use to have to keep (un)plugging hdmi monitor, so your application means I can now view video & pictures.

You asked for feedback so here's a short lo-res video showing hdmi screen flashing when using:

raspivid -t 0

It only occurs on hdmi. The tft "mirroring" is flash-free.

That in itself is interesting, as yesterday when I first connected the tft display I had several hours of tft backlight flashing. Today however, it seems ok so far.
Attachments
662.mp4.zip
(59.36 KiB) Downloaded 429 times

tasanakorn
Posts: 18
Joined: Thu May 16, 2013 3:53 pm

Re: Preview to fb1 ?

Tue Jul 23, 2013 3:16 pm

tvjon wrote: ...

You asked for feedback so here's a short lo-res video showing hdmi screen flashing when using:

raspivid -t 0

It only occurs on hdmi. The tft "mirroring" is flash-free.

That in itself is interesting, as yesterday when I first connected the tft display I had several hours of tft backlight flashing. Today however, it seems ok so far.

Hi. tvjon
Thank you for your feedback.

Recent code, I reduce delay between frame from 50ms to 25ms to increase update rate. I think it update too much. Because I use VideoCore to capture primary screen, It might interfere and slow down raspivid task.

Since I don't know anything inside VideoCore. I don't know how to avoid that.

Hope broadcom guy interest this thread and give me a hint.

sharix
Posts: 200
Joined: Thu Feb 16, 2012 11:29 am
Location: Slovenia

Re: Preview to fb1 ?

Tue Jul 23, 2013 10:10 pm

Is it possible to use this to display the camera preview through SSH?

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Tue Jul 23, 2013 10:22 pm

Ssh is only a terminal device. You can send the fbcp command to start coping from main to fb1 via ssh, but the actual output remains with fb1.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

tvjon
Posts: 710
Joined: Mon Jan 07, 2013 9:11 am

Re: Preview to fb1 ?

Tue Jul 23, 2013 10:26 pm

Yes, via ssh works fine :)

texy
Forum Moderator
Forum Moderator
Posts: 5157
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Preview to fb1 ?

Fri Jul 26, 2013 1:53 pm

tasanakorn wrote: Hi. tvjon
Thank you for your feedback.

Recent code, I reduce delay between frame from 50ms to 25ms to increase update rate. I think it update too much. Because I use VideoCore to capture primary screen, It might interfere and slow down raspivid task.

Since I don't know anything inside VideoCore. I don't know how to avoid that.

Hope broadcom guy interest this thread and give me a hint.
I have only downloaded and used the initial release - has this recent code been released, or only your own experiments?

Thanks again
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23679
Joined: Sat Jul 30, 2011 7:41 pm

Re: Preview to fb1 ?

Fri Jul 26, 2013 2:36 pm

tasanakorn wrote:
tvjon wrote: ...

You asked for feedback so here's a short lo-res video showing hdmi screen flashing when using:

raspivid -t 0

It only occurs on hdmi. The tft "mirroring" is flash-free.

That in itself is interesting, as yesterday when I first connected the tft display I had several hours of tft backlight flashing. Today however, it seems ok so far.

Hi. tvjon
Thank you for your feedback.

Recent code, I reduce delay between frame from 50ms to 25ms to increase update rate. I think it update too much. Because I use VideoCore to capture primary screen, It might interfere and slow down raspivid task.

Since I don't know anything inside VideoCore. I don't know how to avoid that.

Hope broadcom guy interest this thread and give me a hint.
I think probably you will start to hit processor (The video scaler/compositor) and memory bandwidth issues with those low figures. That's a lot of data to be processing per second when added to the data requirements of the camera as well.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

PiGraham
Posts: 3607
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Preview to fb1 ?

Fri Jul 26, 2013 3:05 pm

tasanakorn wrote:My program.

https://github.com/tasanakorn/rpi-fbcp

Just copy from /dev/fb0 to /dev/fb1 by vc_dispmanx_snapshot. It should display everything from primary display to fb1.
This is running great for me with Texy's 2.8" TFT module. Camera preview, omxplayer output, copying HDMI or composite (aka headless)

Thanks tasanakorn!

Return to “Camera board”