hex007
Posts: 4
Joined: Mon Mar 19, 2018 9:22 pm

Modify every frame

Mon Mar 19, 2018 9:35 pm

I would like to modify every frame such that the frame is shrunk to a given rectangle. I tried this with overscan and it works. I also want to use dismanx to show custom data/images outside the rectangle.

If i use Screenshot + element method next frame also has the outer image captured resulting in an infinite shrinking mirror kind of effect. Element is a persistent method to show something on screen. I am looking for a solution that does not persists on the next frame.

Another solution would be a way to capture screen based on layers. I can set the side images on a higher layer which will not be captured at the next call to capture screen.

Adding and removing element at each frame is not possible. It crashes the server and a reboot is needed to get back the display

@AndyD maybe you can point me in the right direction.

Thanks

scotty101
Posts: 2987
Joined: Fri Jun 08, 2012 6:03 pm

Re: Modify every frame

Tue Mar 20, 2018 10:06 am

You might have to give some context here...

What are you trying to do? Is this based on an existing topic or a tutorial somewhere?
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

hex007
Posts: 4
Joined: Mon Mar 19, 2018 9:22 pm

Re: Modify every frame

Tue Mar 20, 2018 7:40 pm

I am using an SPI screen that is bigger than the frame. I can use dispmanX to get the frame, Resize it and fit to the visible area exactly. There is also some slits from where the LCD is visible. I use those areas to show colors corresponding to system state 9eg Green for network connectivity).

I am now moving to a composite screen witch takes PAL /NTSC input. So i cannot control what goes on the screen. But i can capture the screen and add an element to show the screenshot only in the visible area. The problem is that the element persists on the next frame too. So my next call to `screenshot` includes the previous screenshot. This creates an infinite mirror effect.

So i am looking for a way to either capture screen without the element or modify every frame without touching future frames.

PS: if it is still not clear let me know.

User avatar
Paeryn
Posts: 2055
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Modify every frame

Wed Mar 21, 2018 1:59 am

Wouldn't that cause a flicker? You'd see the image drawn full-size whilst you take the screenshot before you put the screenshot element on top?

If constantly adding and removing an element is causing problems you could always try changing the the layer used for the screenshot image element to say -1 e.g.

Code: Select all

vc_dispmanx_element_change_layer(update, element, -1);
before calling the screenshot function, that would put it behind the framebuffer (which is at 0) and so not be visible, then change it back to whatever layer you want for the user to see it.
She who travels light — forgot something.

hex007
Posts: 4
Joined: Mon Mar 19, 2018 9:22 pm

Re: Modify every frame

Wed Mar 21, 2018 7:58 pm

So start update, change element layer to -1, submit_sync, start update, take snapshot, do the shrinking, change layer, submit_sync ?

Also is -1 a valid layer ?

hex007
Posts: 4
Joined: Mon Mar 19, 2018 9:22 pm

Re: Modify every frame

Wed Mar 21, 2018 9:00 pm

So console layer is -127.

Doing sync twice with and without element causes flickering. So that is a no go.

Is there a way to capture a single layer ?

User avatar
Paeryn
Posts: 2055
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Modify every frame

Wed Mar 21, 2018 9:49 pm

Oh, is the framebuffer -127? Sorry, it's been a while since I wrote the layer handling code that I use and I was going off my memory rather than looking it up (quick check, yes, I create my base window with layer=0 so makes sense that the framebuffer is lower than that). I've always assumed the VC4 just uses the signed integer layer numbers for comparisons to sort the when generating the display list.

I thought that taking snaphots would generate flickering. I assume you are in total contol of all the elements other than the framebuffer so can place them correctly from the get go. The only thing I can think of off the top of my head would be to have an element just above the framebuffer set to scale a full screen down to what you want and literally copy the contents of the framebuffer to it (I don't think you can get the framebuffer's dispmanx resource or element handle, if you could there would be less work).

As far as I'm aware there isn't any way of getting an image of one layer, as I said above, I assume the layer number is just for sorting rather than there being set layers. I never spent much time trying to figure out exactly how it operates as I've not hit any problems with my initial assumption. I'd love to have access to the source code for dispmanx but I can't see Broadcom releasing it any time soon.
She who travels light — forgot something.

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 3 guests