static void CheckUserDataSupport(Zivid.NET.Camera camera) { if (camera.UserDataMaxSizeBytes == 0) { throw new System.InvalidOperationException("This camera does not support user data"); } }
static Zivid.NET.Frame AssistedCapture(Zivid.NET.Camera camera) { var suggestSettingsParameters = new Zivid.NET.CaptureAssistant.SuggestSettingsParameters { AmbientLightFrequency = Zivid.NET.CaptureAssistant.SuggestSettingsParameters.AmbientLightFrequencyOption.none, MaxCaptureTime = Duration.FromMilliseconds(800) }; var settings = Zivid.NET.CaptureAssistant.Assistant.SuggestSettings(camera, suggestSettingsParameters); return(camera.Capture(settings)); }
static List <HandEyeInput> ReadInputs(Zivid.NET.Camera camera) { var input = new List <HandEyeInput>(); var currentPoseId = 0U; var beingInput = true; Interaction.ExtendInputBuffer(2048); do { switch (Interaction.EnterCommand()) { case CommandType.AddPose: try { var robotPose = Interaction.EnterRobotPose(currentPoseId); using (var frame = Interaction.AssistedCapture(camera)) { Console.Write("Detecting checkerboard in point cloud"); var result = Detector.DetectFeaturePoints(frame.PointCloud); if (result) { Console.WriteLine("OK"); input.Add(new HandEyeInput(robotPose, result)); ++currentPoseId; } else { Console.WriteLine("FAILED"); } } } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); continue; } break; case CommandType.Calibrate: beingInput = false; break; case CommandType.Unknown: Console.WriteLine("Error: Unknown command"); break; } } while (beingInput); return(input); }
static Tuple <double[], int[], double[]> GetExposureValues(Zivid.NET.Camera camera) { if (camera.Info.ModelName.Substring(0, 9) == "Zivid One") { double[] aperture = { 8.0, 4.0, 4.0 }; int[] exposureTime = { 10000, 10000, 40000 }; double[] gain = { 1.0, 1.0, 2.0 }; return(Tuple.Create <double[], int[], double[]>(aperture, exposureTime, gain)); } if (camera.Info.ModelName.Substring(0, 9) == "Zivid Two") { double[] aperture = { 5.66, 2.38, 1.8 }; int[] exposureTime = { 1677, 5000, 100000 }; double[] gain = { 1.0, 1.0, 1.0 }; return(Tuple.Create <double[], int[], double[]>(aperture, exposureTime, gain)); } throw new Exception("Unknown camera model, " + camera.Info.ModelName.Substring(0, 9)); }
static void Clear(Zivid.NET.Camera camera) { Write(camera, ""); }
static void Write(Zivid.NET.Camera camera, string dataString) { camera.WriteUserData(System.Text.Encoding.ASCII.GetBytes(dataString)); }
static string Read(Zivid.NET.Camera camera) { return(System.Text.Encoding.ASCII.GetString(camera.UserData.ToArray())); }