Upgraded to support latest SDK

This commit is contained in:
MattMo 2023-09-05 09:22:37 -07:00
parent 91f7b94a3a
commit 84bee44bf6

View File

@ -45,38 +45,40 @@ namespace MariCam
public static unsafe extern IntPtr createArducamDepthCamera();
[System.Runtime.InteropServices.DllImport(LibraryPath)]
public static unsafe extern IntPtr init(IntPtr camera, ConnectionType connectionType, int deviceNumber);
public static unsafe extern IntPtr arducamCameraOpen(IntPtr camera, ConnectionType connectionType, int deviceNumber);
[System.Runtime.InteropServices.DllImport(LibraryPath)]
public static unsafe extern IntPtr start(IntPtr camera, FrameType frameType);
public static unsafe extern IntPtr arducamCameraStart(IntPtr camera, FrameType frameType);
[System.Runtime.InteropServices.DllImport(LibraryPath)]
public static unsafe extern IntPtr requestFrame(IntPtr camera, int timeout);
public static unsafe extern IntPtr arducamCameraRequestFrame(IntPtr camera, int timeout);
[System.Runtime.InteropServices.DllImport(LibraryPath)]
public static extern IntPtr releaseFrame(IntPtr camera, IntPtr frameBuffer);
public static extern IntPtr arducamCameraReleaseFrame(IntPtr camera, IntPtr frameBuffer);
[System.Runtime.InteropServices.DllImport(LibraryPath)]
public static extern FrameFormat getFormat(IntPtr camera, int frameType);
public static extern FrameFormat arducamCameraGetFormat(IntPtr camera, int frameType);
[System.Runtime.InteropServices.DllImport(LibraryPath)]
public static extern IntPtr getDepthData(IntPtr frameBuffer);
public static extern IntPtr arducamCameraGetDepthData(IntPtr frameBuffer);
public static unsafe void Main(string[] args)
{
Console.WriteLine("Setting up Camera");
var camera = createArducamDepthCamera();
init(camera, ConnectionType.CSI, 0);
arducamCameraOpen(camera, ConnectionType.CSI, 0);
start(camera, FrameType.DEPTH);
arducamCameraStart(camera, FrameType.DEPTH);
var tempBuffer = requestFrame(camera, 200);
var tempBuffer = arducamCameraRequestFrame(camera, 200);
var tempFormat = getFormat(tempBuffer, 2);
var tempFormat = arducamCameraGetFormat(tempBuffer, 2);
var buffer = new Bitmap(tempFormat.Width, tempFormat.Height, PixelFormat.Format32bppArgb);
releaseFrame(camera, tempBuffer);
arducamCameraReleaseFrame(camera, tempBuffer);
var form = new Form();
@ -90,9 +92,9 @@ namespace MariCam
form.Paint += (object sender, PaintEventArgs e) =>
{
var frameBuffer = requestFrame(camera, 200);
var frameBuffer = arducamCameraRequestFrame(camera, 200);
var format = getFormat(frameBuffer, 2);
var format = arducamCameraGetFormat(frameBuffer, 2);
var graphics = e.Graphics;
@ -100,7 +102,7 @@ namespace MariCam
graphics.Clear(Color.Black);
float* depthData = (float*)getDepthData(frameBuffer);
float* depthData = (float*)arducamCameraGetDepthData(frameBuffer);
float min = float.MaxValue;
float max = float.MinValue;
@ -145,7 +147,7 @@ namespace MariCam
graphics.DrawImage(buffer, new Rectangle(0, 0, form.ClientSize.Width, form.ClientSize.Height));
releaseFrame(camera, frameBuffer);
arducamCameraReleaseFrame(camera, frameBuffer);
form.Invalidate();
};