public Settings(List<String> audioDeviceLst, List<String> vidDeviceLst, LiveDeviceSource deviceSource) { InitializeComponent(); this.deviceSource = deviceSource; this.audioDeviceLst = audioDeviceLst; this.vidDeviceLst = vidDeviceLst; //then populate the GUI populateComboBoxes(); //load values into the program from a file readFile(); //display the current path/options to the GUI to the GUI pathBox.Text = settings.savePath; audioDevBox.SelectedItem = settings.audioDev; vidDevBox.SelectedItem = settings.vidDev; //fill local variables with the versions just read from the XML file this.minYCbCr = settings.minYCbCr; this.maxYCbCr = settings.maxYCbCr; this.percentSkin = settings.percentSkin; this.msRefresh = settings.msRefresh; this.cycleConfirm = settings.cycleConfirm; //Display the color data displayColorTextBox(); //set ok/cancel btns this.saveBtn.DialogResult = DialogResult.OK; this.cancelBtn.DialogResult = DialogResult.Cancel; }
public SettingsData(String audioDev, String vidDev, String savePath, YCbCr minYCbCr, YCbCr maxYCbCr, float percentSkin, int msRefresh, int cycleConfirm) { this.audioDev = audioDev; this.vidDev = vidDev; this.savePath = savePath; //color values this.minYCbCr = minYCbCr; this.maxYCbCr = maxYCbCr; this.percentSkin = percentSkin; this.msRefresh = msRefresh; this.cycleConfirm = cycleConfirm; }
private void recordColorTextBox() { //YCbCr this.minYCbCr = new YCbCr(Convert.ToInt32(this.minYBox.Text), Convert.ToInt32(this.minCbBox.Text), Convert.ToInt32(this.minCrBox.Text)); this.maxYCbCr = new YCbCr(Convert.ToInt32(this.maxYBox.Text), Convert.ToInt32(this.maxCbBox.Text), Convert.ToInt32(this.maxCrBox.Text)); //other 3 values this.percentSkin = Convert.ToSingle(this.percentSkinBox.Text); this.msRefresh = Convert.ToInt32(this.refreshBox.Text); this.cycleConfirm = Convert.ToInt32(this.cycleBox.Text); }
/// <summary> /// Takes a bitmap image and produces a "PercentFace" visualization of the image and the percentage value /// Cuts calculations down significantly when trying to detect the face and visualize it to the user /// </summary> /// <param name="bmp"></param> /// <returns></returns> public static VisualPercent PercentFaceBoth(Bitmap bmp, YCbCr minYCbCr, YCbCr maxYCbCr) { float facePixels = 0f; float totalPixels = ((float)bmp.Height * (float)bmp.Width); //copies over from the original Bitmap newMap = new Bitmap(bmp); //search through each pixel in the bit map for (int col = 0; col < bmp.Height; col++) { for (int row = 0; row < bmp.Width; row++) { //Console.WriteLine(bmp.Width + " " + bmp.Height); //Console.WriteLine("Row: " + row + " Col: " + col); //construct a YCbCr value set for each pixel (THIS MAY BE SLOW) YCbCr temp = new YCbCr(bmp.GetPixel(row, col)); //pixels that pass both tests are white if (((temp.Cr >= minYCbCr.Cr) && (temp.Cr <= maxYCbCr.Cr)) && ((temp.Cb >= minYCbCr.Cb) && (temp.Cb <= maxYCbCr.Cb)) && ((temp.Y >= minYCbCr.Y) && (temp.Y <= maxYCbCr.Y))) { newMap.SetPixel(row, col, bmp.GetPixel(row, col)); //Keepin' that precesion facePixels += 1f; } else //pixels that fail both tests are black newMap.SetPixel(row, col, Color.Black); } } //return both a bitmap and a percentage value VisualPercent newVisualPercent = new VisualPercent(); newVisualPercent.MAP = newMap; newVisualPercent.PERCENT = facePixels / totalPixels; return(newVisualPercent); }
/// <summary> /// Takes a bitmap image and produces a "PercentFace" visualization of the image /// </summary> /// <param name="bmp"></param> /// <returns></returns> public static Bitmap PercentFaceBmp(Bitmap bmp, YCbCr minYCbCr, YCbCr maxYCbCr) { //copies over from the original Bitmap newMap = new Bitmap(bmp); //search through each pixel in the bit map for (int col = 0; col < bmp.Height; col++) { for (int row = 0; row < bmp.Width; row++) { //Console.WriteLine(bmp.Width + " " + bmp.Height); //Console.WriteLine("Row: " + row + " Col: " + col); //construct a YCbCr value set for each pixel (THIS MAY BE SLOW) YCbCr temp = new YCbCr(bmp.GetPixel(row,col)); //pixels that pass both tests are white if (((temp.Cr >= minYCbCr.Cr) && (temp.Cr <= maxYCbCr.Cr)) && ((temp.Cb >= minYCbCr.Cb) && (temp.Cb <= maxYCbCr.Cb)) && ((temp.Y >= minYCbCr.Y) && (temp.Y <= maxYCbCr.Y))) newMap.SetPixel(row, col, bmp.GetPixel(row,col)); //Color.White /* //pixels that pass just the red test are red else if ((temp.Cr >= MINCr) && (temp.Cr <= MAXCr)) newMap.SetPixel(row, col, Color.Red); //pixels that pass just the blue test are blue else if ((temp.Cb >= MINCb) && (temp.Cb <= MAXCb)) newMap.SetPixel(row, col, Color.Blue); */ else //pixels that fail both tests are black newMap.SetPixel(row, col, Color.Black); } } return(newMap); }
/// <summary> /// /// </summary> /// <param name="bmp"></param> /// <returns></returns> public static float PercentFace(Bitmap bmp, YCbCr minYCbCr, YCbCr maxYCbCr) { float facePixels = 0f; float totalPixels = ((float)bmp.Height * (float)bmp.Width); //search through each pixel in the bit map for (int col = 0; col < bmp.Height; col++) { for (int row = 0; row < bmp.Width; row++) { //construct a YCbCr value set for each pixel (THIS MAY BE SLOW) YCbCr temp = new YCbCr(bmp.GetPixel(row, col)); if ((temp.Cr >= minYCbCr.Cr) && (temp.Cr <= maxYCbCr.Cr)) { if ((temp.Cb >= minYCbCr.Cb) && (temp.Cb <= maxYCbCr.Cb)) { if ((temp.Y >= minYCbCr.Y) && (temp.Y <= maxYCbCr.Y)) { //Keepin' that precesion facePixels += 1f; } } } } } return (facePixels / totalPixels); }
/// <summary> /// Converts a bitmap image to an matrix of YCbCr values /// </summary> public static YCbCr[,] BitmapToYCbCr(Bitmap bmp) { YCbCr[,] ColorMatrix = new YCbCr[bmp.Height,bmp.Width]; //fill dat matrix! for (int col = 0; col < bmp.Height; col++) { for (int row = 0; row < bmp.Width; row++) { ColorMatrix[row, col] = new YCbCr(bmp.GetPixel(row, col)); } } return(ColorMatrix); }