void SetCameraInfo(CameraValues values)
    {
        Camera cam;

        if (values.stationary)
        {
            cam = lockCamera;
            followCamera.enabled   = false;
            lockCamera.enabled     = true;
            cam.orthographicSize   = values.size;
            cam.transform.position = new Vector3(values.position.x, values.position.y, -10);
            Debug.Log("SET THE LOCK CAMERA");
        }
        else
        {
            cam = followCamera;
            followCamera.enabled = true;
            lockCamera.enabled   = false;
            cam.orthographicSize = constants.defaultCamSize;
            CameraBox box = cam.GetComponent <CameraBox>();
            box.top    = values.cameraBox.yMin;
            box.bottom = values.cameraBox.yMax;
            box.left   = values.cameraBox.xMin;
            box.right  = values.cameraBox.xMax;
            Debug.Log("SET THE FOLLOW CAMERA");
        }

        playerController.cam = cam;
    }
Example #2
0
        public async Task <ActionResult> Edit(string id, FormCollection collection)
        {
            try
            {
                CameraValues cam = new CameraValues();
                if (TryUpdateModel(cam))
                {
                    cam.Id = new Guid(id);
                    var analyzer = (System.Web.HttpContext.Current.Application["Analyzers"] as List <VideoAnalyzer>)
                                   .FirstOrDefault(a => a.CameraId == cam.Id);
                    if (analyzer == null)
                    {
                        return(new HttpNotFoundResult());
                    }

                    analyzer.UpdateCamera(cam);
                    await db.UpdateCamera(cam);

                    db.UpdateCamera(cam, cameraPath);
                    return(RedirectToAction("WebCams"));
                }
                else
                {
                    ViewBag.Error = "Model doesn't fit";
                    return(RedirectToAction("Edit", id));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Generic Error occurred:\n" + ex.Message;
                return(RedirectToAction("Edit", id));
            }
        }
Example #3
0
        // POST: FaceSentiment/Delete/5
        public async Task <ActionResult> DeleteOK(string Id)
        {
            try
            {
                CameraValues cam = new CameraValues()
                {
                    Id = new Guid(Id)
                };

                var analyzers = (System.Web.HttpContext.Current.Application["Analyzers"] as List <VideoAnalyzer>);
                var analyzer  = analyzers.FirstOrDefault(a => a.CameraId == cam.Id);
                if (analyzer == null)
                {
                    ViewBag.Error = "Impossible to Delete the camera,\n camera not found";
                    return(RedirectToAction("WebCams"));
                }
                analyzer.Stop();
                analyzers.RemoveAll(a => a.CameraId == cam.Id);
                await db.DeleteCamera(cam);

                db.DeleteCamera(cam, cameraPath);
                return(RedirectToAction("WebCams"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Generic Error Occurred\n" + ex.Message;
                return(RedirectToAction("Delete", Id));
            }
        }
Example #4
0
        // InitializeCamera() opens the camera session via the canon sdk wrapper, sets the right modes and starts the live view image feed
        private bool InitializeCamera(Camera camera)
        {
            try
            {
                CameraWrapper.OpenSession(camera);
                Console.Write("Done.\nAdjusting settings...");
                CameraWrapper.SetSetting(EDSDK.PropID_Av, CameraValues.AV(Settings.Av));
                CameraWrapper.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(Settings.Tv));
                CameraWrapper.SetSetting(EDSDK.PropID_ISOSpeed, CameraValues.ISO(Settings.ISO));
                CameraWrapper.SetSetting(EDSDK.PropID_WhiteBalance, (uint)Settings.WB);

                Console.Write("Done.\nStarting LiveView...");
                LiveViewUpdating = false;
                CameraWrapper.StartLiveView();

                if (CameraWrapper.IsLiveViewOn)
                {
                    Console.WriteLine("Done.");
                    return(true);
                }
                Console.WriteLine("Error!\n-> LiveView dit not start for some reason.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error!\n-> " + e.Message);
            }
            return(false);
        }
Example #5
0
        private void OpenSession()
        {
            if (FInDeviceID[0] >= 0)
            {
                Refresh();

                if (CamList.Count > 0)
                {
                    CameraHandler.OpenSession(CamList[FInDeviceID[0]]);
                    string cameraname = CameraHandler.MainCamera.Info.szDeviceDescription;

                    FOutError[0] = (CameraHandler.GetSetting(EDSDK.PropID_AEMode) != EDSDK.AEMode_Mamual) ? "Camera is not in manual mode. Some features might not work!" : "";

                    FOutName.SliceCount = 1;
                    FOutPort.SliceCount = 1;

                    FOutName[0] = CamList[FInDeviceID[0]].Info.szDeviceDescription;
                    FOutPort[0] = CamList[FInDeviceID[0]].Info.szPortName;

                    TvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv);
                    AvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av);
                    ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed);

                    List <string> tv  = new List <string>();
                    List <string> av  = new List <string>();
                    List <string> iso = new List <string>();

                    tv.Add("None");
                    av.Add("None");
                    iso.Add("None");

                    foreach (int Tv in TvList)
                    {
                        tv.Add(CameraValues.TV((uint)Tv));
                    }
                    foreach (int Av in AvList)
                    {
                        av.Add(CameraValues.AV((uint)Av));
                    }
                    foreach (int ISO in ISOList)
                    {
                        iso.Add(CameraValues.ISO((uint)ISO));
                    }

                    EnumManager.UpdateEnum("Tv", tv[0], tv.ToArray());
                    EnumManager.UpdateEnum("Av", av[0], av.ToArray());
                    EnumManager.UpdateEnum("ISO", iso[0], iso.ToArray());

                    //isChanged = true;
                }
                else
                {
                    FOutError[0] = "";

                    FOutName.SliceCount = 0;
                    FOutPort.SliceCount = 0;
                }
            }
        }
