//Gets color frame from kinect private void Ksensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e) { ColorImageFrame colorFrame = e.OpenColorImageFrame(); BitmapSource bmap = ImageToBitmap(colorFrame); Colorstream.Source = bmap; //Each function executed every other time if (i == 1) { Imageprocessing.Proc(bmap, Canvas3, Outputstream); XB = Imageprocessing.XBlue; YB = Imageprocessing.YBlue; XR = Imageprocessing.XRed; YR = Imageprocessing.YRed; //Sets output screen Imageprocessing.OutputScreen(Outputstream, ObjectFrame); i = 0; } else { i = 1; } }
private void button2_Click(object sender, EventArgs e) { //p.Image = pictureBox1.Image; //p.GrayscaleM(); //p._displayWindow = richTextBox1; double nilai = 0; try { nilai = Convert.ToDouble(textBox1.Text); //range 0.5 - 25 if (textBox1.Text == "") { MessageBox.Show("Nilai kosong!!", "Important message", MessageBoxButtons.OK); } } catch (Exception) { MessageBox.Show("Nilai kosong!!", "Important message", MessageBoxButtons.OK); } Imageprocessing pkt = new Imageprocessing(); // Mengambil citra dari pictureBox1 Bitmap resizegmbr = new Bitmap(resizeImage(pictureBox1.Image, new Size(160, 120))); Bitmap gambar = new Bitmap(resizegmbr); // Memanggil method CitraPangkat dari object pkt pkt.CitraPangkat(gambar, nilai); // menampilkan hasil pada pictureBox2 pictureBox2.Image = gambar; try { byte[] x = imageToByteArray(pictureBox1.Image); //byte[] x = BmpToArray(new Bitmap(pictureBox1.Image)); //byte[] x = BmpToArray(gambar, 200, 200); /*string value = ASCIIEncoding.ASCII.GetString(x); * richTextBox1.AppendText(value);*/ string hex = BitConverter.ToString(x).Replace("-", string.Empty); string l = Convert.ToString(hex.Length); //string hex = getstring(x); //string hex = BitConverter.ToString(x); //string hex = Encoding.Default.GetString(x); richTextBox1.AppendText(hex); label1.Text = l; } catch { MessageBox.Show("gagal"); } }
public Form1() { InitializeComponent(); p = new Imageprocessing(); }