コード例 #1
0
        /// <summary>
        /// Init the CameraControl
        /// </summary>
        public IntermecCameraControl2()
        {
            InitializeComponent();

            //read res setting for snapshots and preview
            cameraRes  = (Camera.ImageResolutionType)ITCTools.registrySettings.cameraResolution;
            previewRes = (Camera.ImageResolutionType)ITCTools.registrySettings.previewResolution;

            //disable HW Trigger of Scanner
            YetAnotherHelperClass.setHWTrigger(false);
            try
            {
                if (IntermecCamera != null)
                {
                    addLog("Init() old IntermecCamera found. Disposing...");
                    // IntermecCamera.Streaming = false; //we dont switch streaming except once, ALL THE TIME
                    IntermecCamera.Dispose();
                    IntermecCamera = null;
                }
                else
                {
                    addLog("Init() Creating NEW IntermecCamera...");
                }

                //added to check for exception in creating a new Camera
                int iTry = 1; bool bSuccess = false; string sEx = "";
                do
                {
                    try
                    {
                        //using the same sequence as in sample CN3Camera
#if USE_LOW_RES
                        IntermecCamera = new Camera(CameraPreview, Camera.ImageResolutionType.Lowest);
#else
                        IntermecCamera = new Camera(CameraPreview, previewRes);// Camera.ImageResolutionType.Medium);
#endif
                        //IntermecCamera.PictureBoxUpdate = Camera.PictureBoxUpdateType.None;
                        IntermecCamera.PictureBoxUpdate = Camera.PictureBoxUpdateType.Fit; // None;// Fit;// AdjustToFrameSize;
                        bSuccess = true;
                        addLog("Init() IntermecCamera creation OK. Try " + iTry.ToString() + " of 3");
                    }
                    catch (Intermec.Multimedia.CameraException ex)
                    {
                        sEx = ex.Message;
                        addLog("Init() IntermecCamera creation failed. Try " + iTry.ToString() + " of 3 \nCameraException: \n" + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        sEx = ex.Message;
                        addLog("Init() IntermecCamera creation failed. Try " + iTry.ToString() + " of 3 \nException: \n" + ex.Message);
                    }
                    finally
                    {
                        GC.Collect();
                        iTry++;
                    }
                } while (iTry <= 3 && !bSuccess);
                if (IntermecCamera == null)
                {
                    throw new FileNotFoundException("IntermecCamera did not load. CnxDShow.cab installed?\nException: " + sEx);
                }

                // moving to end of INIT() does not fix problem with NO STREAM AT FIRST INIT()!
#if STREAMING_ON
                addLog("Init() 1 IntermecCamera.Streaming=true...");
                IntermecCamera.Streaming = true;   //we start with streaming = true ALL THE TIME
#else
                addLog("Init() 1 IntermecCamera.Streaming=true...");
                IntermecCamera.Streaming = true;   //we start with streaming = true ALL THE TIME
#endif
                #region AutoFlash
                try
                {
                    addLog("IntermecCamera testing Flash.Available...");
                    if (IntermecCamera.Features.Flash.Available)
                    {
                        addLog("IntermecCamera testing Flash.Available OK. Changing to Auto...");
                        if (IntermecCamera.Features.Flash.SupportsAutoMode)
                        {
                            addLog("IntermecCamera testing Flash.Available OK. Changed to Auto OK");
                            IntermecCamera.Features.Flash.Auto = true;
                        }
                        else
                        {
                            addLog("IntermecCamera testing Flash.Available OK. No AutoMode support");
                        }
                    }
                    else
                    {
                        addLog("IntermecCamera testing Flash.Available OK. No Flash support");
                    }
                }
                catch (Exception)
                {
                    addLog("IntermecCamera testing Flash throwed exception.");
                }
                #endregion
#if MYDEBUG
                //for DEBUG only
                System.Diagnostics.Debug.WriteLine("CurrentViewfinderResolution 1=" +
                                                   IntermecCamera.CurrentViewfinderResolution.Width.ToString() + "x" +
                                                   IntermecCamera.CurrentViewfinderResolution.Height.ToString());
#endif
                //System.Diagnostics.Debug.WriteLine("Current viewfinderRes 2=" +
                //    IntermecCamera.CurrentViewfinderResolution.Width.ToString() + "x" +
                //    IntermecCamera.CurrentViewfinderResolution.Height.ToString());

                //moved to end
                //######## IntermecCamera.SnapshotEvent += new SnapshotEventHandler(IntermecCamera_SnapshotEvent);

                //IntermecCamera.SnapshotFile.Filename = "FotoKamera_"+ DateTime.Now.ToShortDateString()+ "_" + DateTime.Now.ToShortTimeString() + ".jpg";
                IntermecCamera.SnapshotFile.ImageFormatType = Camera.ImageType.JPG;
                //WARNING, if you dont set this property, snapshot may fail with garbage image
#if USE_LOW_RES
                IntermecCamera.SnapshotFile.ImageResolution = Camera.ImageResolutionType.Lowest;
#else
                IntermecCamera.SnapshotFile.ImageResolution = cameraRes;// Camera.ImageResolutionType.Medium;
#endif
                IntermecCamera.SnapshotFile.JPGQuality      = 90;
                IntermecCamera.SnapshotFile.Directory       = "\\Temp";
                IntermecCamera.SnapshotFile.Filename        = _sFileTemplate;
                IntermecCamera.SnapshotFile.FilenamePadding = Camera.FilenamePaddingType.IncrementalCounter; // None;// Camera.FilenamePaddingType.IncrementalCounter;

                showSnapshot(true);                                                                          //show a still image

#if STREAMING_ON
                addLog("Init(): we DO NOT SWITCH streaming");
#else
                addLog("Init() IntermecCamera.Streaming=false...");
                IntermecCamera.Streaming = false;   //we use streaming=true ALL THE TIME
#endif

                ITCTools.KeyBoard.mapKey(); //map the scan button to Event Index 5

                //start the scan button watch thread
                addLog("IntermecBarcodescanControl: starting named event watch thread...");
                waitThread = new System.Threading.Thread(waitLoop);
                waitThread.Start();
                //######### TEST ####### does not fix problem with NO STREAM AT FIRST INIT()!
                //addLog("Init() IntermecCamera.Streaming=true at END of INIT()...");
                //IntermecCamera.Streaming = true;   //we use streaming=true ALL THE TIME

                //CameraPreview.Refresh();
                //ImageIsInPreview();

                // Hook the snapshot event.
                IntermecCamera.SnapshotEvent += new SnapshotEventHandler(IntermecCamera_SnapshotEvent);
            }
            catch (Intermec.Multimedia.CameraException ex)
            {
                addLog("CameraException in CameraInit. Is the runtime 'CNxDShow.CAB' installed? " + ex.Message);
            }
            catch (Exception ex)
            {
                addLog("Exception in CameraInit. Is the runtime 'CNxDShow.CAB' installed?\n" + ex.Message);
            }
            if (IntermecCamera == null)
            {
                System.Diagnostics.Debug.WriteLine("Exception in CameraInit. Is the runtime 'CNxDShow.CAB' installed?");
                throw new FileNotFoundException("Missing Runtimes. Is CNxDShow.CAB installed?");
            }

            //if (IntermecCamera == null)
            //    return;
        }
コード例 #2
0
ファイル: CamSettings.cs プロジェクト: hjgode/eMdiMail
            public settings()
            {
                viewfinderresolution = Camera.ImageResolutionType.Medium;
                resolution = new Camera.Resolution();
                resolution.BPP = 24;
                resolution.Height = 640;
                resolution.Width = 480;
                resolution.ResolutionID = 10;

                ImprintCaptionPos = Camera.ImprintCaptionPosType.Disabled;
                ImprintCaptionString = "";

                ImprintCompassPosType = Camera.ImprintCompassPosType.Disabled;

                ImprintDateTimePos = Camera.ImprintDateTimePosType.Disabled;

                DisplayCameraInfo = false;
                DisplayHistogram = false;

                _DigitalZoomFactor = 1.00f;
                ImprintInfo = false;
            }
コード例 #3
0
ファイル: CamSettings.cs プロジェクト: hjgode/eMdiMail
 public settings(Camera cam, Camera.ImageResolutionType _viewfinderResolution, Camera.Resolution _snapshotResolution)
 {
     _cam = cam;
     viewfinderresolution = _viewfinderResolution;
     resolution = _snapshotResolution;
     readFromCam();
 }
コード例 #4
0
        /// <summary>
        /// Init the CameraControl
        /// </summary>
        public IntermecCameraControl2()
        {
            InitializeComponent();

            //read res setting for snapshots and preview
            cameraRes = (Camera.ImageResolutionType)ITCTools.registrySettings.cameraResolution;
            previewRes = (Camera.ImageResolutionType)ITCTools.registrySettings.previewResolution;

            //disable HW Trigger of Scanner
            YetAnotherHelperClass.setHWTrigger(false);
            try
            {
                if (IntermecCamera != null)
                {
                    addLog("Init() old IntermecCamera found. Disposing...");
                    // IntermecCamera.Streaming = false; //we dont switch streaming except once, ALL THE TIME
                    IntermecCamera.Dispose();
                    IntermecCamera = null;
                }
                else
                    addLog("Init() Creating NEW IntermecCamera...");

                //added to check for exception in creating a new Camera
                int iTry = 1; bool bSuccess = false; string sEx = "";
                do
                {
                    try
                    {
                        //using the same sequence as in sample CN3Camera
#if USE_LOW_RES
                        IntermecCamera = new Camera(CameraPreview, Camera.ImageResolutionType.Lowest);
#else
                        IntermecCamera = new Camera(CameraPreview, previewRes);// Camera.ImageResolutionType.Medium);
#endif
                        //IntermecCamera.PictureBoxUpdate = Camera.PictureBoxUpdateType.None;
                        IntermecCamera.PictureBoxUpdate = Camera.PictureBoxUpdateType.Fit; // None;// Fit;// AdjustToFrameSize;
                        bSuccess = true;
                        addLog("Init() IntermecCamera creation OK. Try " + iTry.ToString() + " of 3");
                    }
                    catch (Intermec.Multimedia.CameraException ex)
                    {
                        sEx = ex.Message;
                        addLog("Init() IntermecCamera creation failed. Try " + iTry.ToString() + " of 3 \nCameraException: \n" + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        sEx = ex.Message;
                        addLog("Init() IntermecCamera creation failed. Try " + iTry.ToString() + " of 3 \nException: \n" + ex.Message);
                    }
                    finally
                    {
                        GC.Collect();
                        iTry++;
                    }
                } while (iTry <= 3 && !bSuccess);
                if (IntermecCamera == null)
                {
                    throw new FileNotFoundException("IntermecCamera did not load. CnxDShow.cab installed?\nException: " + sEx );
                }

                // moving to end of INIT() does not fix problem with NO STREAM AT FIRST INIT()!
#if STREAMING_ON
                addLog("Init() 1 IntermecCamera.Streaming=true...");
                IntermecCamera.Streaming = true;   //we start with streaming = true ALL THE TIME
#else
                addLog("Init() 1 IntermecCamera.Streaming=true...");
                IntermecCamera.Streaming = true;   //we start with streaming = true ALL THE TIME
#endif
                #region AutoFlash
                try
                {
                    addLog("IntermecCamera testing Flash.Available...");
                    if (IntermecCamera.Features.Flash.Available)
                    {
                        addLog("IntermecCamera testing Flash.Available OK. Changing to Auto...");
                        if (IntermecCamera.Features.Flash.SupportsAutoMode)
                        {
                            addLog("IntermecCamera testing Flash.Available OK. Changed to Auto OK");
                            IntermecCamera.Features.Flash.Auto = true;
                        }
                        else
                            addLog("IntermecCamera testing Flash.Available OK. No AutoMode support");
                    }
                    else
                        addLog("IntermecCamera testing Flash.Available OK. No Flash support");
                }
                catch (Exception)
                {
                    addLog("IntermecCamera testing Flash throwed exception.");

                }
                #endregion
#if MYDEBUG
                //for DEBUG only
                System.Diagnostics.Debug.WriteLine("CurrentViewfinderResolution 1=" +
                    IntermecCamera.CurrentViewfinderResolution.Width.ToString() + "x" +
                    IntermecCamera.CurrentViewfinderResolution.Height.ToString());
#endif
                //System.Diagnostics.Debug.WriteLine("Current viewfinderRes 2=" +
                //    IntermecCamera.CurrentViewfinderResolution.Width.ToString() + "x" +
                //    IntermecCamera.CurrentViewfinderResolution.Height.ToString());
                
                //moved to end
                //######## IntermecCamera.SnapshotEvent += new SnapshotEventHandler(IntermecCamera_SnapshotEvent);

                //IntermecCamera.SnapshotFile.Filename = "FotoKamera_"+ DateTime.Now.ToShortDateString()+ "_" + DateTime.Now.ToShortTimeString() + ".jpg";
                IntermecCamera.SnapshotFile.ImageFormatType = Camera.ImageType.JPG;
                //WARNING, if you dont set this property, snapshot may fail with garbage image
#if USE_LOW_RES
                IntermecCamera.SnapshotFile.ImageResolution = Camera.ImageResolutionType.Lowest;
#else
                IntermecCamera.SnapshotFile.ImageResolution = cameraRes;// Camera.ImageResolutionType.Medium;
#endif
                IntermecCamera.SnapshotFile.JPGQuality = 90;
                IntermecCamera.SnapshotFile.Directory = "\\Temp";
                IntermecCamera.SnapshotFile.Filename = _sFileTemplate;
                IntermecCamera.SnapshotFile.FilenamePadding = Camera.FilenamePaddingType.IncrementalCounter;// None;// Camera.FilenamePaddingType.IncrementalCounter;

                showSnapshot(true); //show a still image

#if STREAMING_ON
                addLog("Init(): we DO NOT SWITCH streaming");
#else
                addLog("Init() IntermecCamera.Streaming=false...");
                IntermecCamera.Streaming = false;   //we use streaming=true ALL THE TIME
#endif

                ITCTools.KeyBoard.mapKey(); //map the scan button to Event Index 5

                //start the scan button watch thread
                addLog("IntermecBarcodescanControl: starting named event watch thread...");
                waitThread = new System.Threading.Thread(waitLoop);
                waitThread.Start();
                //######### TEST ####### does not fix problem with NO STREAM AT FIRST INIT()!
                //addLog("Init() IntermecCamera.Streaming=true at END of INIT()...");
                //IntermecCamera.Streaming = true;   //we use streaming=true ALL THE TIME

                //CameraPreview.Refresh();
                //ImageIsInPreview();
                
                // Hook the snapshot event.
                IntermecCamera.SnapshotEvent += new SnapshotEventHandler(IntermecCamera_SnapshotEvent);
            }
            catch (Intermec.Multimedia.CameraException ex)
            {
                addLog("CameraException in CameraInit. Is the runtime 'CNxDShow.CAB' installed? " + ex.Message);
            }
            catch (Exception ex)
            {
                addLog("Exception in CameraInit. Is the runtime 'CNxDShow.CAB' installed?\n" + ex.Message);
            }
            if (IntermecCamera == null)
            {
                System.Diagnostics.Debug.WriteLine("Exception in CameraInit. Is the runtime 'CNxDShow.CAB' installed?");
                throw new FileNotFoundException("Missing Runtimes. Is CNxDShow.CAB installed?");
            }

            //if (IntermecCamera == null)
            //    return;
        }