Example #6
0
        private void OpenSession()
        {
            if (CameraListBox.SelectedIndex >= 0)
            {
                camera_connected = true;
                CameraHandler.OpenSession(CamList[CameraListBox.SelectedIndex]);
                SessionButton.Text = "Close Session";
                string cameraname = CameraHandler.MainCamera.Info.szDeviceDescription;
                SessionLabel.Text = cameraname;
                if (CameraHandler.GetSetting(EDSDK.PropID_AEMode) != EDSDK.AEMode_Manual)
                {
                    MessageBox.Show("Camera is not in manual mode. Some features might not work!");
                }
                AvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av);
                TvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv);
                ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed);
                foreach (int Av in AvList)
                {
                    AvCoBox.Items.Add(CameraValues.AV((uint)Av));
                }
                foreach (int Tv in TvList)
                {
                    TvCoBox.Items.Add(CameraValues.TV((uint)Tv));
                }
                foreach (int ISO in ISOList)
                {
                    ISOCoBox.Items.Add(CameraValues.ISO((uint)ISO));
                }
                AvCoBox.SelectedIndex  = AvCoBox.Items.IndexOf(CameraValues.AV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Av)));
                TvCoBox.SelectedIndex  = TvCoBox.Items.IndexOf(CameraValues.TV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Tv)));
                ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(CameraValues.ISO((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_ISOSpeed)));
                int wbidx = (int)CameraHandler.GetSetting((uint)EDSDK.PropID_WhiteBalance);
                switch (wbidx)
                {
                case EDSDK.WhiteBalance_Auto: WBCoBox.SelectedIndex = 0; break;

                case EDSDK.WhiteBalance_Daylight: WBCoBox.SelectedIndex = 1; break;

                case EDSDK.WhiteBalance_Cloudy: WBCoBox.SelectedIndex = 2; break;

                case EDSDK.WhiteBalance_Tangsten: WBCoBox.SelectedIndex = 3; break;

                case EDSDK.WhiteBalance_Fluorescent: WBCoBox.SelectedIndex = 4; break;

                case EDSDK.WhiteBalance_Strobe: WBCoBox.SelectedIndex = 5; break;

                case EDSDK.WhiteBalance_WhitePaper: WBCoBox.SelectedIndex = 6; break;

                case EDSDK.WhiteBalance_Shade: WBCoBox.SelectedIndex = 7; break;

                default: WBCoBox.SelectedIndex = -1; break;
                }
                SettingsGroupBox.Enabled = true;
                LiveViewGroupBox.Enabled = true;
                this.STComputerButton.Select();
            }
        }
        /// <summary>
        /// Display he camera overlay that lets you edit what needs to be edited
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loadCamOverlay(CameraValues CV)
        {
            indivCamOverlay ICO = new indivCamOverlay();

            ICO.CV = CV;
            ICO.loadValues();
            ICO.ShowDialog();
            loadControls();
        }
Example #8
0
    public static CameraValues Lerp(CameraValues a, CameraValues b, float t)
    {
        CameraValues o = new CameraValues();

        o.Position = Vector3.Lerp(a.Position, b.Position, t);
        o.Rotation = Quaternion.Lerp(a.Rotation, b.Rotation, t);
        o.FOV      = Mathf.Lerp(a.FOV, b.FOV, t);

        return(o);
    }
Example #9
0
    public void InitPlayerCamera(PlayerInput inp)
    {
        values = Resources.Load("Camera Values") as CameraValues;

        mTranform        = this.transform;
        playerController = inp.playerController;
        playerController.playerCamera = this;
        target    = playerController.mTransform;
        rayCamera = camTrans.GetChild(0);
    }
Example #10
0
        // GET: FaceSentiment/Create
        public ActionResult Create()
        {
            CameraValues cam = new CameraValues();

            cam.Fps           = 30;
            cam.MjpegStreamer = true;
            cam.SecondTimeOut = 2;
            cam.LocalWebcam   = false;
            return(View(cam));
        }
