Exemple #1
0
 private void OnClosing(object sender, FormClosingEventArgs e)
 {
     if (toupcam_ != null)
     {
         toupcam_.Close();
         toupcam_ = null;
     }
 }
Exemple #2
0
 private void OnEventDisconnected()
 {
     if (toupcam_ != null)
     {
         toupcam_.Close();
         toupcam_ = null;
     }
     MessageBox.Show("The camera is disconnected, maybe has been pulled out.");
 }
Exemple #3
0
 private void OnEventError()
 {
     if (toupcam_ != null)
     {
         toupcam_.Close();
         toupcam_ = null;
     }
     MessageBox.Show("Error");
 }
Exemple #4
0
        private void savefile(IntPtr pData, ref ToupCam.BITMAPINFOHEADER header)
        {
            Bitmap     bmp     = new Bitmap(header.biWidth, header.biHeight, PixelFormat.Format24bppRgb);
            BitmapData bmpdata = bmp.LockBits(new Rectangle(0, 0, header.biWidth, header.biHeight), ImageLockMode.WriteOnly, bmp.PixelFormat);

            ToupCam.CopyMemory(bmpdata.Scan0, pData, header.biSizeImage);

            bmp.UnlockBits(bmpdata);

            bmp.Save("toupcamdemowinformcs2.jpg");
        }
        public Camera()
        {
            ToupCam.Instance[] arr = ToupCam.Enum();
            if (arr.Length < 0)
            {
                MessageBox.Show("No Device");
            }
            else
            {
                myCamera  = new ToupCam();
                image_pbx = new PictureBox();

                if (!myCamera.Open(arr[0].id))
                {
                    myCamera = null;
                }
            }
        }
Exemple #6
0
        private void OnStart(object sender, EventArgs e)
        {
            if (toupcam_ != null)
            {
                return;
            }

            ToupCam.Instance[] arr = ToupCam.Enum();
            if (arr.Length <= 0)
            {
                MessageBox.Show("no device");
            }
            else
            {
                toupcam_ = new ToupCam();
                if (!toupcam_.Open(arr[0].id))
                {
                    toupcam_ = null;
                }
                else
                {
                    checkBox1.Enabled        = true;
                    trackBar1.Enabled        = true;
                    trackBar2.Enabled        = true;
                    trackBar3.Enabled        = true;
                    comboBox1.Enabled        = true;
                    button2.Enabled          = true;
                    button3.Enabled          = true;
                    button2.ContextMenuStrip = null;
                    InitSnapContextMenuAndExpoTimeRange();

                    trackBar2.SetRange(2000, 15000);
                    trackBar3.SetRange(200, 2500);
                    OnEventTempTint();

                    uint resnum = toupcam_.ResolutionNumber;
                    uint eSize  = 0;
                    if (toupcam_.get_eSize(out eSize))
                    {
                        for (uint i = 0; i < resnum; ++i)
                        {
                            int w = 0, h = 0;
                            if (toupcam_.get_Resolution(i, out w, out h))
                            {
                                comboBox1.Items.Add(w.ToString() + "*" + h.ToString());
                            }
                        }
                        comboBox1.SelectedIndex = (int)eSize;

                        int width = 0, height = 0;
                        if (toupcam_.get_Size(out width, out height))
                        {
                            bmp_ = new Bitmap(width, height, PixelFormat.Format24bppRgb);
                            ev_  = new DelegateEvent(DelegateOnEvent);
                            if (!toupcam_.StartPullModeWithCallback(new ToupTek.ToupCam.DelegateEventCallback(DelegateOnEventCallback)))
                            {
                                MessageBox.Show("failed to start device");
                            }
                            else
                            {
                                bool autoexpo = true;
                                toupcam_.get_AutoExpoEnable(out autoexpo);
                                checkBox1.Checked = autoexpo;
                                trackBar1.Enabled = !checkBox1.Checked;
                            }
                        }
                    }
                }
            }
        }
Exemple #7
0
        private void OnStart(object sender, EventArgs e)
        {
            if (toupcam_ != null)
            {
                return;
            }

            ToupCam.Instance[] arr = ToupCam.Enum();
            if (arr.Length <= 0)
            {
                MessageBox.Show("no device");
            }
            else
            {
                toupcam_ = new ToupCam();
                if (!toupcam_.Open(arr[0].id))
                {
                    toupcam_ = null;
                }
                else
                {
                    label16.Enabled    = true;
                    textBox1.Enabled   = true;
                    checkBox1.Enabled  = true;
                    checkBox12.Enabled = true;
                    checkBox2.Enabled  = true;
                    checkBox4.Enabled  = true;
                    checkBox5.Enabled  = true;
                    checkBox6.Enabled  = true;
                    checkBox7.Enabled  = true;
                    trackBar1.Enabled  = true;
                    trackBar2.Enabled  = true;
                    //trackBar3.Enabled = true;
                    trackBar4.Enabled    = true;
                    trackBar5.Enabled    = true;
                    comboBox1.Enabled    = true;
                    button2.Enabled      = true;
                    radioButton1.Enabled = true;
                    radioButton2.Enabled = true;
                    // button3.Enabled = true;
                    button2.ContextMenuStrip = null;
                    InitSnapContextMenuAndExpoTimeRange();

                    trackBar2.SetRange(0, 255);
                    //trackBar3.SetRange(-100, 255);
                    OnEventTempTint();

                    uint resnum = toupcam_.ResolutionNumber;
                    uint eSize  = 0;
                    if (toupcam_.get_eSize(out eSize))
                    {
                        for (uint i = 0; i < resnum; ++i)
                        {
                            int w = 0, h = 0;
                            if (toupcam_.get_Resolution(i, out w, out h))
                            {
                                comboBox1.Items.Add(w.ToString() + "*" + h.ToString());
                            }
                        }
                        comboBox1.SelectedIndex = (int)eSize;

                        int width = 0, height = 0;
                        if (toupcam_.get_Size(out width, out height))
                        {
                            bmp_ = new Bitmap(width, height, PixelFormat.Format24bppRgb);
                            ev_  = new DelegateEvent(DelegateOnEvent);
                            if (!toupcam_.StartPullModeWithCallback(new ToupTek.ToupCam.DelegateEventCallback(DelegateOnEventCallback)))
                            {
                                MessageBox.Show("failed to start device");
                            }
                            else
                            {
                                bool autoexpo = true;
                                //toupcam_.get_AutoExpoEnable(out autoexpo);
                                toupcam_.put_AutoExpoEnable(false);
                                checkBox1.Checked = false;// autoexpo;
                                trackBar1.Enabled = !checkBox1.Checked;
                            }
                        }
                        if (toupcam_.get_ExpoAGain(out ushort val))
                        {
                            trackBar2.Value = val;
                            trackBar2.Update();
                        }
                        if (toupcam_.get_Saturation(out int val2))
                        {
                            //trackBar3.Value = val2;
                            //trackBar3.Update();
                        }

                        SetLimits(width, height);
                        started = true;
                    }
                }
            }

            try
            {
                ApplySettings();
                dbsync.Elapsed            += TimerAction;
                dbsync.SynchronizingObject = this;
                dbsync.Start();
            }
            catch { }
        }