From 84bee44bf63aa93b7d79efd2f1bdc37a7b4279af Mon Sep 17 00:00:00 2001 From: MattMo Date: Tue, 5 Sep 2023 09:22:37 -0700 Subject: [PATCH] Upgraded to support latest SDK --- MariCam/Program.cs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/MariCam/Program.cs b/MariCam/Program.cs index 1ead4e8..10b29e2 100644 --- a/MariCam/Program.cs +++ b/MariCam/Program.cs @@ -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(); };