Example #11
0
 private void AvCoBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV((string)AvCoBox.SelectedItem));
     }
     catch (Exception ex)
     {
         ReportError(ex.Message, false);
     }
     this.serial_lost_focus(this.serial_number, EventArgs.Empty);
 }
Example #12
0
 private void ISOCoBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (ISOCoBox.SelectedIndex < 0)
         {
             return;
         }
         CameraHandler.SetSetting(EDSDK.PropID_ISOSpeed, CameraValues.ISO((string)ISOCoBox.SelectedItem));
     }
     catch (Exception ex) { ReportError(ex.Message, false); }
 }
Example #13
0
 private void TvCoBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     CameraHandler.SetSetting(EDSDK.PropID_Tv, CameraValues.TV((string)TvCoBox.SelectedItem));
     if ((string)TvCoBox.SelectedItem == "Bulb")
     {
         BulbUpDo.Enabled = true;
     }
     else
     {
         BulbUpDo.Enabled = false;
     }
 }
Example #14
0
    private void UpdateZoomedState()
    {
        CameraValues v = m_CameraValues[CameraMode.zoomed];

        // Calculate the final position
        v.Position = m_PlayerHeadPos;

        if (m_GameManager.Players[m_PlayerIndex].Player != null)
        {
            v.Rotation = m_GameManager.Players[m_PlayerIndex].Player.Weapon.TankBarrel.rotation;
        }

        m_CameraValues[CameraMode.zoomed] = v;
    }
Example #15
0
        /**
         * 打开会话
         */
        public void OpenSession()
        {
            LiveViewGroupBox.Enabled = true;
            //如果当前相机里表中有选中项,则打开
            if (CameraListBox.SelectedIndex >= 0)
            {
                //利用相机的驱动打开选中的相机
                CameraHandler.OpenSession(CamList[CameraListBox.SelectedIndex]);
                //CameraHandler.OpenSession(null);
                //设置会话按钮
                SessionButton.Text = "关闭会话";

                SessionLabel.Text = CameraHandler.MainCamera.Info.szDeviceDescription;

                AvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av);
                TvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv);
                ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed);

                foreach (int Av in AvList)
                {
                    AvCoBox.Items.Add(CameraValues.AV((uint)Av));
                }
                foreach (int Tv in TvList)
                {
                    TvCoBox.Items.Add(CameraValues.TV((uint)Tv));
                }
                foreach (int ISO in ISOList)
                {
                    ISOCoBox.Items.Add(CameraValues.ISO((uint)ISO));
                }

                AvCoBox.SelectedIndex  = AvCoBox.Items.IndexOf(CameraValues.AV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Av)));
                TvCoBox.SelectedIndex  = TvCoBox.Items.IndexOf(CameraValues.TV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Tv)));
                ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(CameraValues.ISO((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_ISOSpeed)));

                int wbidx = (int)CameraHandler.GetSetting((uint)EDSDK.PropID_WhiteBalance);
                WBCoBox.SelectedIndex = (wbidx > 8) ? wbidx - 1 : wbidx;

                try
                {
                    WBUpDo.Value = CameraHandler.GetSetting((uint)EDSDK.PropID_ColorTemperature);
                }
                catch (Exception e)
                {
                }

                SettingsGroupBox.Enabled = true;
                LiveViewGroupBox.Enabled = true;
            }
        }
Example #16
0
    private void UpdateFollowState()
    {
        CameraValues cameraValues = m_CameraValues[CameraMode.following];

        switch (m_LookMode)
        {
        case LookMode.drive:
            m_ViewAngle = Mathf.LerpAngle(m_ViewAngle, m_angleDest + m_AimOffset.x, LerpInterpolation);
            break;

        case LookMode.aim:
            m_ViewAngle = Mathf.LerpAngle(m_ViewAngle, m_aimAngleDest + (m_AimOffset.x / 2.0f), LerpInterpolation);
            break;
        }


        m_HeightAngle = Mathf.LerpAngle(m_HeightAngle, m_BaseHeight + m_AimOffset.y + m_PlayerFloorAngleOffset, LerpInterpolation);
        m_Distance    = Mathf.Lerp(m_Distance, m_BaseDistance, LerpInterpolation);

        // Calculate the final position
        cameraValues.Position.x = m_PlayerPos.x + Mathf.Sin((m_ViewAngle - 180) * Mathf.Deg2Rad) * (Mathf.Cos(m_HeightAngle * Mathf.Deg2Rad) * m_Distance);
        cameraValues.Position.y = m_PlayerPos.y + Mathf.Sin(m_HeightAngle * Mathf.Deg2Rad) * m_Distance;
        cameraValues.Position.z = m_PlayerPos.z + Mathf.Cos((m_ViewAngle - 180) * Mathf.Deg2Rad) * (Mathf.Cos(m_HeightAngle * Mathf.Deg2Rad) * m_Distance);

        if (m_GameManager.Players[m_PlayerIndex].Player != null)
        {
            Vector3 lookTarget;

            switch (m_LookMode)
            {
            case LookMode.drive:
                lookTarget = m_GameManager.Players[m_PlayerIndex].Player.transform.position;
                break;

            case LookMode.aim:
                lookTarget = m_GameManager.Players[m_PlayerIndex].Player.Weapon.AimPosition();
                break;

            default:
                lookTarget = Vector3.zero;
                break;
            }

            cameraValues.Rotation = Quaternion.Lerp(cameraValues.Rotation, Quaternion.LookRotation(lookTarget - cameraValues.Position), LerpInterpolation);
        }


        m_CameraValues[CameraMode.following] = cameraValues;
    }
