void PixyCameraSensor_PixyCameraBlocksChanged(object sender, TargetingCameraEventArgs args) { //Debug.WriteLine("Pixy Camera Event: " + args); // On Arduino: // pixy.blocks[i].signature The signature number of the detected object (1-7) // pixy.blocks[i].x The x location of the center of the detected object (0 to 319) // pixy.blocks[i].y The y location of the center of the detected object (0 to 199) // pixy.blocks[i].width The width of the detected object (1 to 320) // pixy.blocks[i].height The height of the detected object (1 to 200) // Field of view: // goal 45 degrees left x=10 // middle x=160 // goal 45 degrees right x=310 // // goal 30 degrees up y=10 // middle y=90 // goal 30 degrees down y=190 // if (args.width * args.height > 500) // only large objects count { int bearing = GeneralMath.map(args.x, 0, 320, -45, 45); int inclination = GeneralMath.map(args.y, 0, 200, 30, -30); //Debug.WriteLine("Pixy: bearing=" + bearing + " inclination: " + inclination); lock (currentSensorsDataLock) { SensorsData sensorsData = new SensorsData(this.currentSensorsData); sensorsData.TargetingCameraBearingDegrees = bearing; sensorsData.TargetingCameraInclinationDegrees = inclination; sensorsData.TargetingCameraTimestamp = args.timestamp; //Debug.WriteLine(sensorsData.ToString()); this.currentSensorsData = sensorsData; } } }
private void RPiCameraSensor_TargetsChanged(object sender, TargetingCameraEventArgs args) { // Raspberry Pi based camera sensor works under Wheezy and uses OpenCV and Python to process // 240x320 frames and select areas with yellow color. Bearing, inclination and size of blobs is then // reported over HTTP to RPiCamera (derived from HttpServerBase). Frequency is around 10 FPS. //Debug.WriteLine("RPi Camera Event: " + args); // On Raspberry Pi: // pixy.blocks[i].signature The signature number of the detected object (1-7) // pixy.blocks[i].x The x location of the center of the detected object (0 to 319) // pixy.blocks[i].y The y location of the center of the detected object (0 to 199) // pixy.blocks[i].width The width of the detected object (1 to 320) // pixy.blocks[i].height The height of the detected object (1 to 200) // Field of view: // goal 45 degrees left x=10 // middle x=160 // goal 45 degrees right x=310 // // goal 30 degrees up y=10 // middle y=90 // goal 30 degrees down y=190 // if (args.width * args.height > 500) // only large objects count { int bearing = GeneralMath.map(args.x, 0, 320, 45, -45); int inclination = GeneralMath.map(args.y, 0, 200, 30, -30); //Debug.WriteLine("RPi: bearing=" + bearing + " inclination: " + inclination); lock (currentSensorsDataLock) { SensorsData sensorsData = new SensorsData(this.currentSensorsData); sensorsData.TargetingCameraBearingDegrees = bearing; sensorsData.TargetingCameraInclinationDegrees = inclination; sensorsData.TargetingCameraTimestamp = args.timestamp; //Debug.WriteLine(sensorsData.ToString()); this.currentSensorsData = sensorsData; } } }