-
Notifications
You must be signed in to change notification settings - Fork 13
Saving images
Adwyzz (OLED Edition) edited this page Jan 22, 2022
·
5 revisions
Alright, so you got your Camera
device, and you're listening to the OnFrame
event.
Now you want to save them to a png or jpg file. How do you do that?
SeeShark is just a camera library and thus does not handle saving images. You can use ImageSharp
for this.
Ensure that the camera frames are in a pixel format that is readable by ImageSharp, as SeeShark supports a wide variety of pixel formats that ImageSharp does not. This depends from camera to camera, so i'd reccommend Converting frames between pixel formats anyway.
Here I'll use the RGBA pixel format, compatible with both SeeShark and ImageSharp.
After installing ImageSharp using their docs, here's a modified version of their example code.
var frame = e.Frame; // Assume this is in RGBA for this example
using (Image<Rgba32> image = Image.LoadPixelData<Rgba32>(frame.RawData, frame.Width, frame.Height))
{
image.SaveAsJpeg("image.jpg");
}