Example #17
0
 private void TvCoBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         CameraHandler.SetSetting(EDSDK.PropID_Tv, CameraValues.TV((string)TvCoBox.SelectedItem));
         if ((string)TvCoBox.SelectedItem == "Bulb")
         {
             BulbUpDo.Enabled = true;
         }
         else
         {
             BulbUpDo.Enabled = false;
         }
     }
     catch (Exception ex) { ReportError(ex.Message, false); }
 }
Example #18
0
    private IEnumerator CameraUpdate()
    {
        while (true)
        {
            yield return(new WaitForFixedUpdate());

            UpdateVariables();

            switch (m_CameraState)
            {
            case CameraState.FollowingPlayer:
            {
                UpdateFollowState();
                UpdateZoomedState();

                // Apply values
                float tPos = Easing.Ease(EaseType.EaseInOutQuart, m_CameraMode);
                float tRot = Easing.Ease(EaseType.EaseInOutQuart, m_CameraMode);
                float tFov = Easing.Ease(EaseType.EaseInOutQuart, m_CameraMode);

                transform.position   = CameraValues.Lerp(m_CameraValues[CameraMode.following], m_CameraValues[CameraMode.zoomed], tPos).Position;
                transform.rotation   = CameraValues.Lerp(m_CameraValues[CameraMode.following], m_CameraValues[CameraMode.zoomed], tRot).Rotation;
                m_Camera.fieldOfView = CameraValues.Lerp(m_CameraValues[CameraMode.following], m_CameraValues[CameraMode.zoomed], tFov).FOV;
            }
            break;

            case CameraState.DeathCam:
            {
                transform.position   = m_CameraValues[CameraMode.following].Position;
                m_Camera.fieldOfView = m_CameraValues[CameraMode.following].FOV;

                if (PlayerKiller != null)
                {
                    transform.LookAt(PlayerKiller);
                }
            }
            break;
            }

            // Apply post effects
            transform.position += m_BumpOffset;

            transform.position += m_ScreenshakePosition;
            transform.rotation  = Quaternion.Euler(transform.eulerAngles + m_ScreenshakeRotation);
        }
    }
        /// <summary>
        /// Add a new camera
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addCamera_Click(object sender, EventArgs e)
        {
            CameraValues newCV = new CameraValues();

            newCV.location           = "Location";
            newCV.CameraID           = "ID";
            newCV.URL                = "RTSP";
            newCV.save_xml_folder    = newCV.save_xml_folder.Replace("[CamNUMBER]", Program.TempCAMs.cameras.Count.ToString());
            newCV.save_images_folder = newCV.save_images_folder.Replace("[CamNUMBER]", Program.TempCAMs.cameras.Count.ToString());
            Program.TempCAMs.cameras.Add(newCV);

            Program.TempCAMs.fixNumbers();
            //Save everything
            Program.CAMS = Program.TempCAMs.clone();
            Program.save("CAM");
            loadControls();
        }
        /// <summary>
        /// Format the camera error
        /// </summary>
        /// <param name="CV"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        private string formatError(CameraValues CV, string reason)
        {
            string ret = "";

            if (Int32.Parse(CV.cameraIndex.Trim()) < 10)
            {
                ret = reason + "Camera   " + Int32.Parse(CV.cameraIndex) + "   RTSP: " + CV.URL + "\r\n";
            }
            else if (Int32.Parse(CV.cameraIndex.Trim()) >= 10 && Int32.Parse(CV.cameraIndex) < 100)
            {
                ret = reason + "Camera   " + Int32.Parse(CV.cameraIndex) + "   RTSP: " + CV.URL + "\r\n";
            }
            else
            {
                ret = reason + "Camera   " + Int32.Parse(CV.cameraIndex) + "   RTSP: " + CV.URL + "\r\n";
            }

            return(ret);
        }
