/// <summary> /// Initialize this frame with the received data by Device.Stream_GetFrame(). /// </summary> /// <param name="data">image data</param> /// <param name="cam">camera instance</param> /// <param name="log">metri log from camera instance</param> internal FrameData(byte[] data, VisionaryT cam, MetriLog log) { ImageBuffer = data; this.cam = cam; this.log = log; SetDefaultValues(); Parse(); }
//private void TestBltCLI() //{ // // ip: 192.168.1.146 // BluetechnixCLI cam = new BluetechnixCLI(); // cam.IPAddress = "192.168.1.146"; // cam.Connect(); // Console.WriteLine("Got camera: {0}", cam.SerialNumber); // cam.MedianFilter = true; // cam.FrameAverageFilter = true; // cam.BilateralFilter = true; // cameras.Add(cam); // cam.ActivateChannel(ChannelNames.Color); // cam.SelectChannel(ChannelNames.Color); // bgWorkerGetFrames.RunWorkerAsync(); //} private void TestV3S() { VisionaryT cam = new VisionaryT(); cam.IPAddress = "192.168.1.137"; // DHCP cam.Connect(); // get distance frame { cam.ActivateChannel(ChannelNames.Distance); cam.SelectChannel(ChannelNames.Distance); cam.Update(); FloatCameraImage distances = (FloatCameraImage)cam.CalcSelectedChannel(); float min = distances[0]; float max = distances[0]; float mean = 0F; float mid = distances[(int)(cam.Width * (cam.Height / 2) + cam.Width / 2)]; for (int i = 0; i < cam.Height; ++i) { for (int j = 0; j < cam.Width; ++j) { float val = distances[i, j]; if (val < min) { min = val; } if (val > max) { max = val; } mean += val; } } mean /= cam.Height * cam.Width; Console.WriteLine("Distances: Min: {0}m Max: {1}m Mean: {2}m Mid: {3}m", min, max, mean, mid); } cam.ActivateChannel(ChannelNames.Intensity); cam.SelectChannel(ChannelNames.Intensity); cameras.Add(cam); bgWorkerGetFrames.RunWorkerAsync(); //cam.Disconnect(); }
/// <summary> /// Creates a new Device instance which can be used to handle the low level TCP communication /// between camera and client. /// </summary> /// <param name="ipAddress">IP address of client</param> /// <param name="cam">MetriCam2 camera object used for exceptions</param> /// <param name="log">MetriLog</param> internal Device(string ipAddress, VisionaryT cam, MetriLog log) { this.cam = cam; this.log = log; try { sockData = new TcpClient(ipAddress, TCP_PORT_BLOBSERVER); } catch (Exception ex) { string msg = string.Format("{0}: Failed to connect to IP {1}{2}Reason: {3}", cam.Name, ipAddress, Environment.NewLine, ex.Message); log.Error(msg); throw new Exceptions.ConnectionFailedException(msg, ex); } streamData = sockData.GetStream(); // say "hello" to camera byte[] hbBytes = Encoding.ASCII.GetBytes(HEARTBEAT_MSG); streamData.Write(hbBytes, 0, hbBytes.Length); }