static void Main(string[] args) { Console.WriteLine( "Skeleton tracking will be run on an image saved at %LOCALAPPDATA%\\res\\images\\skeleton_estimation.jpg... "); // Initialize logging to output all messages with severity level INFO or higher to the console Cubemos.Api.InitialiseLogging(Cubemos.LogLevel.CM_LL_INFO, bWriteToConsole: true); // Create cubemos Skeleton tracking Api handle and specify the directory containing a valid // cubemos_license.json or activation_key.json file Cubemos.SkeletonTracking.Api skeletontrackingApi; try { skeletontrackingApi = new Cubemos.SkeletonTracking.Api(Common.DefaultLicenseDir()); } catch (Cubemos.Exception ex) { Console.WriteLine("If you haven't activated the SDK yet, please run post_installation script as described in the Getting Started Guide to activate your license."); Console.ReadLine(); return; } // Initialise cubemos SkeletonTracking framework with the required model try { skeletontrackingApi.LoadModel(Cubemos.TargetComputeDevice.CM_CPU, Common.DefaultModelDir() + "\\fp32\\skeleton-tracking.cubemos"); } catch (Cubemos.Exception ex) { Console.WriteLine(String.Format("Error during model loading. " + "Please verify the model exists at the path {0}. Details: {1}", Common.DefaultModelDir() + "\\fp32\\skeleton-tracking.cubemos", ex)); Console.ReadLine(); return; } // Read an RGB image of any size System.Drawing.Bitmap inputImage = new System.Drawing.Bitmap(Common.DefaultResDir() + ".\\images\\skeleton_estimation.jpg"); // Set the network input size to 128 for faster inference int networkHeight = 128; System.Collections.Generic.List <Cubemos.SkeletonTracking.Api.SkeletonKeypoints> skeletonKeypoints; // Send inference request and get the poses skeletontrackingApi.RunSkeletonTracking(ref inputImage, networkHeight, out skeletonKeypoints); // Output detected skeletons Console.WriteLine("# Persons detected: " + skeletonKeypoints.Count); for (int skeleton_index = 0; skeleton_index < skeletonKeypoints.Count; skeleton_index++) { var skeleton = skeletonKeypoints[skeleton_index]; Console.WriteLine("Skeleton #" + skeleton_index); for (int joint_index = 0; joint_index < skeleton.listJoints.Count; joint_index++) { Cubemos.SkeletonTracking.Api.Coordinate coordinate = skeleton.listJoints[joint_index]; Console.WriteLine("\tJoint coordinate #" + joint_index + ": " + coordinate.x + "; " + coordinate.y); } } Console.Write("Press <Enter> to exit... "); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Skeleton tracking will be run on a pair of two images in the samples folder. "); // Initialize logging to output all messages with severity level INFO or higher to the console Cubemos.Api.InitialiseLogging(Cubemos.LogLevel.CM_LL_INFO, bWriteToConsole: true); // Create cubemos Skeleton tracking Api handle and specify the valid cubemos activation key file Cubemos.SkeletonTracking.Api skeletontrackingApi = new Cubemos.SkeletonTracking.Api(Common.DefaultLicenseDir()); // Initialise cubemos SkeletonTracking framework with the required model skeletontrackingApi.LoadModel(Cubemos.TargetComputeDevice.CM_CPU, Common.DefaultModelDir() + "\\fp32\\skeleton-tracking.cubemos"); // Read an RGB image of any size String cubemosSampleImagesDir = Common.DefaultResDir() + "\\images"; System.Drawing.Bitmap image1 = new System.Drawing.Bitmap(cubemosSampleImagesDir + ".\\skeleton_tracking_1.jpg"); System.Drawing.Bitmap image2 = new System.Drawing.Bitmap(cubemosSampleImagesDir + ".\\skeleton_tracking_2.jpg"); // Set the network input size to 256 for better accuracy int networkHeight = 256; // Send inference request and get the poses // Results container System.Collections.Generic.List <Cubemos.SkeletonTracking.Api.SkeletonKeypoints> lastResult; // ID of the image pipeline required to group images for tracking int pipelineID = 1; skeletontrackingApi.RunSkeletonTracking(ref image1, networkHeight, out lastResult, pipelineID); skeletontrackingApi.RunSkeletonTracking(ref image2, networkHeight, out lastResult, pipelineID); // Output detected skeletons Console.WriteLine("# Persons detected: " + lastResult.Count); for (int skeleton_index = 0; skeleton_index < lastResult.Count; skeleton_index++) { var skeleton = lastResult[skeleton_index]; Console.WriteLine("Skeleton #" + skeleton_index + " Tracking ID " + skeleton.id); for (int joint_index = 0; joint_index < skeleton.listJoints.Count; joint_index++) { Cubemos.SkeletonTracking.Api.Coordinate coordinate = skeleton.listJoints[joint_index]; Console.WriteLine("\tJoint coordinate #" + joint_index + ": " + coordinate.x + "; " + coordinate.y); } } Console.Write("Press <Enter> to exit... "); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Initializing console Skeleton Tracking sample with RealSense ... "); // Initialize logging to output all messages with severity level INFO or higher to the console Cubemos.Api.InitialiseLogging(Cubemos.LogLevel.CM_LL_ERROR, bWriteToConsole: true); Cubemos.SkeletonTracking.Api skeletontrackingApi; // Create cubemos Skeleton tracking Api handle and specify the directory containing a cubemos_license.json file try { skeletontrackingApi = new Cubemos.SkeletonTracking.Api(Common.DefaultLicenseDir()); } catch (Cubemos.Exception ex) { Console.WriteLine("If you haven't activated the SDK yet, please run post_installation script as described in the Getting Started Guide to activate your license."); Console.ReadLine(); return; } // Initialise cubemos DNN framework with the required model try { skeletontrackingApi.LoadModel(Cubemos.TargetComputeDevice.CM_CPU, Common.DefaultModelDir() + "\\fp32\\skeleton-tracking.cubemos"); } catch (Cubemos.Exception ex) { Console.WriteLine(String.Format("Error during model loading. " + "Please verify the model exists at the path {0}. Details: {1}", Common.DefaultModelDir() + "\\fp32\\skeleton-tracking.cubemos", ex)); Console.ReadLine(); return; } Console.Write("Hold the Intel RealSense with person(s) in scene and hit <ENTER>... "); Console.ReadLine(); // Initialise the intel realsense pipeline as an acquisition device Pipeline pipeline = new Pipeline(); Config cfg = new Config(); Context context = new Intel.RealSense.Context(); cfg.EnableStream(Intel.RealSense.Stream.Color, 1280, 720, Format.Bgr8, framerate: 30); PipelineProfile pp = pipeline.Start(cfg); // Set the network input size to 128 for faster inference int networkHeight = 128; // Acquire a single color frame and run Skeleton Tracking on it using (var frames = pipeline.WaitForFrames()) { var frame = frames.ColorFrame.DisposeWith(frames); System.Drawing.Bitmap inputImage = new System.Drawing.Bitmap(frame.Width, frame.Height, frame.Stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, frame.Data); System.Collections.Generic.List <Cubemos.SkeletonTracking.Api.SkeletonKeypoints> skeletonKeypoints; // Send inference request and get the skeletons skeletontrackingApi.RunSkeletonTracking(ref inputImage, networkHeight, out skeletonKeypoints); // Output detected skeletons Console.WriteLine("# Persons detected: " + skeletonKeypoints.Count); for (int skeleton_index = 0; skeleton_index < skeletonKeypoints.Count; skeleton_index++) { var skeleton = skeletonKeypoints[skeleton_index]; Console.WriteLine("Skeleton #" + skeleton_index); for (int joint_index = 0; joint_index < skeleton.listJoints.Count; joint_index++) { Cubemos.SkeletonTracking.Api.Coordinate coordinate = skeleton.listJoints[joint_index]; Console.WriteLine("\tJoint coordinate #" + joint_index + ": " + coordinate.x + "; " + coordinate.y); } } } Console.Write("Press <Enter> to exit... "); Console.ReadLine(); }