Example #21
0
        /// <summary>
        /// Restore everything back to normal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure that you would like to restore all settings to their default values?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                CameraValues tempCV = new CameraValues();
                tempCV.location                    = CV.location;
                tempCV.CameraID                    = CV.CameraID;
                tempCV.URL                         = CV.URL;
                tempCV.face_detect_top             = CV.face_detect_top;
                tempCV.face_detect_left            = CV.face_detect_left;
                tempCV.face_detect_height          = CV.face_detect_height;
                tempCV.face_detect_width           = CV.face_detect_width;
                tempCV.face_detect_min_height_prop = CV.face_detect_min_height_prop;
                tempCV.face_detect_max_height_prop = CV.face_detect_max_height_prop;
                tempCV.save_images                 = CV.save_images;

                CV = tempCV.clone();

                loadAll();
            }
        }
Example #22
0
        public async Task <ActionResult> Create(FormCollection collection)
        {
            try
            {
                CameraValues cameraVal = new CameraValues();
                if (TryUpdateModel(cameraVal))
                {
                    cameraVal.Id     = Guid.NewGuid();
                    cameraVal.Status = "Stopped";
                    var analyzers = (System.Web.HttpContext.Current.Application["Analyzers"] as List <VideoAnalyzer>);
                    var analyzer  = analyzers
                                    .FirstOrDefault(a => a.Camera.IsEqual(cameraVal));

                    if (analyzer != null)
                    {
                        ViewBag.Error = "Already exist a camera with this settings";
                        return(View(cameraVal));
                    }
                    var connections = (System.Web.HttpContext.Current.Application["Connections"] as Connections);
                    var detections  = (System.Web.HttpContext.Current.Application["Detection"] as DetectionSetting);
                    analyzers.Add(new VideoAnalyzer(cameraVal, connections, detections));
                    await db.UpdateCamera(cameraVal);

                    db.UpdateCamera(cameraVal, cameraPath);
                    return(RedirectToAction("WebCams"));
                }
                else
                {
                    ViewBag.Error = "Model doesn't match";
                    return(RedirectToAction("Create"));
                }
            }
            catch
            {
                return(RedirectToAction("Create"));
            }
        }
Example #23
0
        /// <summary>
        /// Save the settings
        /// </summary>
        /// <param name="values"></param>
        internal static void save(string values, string newLicense = "")
        {
            try
            {
                settingsContent = settingsContent.Replace("&", "&amp;");
                XmlDocument xmlDoc = new XmlDocument();
                //Load the XML string into the xmlDoc variable
                xmlDoc.LoadXml(settingsContent);

                string aoiSetting   = "";
                string emailSetting = "";
                string licenseInfo  = "";
                string autoRestart  = "";
                string camInfo      = "";

                //Make sure that we have something to save for the default AOI settings
                var aoi = xmlDoc.GetElementsByTagName("defaultVideoStreamControlSettings");
                if (aoi.Count > 0)
                {
                    aoiSetting = aoi[0].OuterXml;
                }
                else
                {
                    aoiSetting = defaultAOI.toXML();
                }

                //Make sure that we have something to save for the default email settings
                var tempEmail = xmlDoc.GetElementsByTagName("emailConfiguration");
                if (tempEmail.Count > 0)
                {
                    emailSetting = tempEmail[0].OuterXml;
                }
                else
                {
                    emailSetting = email.toXML();
                }

                //Only care if this it is not returned with the email settings
                if (!emailSetting.Contains("<automaticCameraRestart>"))
                {
                    //Make sure that we have something to save for the default email settings
                    var tempAuto = xmlDoc.GetElementsByTagName("automaticCameraRestart");
                    if (tempEmail.Count > 0)
                    {
                        autoRestart += tempAuto[0].OuterXml;
                    }
                    else
                    {
                        autoRestart += "<automaticCameraRestart><stream_timeout>5</stream_timeout><camera_restart_interval>5</camera_restart_interval><camera_restart_attempts>10</camera_restart_attempts></automaticCameraRestart>";
                    }
                }
                else
                {
                    autoRestart = "";
                }

                //Make sure that we have something to save for the license info
                var LI = xmlDoc.GetElementsByTagName("licenseInformation");
                if (LI.Count > 0)
                {
                    licenseInfo = LI[0].OuterXml;
                }
                else
                {
                    licenseInfo = "<licenseInformation><dateIssued>YYYYMMDDHHMMSS</dateIssued><daysLeft>text</daysLeft><dateExpires>YYYYMMDDHHMMSS</dateExpires></licenseInformation>";
                }

                //Make sure that we have something to save for the camerainfo
                var CI = xmlDoc.GetElementsByTagName("cameraConfiguration");
                if (CI.Count > 0)
                {
                    camInfo = CI[0].OuterXml;
                }
                else
                {
                    CameraValues CV = new CameraValues();
                    camInfo = "<cameraConfiguration>";
                    camInfo = CV.toXML();
                    camInfo = "</cameraConfiguration>";
                }

                string newFile = "";
                switch (values)
                {
                case "EMAIL":
                    newFile += email.toXML();     //New value
                    newFile += autoRestart;
                    newFile += aoiSetting;
                    newFile += licenseInfo;
                    newFile += camInfo;
                    break;

                case "AOI":
                    newFile += emailSetting;
                    newFile += autoRestart;
                    newFile += defaultAOI.toXML();     //New value
                    newFile += licenseInfo;
                    newFile += camInfo;
                    break;

                case "LICENSE":
                    newFile += emailSetting;
                    newFile += autoRestart;
                    newFile += aoiSetting;     //New value
                    if (newLicense.Trim() != "")
                    {
                        newFile += newLicense;
                    }
                    else
                    {
                        newFile += licenseInfo;
                    }
                    newFile += camInfo;
                    break;

                case "CAM":
                    newFile += emailSetting;
                    newFile += autoRestart;
                    newFile += aoiSetting;
                    newFile += licenseInfo;
                    newFile += CAMS.toXML(true);     //New value
                    break;

                default:
                    //Save All
                    newFile += email.toXML();      //New value
                    newFile += autoRestart;
                    newFile += defaultAOI.toXML(); //New value
                    newFile += licenseInfo;
                    newFile += CAMS.toXML(true);   //New value
                    break;
                }

                settingsContent = "<?xml version=\"1.0\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" + newFile + "</SOAP-ENV:Envelope>";

                newFile = newFile.Replace("&", "&amp;");
                newFile = newFile.Replace("\"", "&quot;").Replace("'", "&apos;");
                newFile = "<?xml version=\"1.0\"?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">" + newFile + "</SOAP-ENV:Envelope>";
                //Assign it and save it!
                writeToFile(Settings, newFile);
            }
            catch
            {
                saveAll();
            }
        }
