Example #1
0
        public static Bitmap TakeBitmap(MyroImageType type)
        {
            if (webcamAdapter != null)
            {
                var r = takePicture(type);

                Bitmap ret;
                System.Drawing.Imaging.BitmapData bitmapData;
                ret = new Bitmap(r.Width, r.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                if (r.Image.Length != 3 * ret.Width * ret.Height)
                {
                    throw new Exception("Image returned from QueryFrame in TakeBitmap is the wrong size");
                }

                // Get bitmap data
                bitmapData = ret.LockBits(
                    new Rectangle(0, 0, ret.Width, ret.Height),
                    System.Drawing.Imaging.ImageLockMode.WriteOnly,
                    System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                // Copy frame
                System.Runtime.InteropServices.Marshal.Copy(
                    r.Image, 0, bitmapData.Scan0, 3 * ret.Width * ret.Height);

                ret.UnlockBits(bitmapData);
                return(ret);
            }
            else
            {
                throw new MyroNotInitializedException();
            }
        }
Example #2
0
        private void OnImageTypeChange(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem item = ImageTypesBox.SelectedItem as ComboBoxItem;

            // This could be null because nothing is selected, or because
            // of a casting error (the latter should never happen).
            if (item != null)
            {
                curType = (MyroImageType)item.Tag;
            }
        }
Example #3
0
        public void QueryFrame(MyroImageType type, out int Width, out int Height, out byte[] Image)
        {
            var r = RSUtils.ReceiveSync(queue,
                                        opPort.QueryFrame(new webcam.QueryFrameRequest()
            {
                Format = type.Guid
            }),
                                        Params.DefaultRecieveTimeout);

            Width  = r.Size.Width;
            Height = r.Size.Height;
            Image  = r.Frame;
        }
Example #4
0
 public static MyroImage takePicture(MyroImageType type)
 {
     if (webcamAdapter != null)
     {
         int    width, height;
         byte[] image;
         webcamAdapter.Adapter.QueryFrame(type, out width, out height, out image);
         return(new MyroImage()
         {
             Width = width,
             Height = height,
             Image = image
         });
     }
     else
     {
         throw new MyroNotInitializedException();
     }
 }
Example #5
0
 public static MyroImage TakePicture(string type)
 {
     return(takePicture(MyroImageType.CreateFromShortName(type.ToLower())));
 }