308 views
in Platform Packages by

Hello Embedded Wizard Team,

currently I am planning to output a camera view on an Embedded Wizard UI for a student project. I’ve already found a similar question here (Link) in the forum, that was a good first guidance. Unfortunately it doesn’t works for me cause I have to connect the STM32F4-DIS-CAM (Link). My development board have to be the STM32F746G-DISCO (Link). For this hardware combination ST also provides some BSP functions within the CubeF7 Package.

Right now I’ve running an Embedded Wizard UI with your provided Build Environment and started to implement the camera view with an applet class as some of you recommended in the other thread that is linked above. The camera is connected through the camera connector P1.

Honestly, until this point I had the know how it works, but now I do not have any idea how to configure the applet within my C code and pass the data to Embedded Wizard. Even the ‘DeviceDriver’ example cannot give me an answer to this relatively special hardware connection.

 

1: I assume that an applet class would be the best way to import external data directly into the framebuffer, is that right?

2: Do I have to use the device driver class for this applet? The applet example that I have found in Embedded Wizard do not use it…

3: Can anybody give me a further guidance how to configure the applet class respectively the C code to pass the camera data?

 

Btw: Embedded Wizard is amazing easy to handle, thanks for providing a free version of it!

 

Fridolin

1 Answer

+1 vote
by

Hi Fridolin,

Nice to hear your last sentence, thanks.

 

1: Your assumption is correct, the most practicable solution is the applet class. With the provided function like Init(), Done(), OnCreate(), OnDestroy(), OnProgress(), OnUpdate(), OnGetBitmap() you will get all the API to pass the camera data to the Embedded Wizard UI element. Further information how to configure these functions correctly you can find here.

2: The applet class also provides an API to interact with the hardware. This means that you do not have to use a dedicated device driver class, but we really recommend it to use one. Since version 9.00 of Embedded Wizard we implemented the device driver functionality. The simple reason that you cannot find this in the applet example is that this example was written a long time ago. All in all; the device driver class is always a right way.

3: A camera view by an applet class itself is handled like any other Embedded Wizard widget. The difference is that it’s freely to fill the data of the widget area by your own external functionality. Shortly said an applet gives Embedded Wizard the opportunity to manage an external application.

 

You should use device driver methods inside the functions that I mentioned in 1, then you are also will be able to use the Embedded Wizard Prototyper without any warnings. An important thing to do is to synchronize the data with Embedded Wizard’s update routine. Therefore a double buffer implementation is recommended. One buffer should be always filled with the last fully captured picture and the other buffer should use for filling and saving the active data stream from your camera.

To switch between the buffers can be manage by an interrupt callback of the camera interface. I have taken a short view over the camera ST BSP and that’s already provided by ST.

These buffers should be accessible by the Embedded Wizard C code implementation. Therefore it is necessary to allocate two bitmaps. If this is done, you can access to the empty bitmap resource by getting the address of the first pixel. Within the applet example that you already have found you can take a look how that works. The applet example uses an Win32 project, this is also located in the applet example folder under ‘C:\Users\<User>\Documents\Embedded Wizard 9.20\Examples’. There you can find how to fill manually allocated bitmap resources.

 

I hope this helps.

 

Best regards

 

Tim

by
Hi Tim,

thank for this explanation. I will make some research with the applet example that you recommend to me.

Fridolin
by

Hi Tim,

I got it!

It was a lot work, but it works pretty well, here you can see how I did it:

That’s the content of my applet class:

 

Init()

// After the object has been created - initialize the external 'C' application.
// Create() will then call the OnCreate() method.
Create();

// Set the timer for the update routine
this.ProgressTimer.Period = 100;

 

Done()

// When the object is disposed - destroy the embedded application
// Destroy() will then call the OnDestroy() method.
Destroy();

 

OnCreate()

// This method initialize the external application in general. 
// For this specific example a device class is in use which 
// provides a function to initialize a camera.

aPosition;  // Dummy expresion to avoid Chora warnings.

return Camera::Device.CameraInit( aSize );

 

OnDestroy()

// This method calls the device class function for the deinitalisazin.

Camera::Device.CameraDeinit( aHandle );

 

OnProgress()

// OnProgress() is called, to give the external 'C' application a chance for some
// background processing, animations, etc. aTime contains the current time in 
// milliseconds.

aTime;  // Dummy expresion to avoid Chora warnings.

Camera::Device.CameraProgress( aHandle );

// No idle processing required. Wait for the next timer expiration. When 'true'
// is returned, OnProgress() is invoked as soon as possible.
return false;

 

OnUpdate()

// Here, the external application can perform screen updates. 
// In our example the camera uses two buffer areas to update the screen.
// The first area is for permanent saving the data that the camera sends 
// and the second one is for supporting an complete camera view after the first buffer 
// has be written completely.
   
if ( Camera::Device.CameraUpdate( aHandle ) )
  return Bounds.orect; 

// No update needed
return <0,0,0,0>;

 

OnGetBitmap()

// Here, the bitmap used internally by the external application to store its visible
// content is determined.

return Camera::Device.CameraGetBitmap( aHandle );

 

by

That’s the content of my device driver class:

Inside these device driver functions the BSP methods will called. I forward the signals for changing the state, contrast and brightness directly to the camera API. All the information how to work with the device driver class I got here.

 

Below is the rest of my code, especially the device driver C code and camera API. Here I just forward the functions calls from the device driver to my camera API. All works as you recommended, but unfortunately the callback handler for the frame event doesn't work properly. Any ideas about that?

 

cameraapi.h

cameraapi.c

DeviceDriver.h

DeviceDriver.c

 

Fridolin

 

by
Hello Fridolin,

Well done!

Thanks for sharing the code.

All the HAL functions provided by St aren't our task. Unfortunately i can't give any answer why the callback handler is not working. With this problem you should contact ST directly.

Best regards

Tim
by
Thank you for posting this!! We're after the same goal, but different devices (I'm working a RPi3). Please keep me updated on your progress!

Embedded Wizard Website | Privacy Policy | Imprint

...