Example #24
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            for (int i = 0; i < this.FTextureOutput.SliceCount; i++)
            {
                if (this.FTextureOutput[i] == null)
                {
                    this.FTextureOutput[i] = new DX11Resource <DX11DynamicTexture2D>();
                }
            }

            if (!init)
            {
                CameraHandler = new SDKHandler();

                CameraHandler.CameraAdded       += new SDKHandler.CameraAddedHandler(SDK_CameraAdded);
                CameraHandler.LiveViewUpdated   += new SDKHandler.StreamUpdate(SDK_LiveViewUpdated);
                CameraHandler.ProgressChanged   += new SDKHandler.ProgressHandler(SDK_ProgressChanged);
                CameraHandler.CameraHasShutdown += SDK_CameraHasShutdown;

                EnumManager.UpdateEnum("Tv", "None", new string[] { "None" });
                EnumManager.UpdateEnum("Av", "None", new string[] { "None" });
                EnumManager.UpdateEnum("ISO", "None", new string[] { "None" });

                init = true;
            }

            if (FInUpdate[0])
            {
                Refresh();
            }

            if (FInEnable.IsChanged)
            {
                if (FInEnable[0] && !CameraHandler.CameraSessionOpen)
                {
                    FLogger.Log(LogType.Debug, "OpenSession"); OpenSession(); isChanged = true;
                }
                if (!FInEnable[0] && CameraHandler.CameraSessionOpen)
                {
                    FLogger.Log(LogType.Debug, "CloseSession"); CloseSession();
                }
            }


            if (CameraHandler.CameraSessionOpen)
            {
                if (FInAv.IsChanged || isChanged)
                {
                    if (FInAv[0].Name != "None")
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV(FInAv[0].Name));
                    }
                }

                if (FInTv.IsChanged || isChanged)
                {
                    if (FInTv[0].Name != "None")
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(FInTv[0].Name));
                    }
                }

                if (FInISO.IsChanged || isChanged)
                {
                    if (FInISO[0].Name != "None")
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(FInISO[0].Name));
                    }
                }

                if (FInFocusSpeed.IsChanged || isChanged)
                {
                    if (FInFocusSpeed[0] != DriveFocus.None)
                    {
                        switch (FInFocusSpeed[0])
                        {
                        case DriveFocus.Far1: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Far1); break;

                        case DriveFocus.Far2: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Far2); break;

                        case DriveFocus.Far3: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Far3); break;

                        case DriveFocus.Near1: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Near1); break;

                        case DriveFocus.Near2: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Near2); break;

                        case DriveFocus.Near3: CameraHandler.SetFocus(EDSDK.EvfDriveLens_Near3); break;
                        }
                    }
                }

                if (FInWB.IsChanged || isChanged)
                {
                    if (FInWB[0] != WB.None)
                    {
                        switch (FInWB[0])
                        {
                        case WB.Auto: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Auto); break;

                        case WB.Daylight: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Daylight); break;

                        case WB.Cloudy: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Cloudy); break;

                        case WB.Tangsten: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Tangsten); break;

                        case WB.Fluorescent: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Fluorescent); break;

                        case WB.Strobe: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Strobe); break;

                        case WB.WhitePaper: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_WhitePaper); break;

                        case WB.Shade: CameraHandler.SetSetting(EDSDK.PropID_WhiteBalance, EDSDK.WhiteBalance_Shade); break;
                        }
                    }
                }

                if (FInSaveTo.IsChanged || FInSavePath.IsChanged || isChanged)
                {
                    if (FInSaveTo[0] == SaveTo.Camera)
                    {
                        CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Camera);
                    }
                    else
                    {
                        if (FInSaveTo[0] == SaveTo.Computer)
                        {
                            CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Host);
                        }
                        else if (FInSaveTo[0] == SaveTo.Both)
                        {
                            CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both);
                        }
                        CameraHandler.SetCapacity();

                        try
                        {
                            Directory.CreateDirectory(FInSavePath[0]);
                            CameraHandler.ImageSaveDirectory = FInSavePath[0];
                        }
                        catch (Exception e)
                        {
                            FOutError[0] = e.Message;
                        }
                    }
                }

                if (FInSavePath.IsChanged || isChanged)
                {
                    CameraHandler.ImageSaveDirectory = FInSavePath[0];
                    //CameraHandler.ImageSaveDirectory = "C:\\VVVV\\";
                }

                if (FInTakeVideo.IsChanged || isChanged)
                {
                    if (FInTakeVideo[0] && !CameraHandler.IsFilming)
                    {
                        if (FInSaveTo[0] == SaveTo.Computer || FInSaveTo[0] == SaveTo.Both)
                        {
                            Directory.CreateDirectory(FInSavePath[0]);
                            CameraHandler.StartFilming(FInSavePath[0]);
                        }
                        else
                        {
                            CameraHandler.StartFilming();
                        }
                    }

                    else if (!FInTakeVideo[0] && CameraHandler.IsFilming)
                    {
                        CameraHandler.StopFilming();
                    }
                }

                if (FInForceFocus[0] || FInFocusMode.IsChanged || isChanged)
                {
                    //CameraHandler.SetAFMode((uint)(FInFocusMode[0]-1));
                    CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);
                    CameraHandler.SetSetting(EDSDK.PropID_Evf_AFMode, (uint)(FInFocusMode[0]));
                    CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_ON);
                }

                if (FInTakePhoto[0])
                {
                    if (FInTv[0].Name.Equals("Bulb"))
                    {
                        CameraHandler.TakePhoto((uint)FInBulb[0]);
                    }
                    else
                    {
                        if (FInUseAutofocus[0]) // manual
                        {
                            CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);
                            CameraHandler.TakePhoto();
                        }
                        else                         // auto
                        {
                            CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);
                            CameraHandler.TakePhotoShutterButton();
                        }
                    }
                }

                if (FInLiveView.IsChanged || isChanged)
                {
                    CameraHandler.SetAF(EDSDK.EdsEvfAf.CameraCommand_EvfAf_OFF);

                    if (FInLiveView[0] && !CameraHandler.IsLiveViewOn)
                    {
                        FLogger.Log(LogType.Debug, "StartLiveView"); CameraHandler.StartLiveView();
                    }
                    if (!FInLiveView[0] && CameraHandler.IsLiveViewOn)
                    {
                        FLogger.Log(LogType.Debug, "StopLiveView"); CameraHandler.StopLiveView();
                    }
                }

                isChanged = false;
            }

            if (CameraHandler.Error != EDSDK.EDS_ERR_OK)
            {
                FOutError[0] = Enum.GetName(typeof(EDSDKError), 0x081) + " (0x" + CameraHandler.Error.ToString("X") + ")";
            }

            FOutSaved[0] = saved;
            if (saved)
            {
                saved = false;
            }

            //FLogger.Log(LogType.Debug, "hi tty!");
        }
