A camera unit for Ultibo

The place to share and discuss your Ultibo projects.
pik33
Posts: 840
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

A camera unit for Ultibo

Postby pik33 » Sun Dec 02, 2018 12:05 pm

https://github.com/pik33/SimpleCamera

Now in working alpha stage.

To do: testing, debugging and cleaning.

Usage:

(1) call initcamera with your desired parameters, then check the result: if it is >$C0000000 then all went OK, the camera is in the idle state, and the result is the address of the main camera buffer

If it is small integer, an error occured

1 - error while loading the camera component 2 - error while setting camera number 3 - error while setting the video format 4 - error while switching the camera to the idle state 5 - error while allocating the camera buffer 6 - camera didn't reached the idle state

If all went OK, you will get pointers to y, u, v buffers in pY, pU, pV and their sizes in sizey, sizeu, sizev

(2) call startcamera. If it returned 0, the worker thread is started

In your main thread wait until filled=true and read the buffers as fast as you can, then set filled=false If there is no filled=false set by the receiving thread, the camera worked thread will stop itself in one second

(3) when done, call stopcamera

(4) after this you can start it again or... (5) call destroycamera which will unload it and close omx.
mark
Posts: 1324
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: A camera unit for Ultibo

Postby mark » Thu Dec 20, 2018 2:49 am

pik33 wrote:https://github.com/pik33/SimpleCamera

Now in working alpha stage.

To do: testing, debugging and cleaning.

Usage:

(1) call initcamera with your desired parameters, then check the result: if it is >$C0000000 then all went OK, the camera is in the idle state, and the result is the address of the main camera buffer

If it is small integer, an error occured

1 - error while loading the camera component 2 - error while setting camera number 3 - error while setting the video format 4 - error while switching the camera to the idle state 5 - error while allocating the camera buffer 6 - camera didn't reached the idle state

If all went OK, you will get pointers to y, u, v buffers in pY, pU, pV and their sizes in sizey, sizeu, sizev

(2) call startcamera. If it returned 0, the worker thread is started

In your main thread wait until filled=true and read the buffers as fast as you can, then set filled=false If there is no filled=false set by the receiving thread, the camera worked thread will stop itself in one second

(3) when done, call stopcamera

(4) after this you can start it again or... (5) call destroycamera which will unload it and close omx.


I would like to use this. I tried adding an lpr with the suggested logic and it did not seem to receive an omx camera buffer filled event.

Assuming that this was extracted from ultibo_retro_gui (which works as seen in the sampler) should I add my lpr to the repo and push it so you can see what I might be doing incorrectly? I also found some text errors and I can format the code using the ptop automatic formatter.

Regards,
Mark
pik33
Posts: 840
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: A camera unit for Ultibo

Postby pik33 » Thu Dec 20, 2018 5:25 am

This need to be upgraded. I made severl changes (bugfixes) in the unit. It is still in alpha stage.
mark
Posts: 1324
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: A camera unit for Ultibo

Postby mark » Thu Dec 20, 2018 2:11 pm

pik33 wrote:This need to be upgraded. I made severl changes (bugfixes) in the unit. It is still in alpha stage.

Ok, I will wait for the repo push.

Thanks,
Mark
pik33
Posts: 840
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: A camera unit for Ultibo

Postby pik33 » Thu Dec 20, 2018 6:06 pm

New version pushed, try if it works. A major change: using OMX buffers in 2 threads (a main thread and a camera worker thread) and making the camera thread dependent on what you do in your main thread caused instability. So I changed this: now you have to provide your buffer to the init procedure. Declare an array or do a getmem, then pass the pointer as unsigned integer to initcamera.The camera unit will copy the omx buffer to your buffer using fastest possible copy method (asm procedure). Memory copy costs time, but now this seems to be stable.
mark
Posts: 1324
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: A camera unit for Ultibo

Postby mark » Thu Dec 20, 2018 7:51 pm

pik33 wrote:New version pushed, try if it works. A major change: using OMX buffers in 2 threads (a main thread and a camera worker thread) and making the camera thread dependent on what you do in your main thread caused instability. So I changed this: now you have to provide your buffer to the init procedure. Declare an array or do a getmem, then pass the pointer as unsigned integer to initcamera.The camera unit will copy the omx buffer to your buffer using fastest possible copy method (asm procedure). Memory copy costs time, but now this seems to be stable.

Thank you. I am starting to update and modify right now. Mark.
mark
Posts: 1324
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: A camera unit for Ultibo

Postby mark » Thu Dec 20, 2018 8:43 pm

mark wrote:
pik33 wrote:New version pushed, try if it works. A major change: using OMX buffers in 2 threads (a main thread and a camera worker thread) and making the camera thread dependent on what you do in your main thread caused instability. So I changed this: now you have to provide your buffer to the init procedure. Declare an array or do a getmem, then pass the pointer as unsigned integer to initcamera.The camera unit will copy the omx buffer to your buffer using fastest possible copy method (asm procedure). Memory copy costs time, but now this seems to be stable.

Thank you. I am starting to update and modify right now. Mark.


Ok, I am getting the expected fill rate of 30 fps. I haven't checked the buffer to see that it produces a sensible image but I can assume that it is for now. Thanks again, Mark.

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest