I am working on a simple application that is to capture an image from the serial camera connected to an FEZ Cobra II NET and display the captured image on a simple web server running on the device.
I am a bit lost how to go about doing this. There are samples on how to capture images and display them on a display (dont have a display so havent tested that) but going from that to a function web page is a bit lost on me.
Any tips or other help is greatly appreciated.
Approach it in pieces.
Capture an image - based on what, a time interval? A web request?
Capture an image and save the image somewhere you can use it later.
Web server - do you have it working already? How much HTML do you know and what would a web page with graphic object in it look like? Try with a static object in a page, from SD card or embedded in your app, what do those requests look like? Then, once you have that working, how do you change it to use the dynamically saved image?
My thoughts is to capture an image from the serial camera when it is ready and keep it in memory (serCam.isNewImageReady) .
The question is if I have to do something with the image or is it passed as a BMP from the serial camera? Ie if I wanted to can, I just save the bulk of data to a file and the end product would be a bmp file?
When I get a http request I would make it as simple as possible, just respond with the most basic web page with a link to a file and when the request for the file comes I would like to stream out the image I have in memory. I have written basic web server before that only display text info and simple config pages with text input boxes and buttons to save config data to the device.
The image aspects of the project is new to me. I would prefer to avoid the requirement for a SD card to save the camera image to.
So essentially the question you are asking is now about the serial camera output - I have no idea !!
If you look at the developers guide, https://www.ghielectronics.com/docs/176/serial-camera-module, you’ll find the code example creates a bitmap object the size of the screen, starts streaming, then calls DrawImage to map the image into the bitmap. If you look at the product guide https://www.ghielectronics.com/catalog/product/382 it says JPEG, but I am not sure what method you’re meant to use to access the raw JPEG image.
You can see from the code for the driver, http://gadgeteer.codeplex.com/SourceControl/latest#Main/Modules/GHIElectronics/SerCam/Software/SerCam/SerCam_42/SerCam_42.cs that you also have some other functions that there are other image related public methods such as ReadFrameBuffer() that you may be able to leverage, or even extend the driver, that might be a “cleaner” approach than streaming and using DrawImage - I’ll say it again, I don’t know what you’re meant to use to access the JPG itself.
To store the image in memory, you need to have memory. With a Cobra you have plenty and shouldn’t have a problem with keeping an image in memory and then sending it out to the web response.
Hope that helps - sorry I don’t have a sercam module to actually help more and try it.
From a web perspective, I think you’re on the right path by creating a web page that contains an embedded image whose path is known (http://your.ip.address.here/sercam_image.jpg might be a good example) that in your server you then return the jpg data.
This could help you:
Code share: “Webserver displaying picture captured when button is pressed”