Example #25
0
        private void OpenSession()
        {
            if (CameraListBox.SelectedIndex >= 0)
            {
                CameraHandler.OpenSession(CamList[CameraListBox.SelectedIndex]);

                string cameraname = CameraHandler.MainCamera.Info.szDeviceDescription;
                SessionLabel.Text = cameraname;
                try
                {
                    if (CameraHandler.GetSetting(EDSDK.PropID_AEMode) != EDSDK.AEMode_Manual)
                    {
                        MessageBox.Show("相机不在手动模式(manual mode)!");
                    }
                }
                catch {
                    MessageBox.Show("连接相机出错。请重试。");
                    return;
                }
                AvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Av);
                TvList  = CameraHandler.GetSettingsList((uint)EDSDK.PropID_Tv);
                ISOList = CameraHandler.GetSettingsList((uint)EDSDK.PropID_ISOSpeed);
                foreach (int Av in AvList)
                {
                    AvCoBox.Items.Add(CameraValues.AV((uint)Av));
                }
                foreach (int Tv in TvList)
                {
                    TvCoBox.Items.Add(CameraValues.TV((uint)Tv));
                }
                foreach (int ISO in ISOList)
                {
                    ISOCoBox.Items.Add(CameraValues.ISO((uint)ISO));
                }
                AvCoBox.SelectedIndex  = AvCoBox.Items.IndexOf(CameraValues.AV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Av)));
                TvCoBox.SelectedIndex  = TvCoBox.Items.IndexOf(CameraValues.TV((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_Tv)));
                ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(CameraValues.ISO((uint)CameraHandler.GetSetting((uint)EDSDK.PropID_ISOSpeed)));
                int wbidx = (int)CameraHandler.GetSetting((uint)EDSDK.PropID_WhiteBalance);
                switch (wbidx)
                {
                case EDSDK.WhiteBalance_Auto: WBCoBox.SelectedIndex = 0; break;

                case EDSDK.WhiteBalance_Daylight: WBCoBox.SelectedIndex = 1; break;

                case EDSDK.WhiteBalance_Cloudy: WBCoBox.SelectedIndex = 2; break;

                case EDSDK.WhiteBalance_Tangsten: WBCoBox.SelectedIndex = 3; break;

                case EDSDK.WhiteBalance_Fluorescent: WBCoBox.SelectedIndex = 4; break;

                case EDSDK.WhiteBalance_Strobe: WBCoBox.SelectedIndex = 5; break;

                case EDSDK.WhiteBalance_WhitePaper: WBCoBox.SelectedIndex = 6; break;

                case EDSDK.WhiteBalance_Shade: WBCoBox.SelectedIndex = 7; break;

                default: WBCoBox.SelectedIndex = -1; break;
                }
                SettingsGroupBox.Enabled = true;
                LiveViewGroupBox.Enabled = true;
                LiveViewButton.Enabled   = true;
                cameraConnectFlag        = true;
                updateRecordReadyControls();
                //if (recordReadyFlag)
                //    TakePhotoButton.Enabled = true;
                //added to initialize save-to options at session opening
                CameraHandler.SetSetting(EDSDK.PropID_SaveTo, (uint)EDSDK.EdsSaveTo.Both);
                CameraHandler.SetCapacity();
                SessionButton.Enabled = false;
                RefreshButton.Enabled = false;

                //SessionButton.Text = "断开相机";
            }
        }
        /// <summary>
        /// Start and stop the inividual camera
        /// </summary>
        /// <param name="CV"></param>
        private void startStopIndivCam(CameraValues CV, Button START)
        {
            string action = START.Text;

            START.Text      = "....";
            START.BackColor = Color.Yellow;
            START.Refresh();
            try
            {
                if (action == "START")
                {
                    if (Program.usedLicense < Program.numberOfLicense)
                    {
                        //Add camera by index
                        try
                        {
                            //Create the folder
                            Program.createDirectory(CV.save_xml_folder);
                            Program.createDirectory(CV.save_images_folder);
                            //Create the camera in Aureus Edge
                            AureusEdge.CreateCamera(Program.mp_aureus, Int32.Parse(CV.cameraIndex.Trim()), 2, Program.msg);
                        }
                        catch
                        {
                            //Do nothing. Camera was already added
                        }
                        //Start Camera
                        AureusEdge.StartCameraByIndex(Int32.Parse(CV.cameraIndex.Trim()), Program.msg);
                        //Check the status
                        if (AureusEdge.RunningStatus(Int32.Parse(CV.cameraIndex.Trim())) == 0)
                        {
                            //Good to go. Update the display
                            CV.running           = true;
                            START.Text           = "STOP";
                            START.BackColor      = Color.Red;
                            Program.usedLicense += 1;
                        }
                        else
                        {
                            //Camera did not start
                            MessageBox.Show("Camera " + CV.cameraIndex + " Failed to start\r\n" + CV.URL, "ERROR", MessageBoxButtons.OK);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Cannot start camera. All allowed cameras are currently in use", "Warning", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    AureusEdge.StopCameraByIndex(Int32.Parse(CV.cameraIndex), Program.msg);
                    //AureusEdge.DestroyCameraByIndex(Int32.Parse(CV.cameraIndex));
                    //Check the status
                    CV.running           = false;
                    START.Text           = "START";
                    START.BackColor      = Color.MediumSeaGreen;
                    Program.usedLicense -= 1;
                }
            }
            catch
            {
                if (action == "START")
                {
                    START.Text      = "START";
                    START.BackColor = Color.MediumSeaGreen;
                }
                else
                {
                    START.Text      = "STOP";
                    START.BackColor = Color.Red;
                }
                START.Refresh();
            }

            if (Program.usedLicense < 0)
            {
                Program.usedLicense = 0;
            }

            loadControls();
        }
Example #27
0
 private void AvCoBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     CameraHandler.SetSetting(EDSDK.PropID_Av, CameraValues.AV((string)AvCoBox.SelectedItem));
 }
Example #28
0
 private void ISOCoBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     CameraHandler.SetSetting(EDSDK.PropID_ISOSpeed, CameraValues.ISO((string)ISOCoBox.SelectedItem));
 }