private void camControl(int cam) { List <Control> availControls = controls(this); for (int i = 0; i < availControls.Count; i++) { if (availControls[i] is Button) { } else { availControls.RemoveAt(i); } } foreach (Control ctrl in availControls) { if (ctrl.Name.ToString().Length > 7 && ctrl.Name.ToString().Length < 11 && LeftRightMid.Left(ctrl.Name.ToString(), 7) == "bttncam") { if (ctrl.Text == Convert.ToString(cam + 1)) { ctrl.BackColor = Color.LawnGreen; } else { if (Convert.ToInt32(ctrl.Text) <= CameraRig.cameraCount()) { ctrl.BackColor = Color.SkyBlue; } } } } availControls.Clear(); }
private void areaOffAtMotion_CheckedChanged(object sender, EventArgs e) { CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.areaOffAtMotion, areaOffAtMotion.Checked); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); CameraRig.ConnectedCameras[CameraRig.ConfigCam].cam.areaOffAtMotionTriggered = false; CameraRig.ConnectedCameras[CameraRig.ConfigCam].cam.areaOffAtMotionReset = false; }
private void webcamConfig_FormClosing(object sender, FormClosingEventArgs e) { try { //20110506 //bubble.drawMode = false; //bubble.exposeArea = false; drawModeOff.Checked = true; drawModeOn.Checked = false; radioButton7.Checked = true; radioButton8.Checked = false; //20110506 returnList.Clear(); for (int i = 0; i < CameraRig.cameraCount(); i++) { CameraRig.getCam(i).motionLevelEvent -= new motionLevelEventHandler(drawLevel); } levelBitmap.Dispose(); cameraWindow.Camera = null; CameraRig.ExposeArea = false; System.Diagnostics.Debug.WriteLine(CameraRig.cameraCount()); returnList.Add(mainSelectedWebcam + 1); returnList.Add(autoscroll); webcamConfigDelegate(returnList); } catch { } }
private void areaOffAtMotion_CheckedChanged(object sender, EventArgs e) { CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, "areaOffAtMotion", areaOffAtMotion.Checked); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); CameraRig.rig[CameraRig.drawCam].cam.MotionDetector.areaOffAtMotionTriggered = false; CameraRig.rig[CameraRig.drawCam].cam.MotionDetector.areaOffAtMotionReset = false; }
public static void rigInfoPopulateForCam(string profileName, string webcam) { ConnectedCamera selectedCamera = CameraRig.ConnectedCameras.Where(x => x.cameraName == webcam).FirstOrDefault(); selectedCamera.friendlyName = (string)(CameraRig.rigInfoGet(profileName, webcam, infoEnum.friendlyName)); selectedCamera.cam.areaDetection = (bool)(CameraRig.rigInfoGet(profileName, webcam, infoEnum.areaDetection)); selectedCamera.cam.areaDetectionWithin = (bool)(CameraRig.rigInfoGet(profileName, webcam, infoEnum.areaDetectionWithin)); }
private void radioButton1_CheckedChanged(object sender, EventArgs e) { CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.areaDetectionWithin, radioButton1.Checked); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); config.getProfile(bubble.profileInUse).areaDetectionWithin = radioButton1.Checked; CameraRig.AreaDetectionWithin = radioButton1.Checked; CameraRig.getCam(selectedWebcam).MotionDetector.Reset(); }
private void analyseResults() { bool alarmed = new bool(); foreach (analysePictureControl item in analysis.images) { alarmed = false; if (Convert.ToInt32(lblTimeSpike.Text) == 0 || Convert.ToInt32(lblToleranceSpike.Text) == 0) { if (item.movLevel >= Convert.ToInt32(lblSensitivity.Text)) { alarmed = true; item.borderColour = Color.Red; item.Refresh(); } } else { if (item.movLevel >= trkMov.Value) { List <object> lightSpikeResults; bool spike = new bool(); spike = false; int spikePerc = new int(); lightSpikeResults = statistics.lightSpikeDetected(CameraRig.getCam(item.cam).cam, item.movLevel, trkTimeSpike.Value, trkToleranceSpike.Value, bubble.profileInUse, item.time); spike = (bool)lightSpikeResults[0]; spikePerc = (int)lightSpikeResults[1]; if (!spike) { alarmed = true; item.borderColour = Color.Red; item.Refresh(); } } } if (!alarmed) { item.borderColour = Color.Empty; item.Refresh(); } } }
public static void WebcamSettingsPopulate() { foreach (configApplication profile in profiles) { foreach (configWebcam webcamConfig in profile.camConfigs) { CameraRig.addInfo(CameraRig.infoEnum.webcam, webcamConfig.webcam); CameraRig.addInfo(CameraRig.infoEnum.profileName, webcamConfig.profileName); CameraRig.addInfo(CameraRig.infoEnum.alarmActive, webcamConfig.alarmActive); CameraRig.addInfo(CameraRig.infoEnum.publishActive, webcamConfig.publishActive); CameraRig.addInfo(CameraRig.infoEnum.friendlyName, webcamConfig.friendlyName); CameraRig.addInfo(CameraRig.infoEnum.displayButton, webcamConfig.displayButton); CameraRig.addInfo(CameraRig.infoEnum.areaDetection, webcamConfig.areaDetection); CameraRig.addInfo(CameraRig.infoEnum.areaDetectionWithin, webcamConfig.areaDetectionWithin); CameraRig.addInfo(CameraRig.infoEnum.areaOffAtMotion, webcamConfig.areaOffAtMotion); CameraRig.addInfo(CameraRig.infoEnum.rectX, webcamConfig.rectX); CameraRig.addInfo(CameraRig.infoEnum.rectY, webcamConfig.rectY); CameraRig.addInfo(CameraRig.infoEnum.rectWidth, webcamConfig.rectWidth); CameraRig.addInfo(CameraRig.infoEnum.rectHeight, webcamConfig.rectHeight); CameraRig.addInfo(CameraRig.infoEnum.movementVal, webcamConfig.movementVal); CameraRig.addInfo(CameraRig.infoEnum.timeSpike, webcamConfig.timeSpike); CameraRig.addInfo(CameraRig.infoEnum.toleranceSpike, webcamConfig.toleranceSpike); CameraRig.addInfo(CameraRig.infoEnum.lightSpike, webcamConfig.lightSpike); CameraRig.addInfo(CameraRig.infoEnum.pubTime, webcamConfig.pubTime); CameraRig.addInfo(CameraRig.infoEnum.pubHours, webcamConfig.pubHours); CameraRig.addInfo(CameraRig.infoEnum.pubMins, webcamConfig.pubMins); CameraRig.addInfo(CameraRig.infoEnum.pubSecs, webcamConfig.pubSecs); CameraRig.addInfo(CameraRig.infoEnum.publishWeb, webcamConfig.publishWeb); CameraRig.addInfo(CameraRig.infoEnum.publishLocal, webcamConfig.publishLocal); CameraRig.addInfo(CameraRig.infoEnum.timerOn, webcamConfig.timerOn); CameraRig.addInfo(CameraRig.infoEnum.fileURLPubWeb, webcamConfig.fileURLPubWeb); CameraRig.addInfo(CameraRig.infoEnum.filenamePrefixPubWeb, webcamConfig.filenamePrefixPubWeb); CameraRig.addInfo(CameraRig.infoEnum.cycleStampCheckedPubWeb, webcamConfig.cycleStampCheckedPubWeb); CameraRig.addInfo(CameraRig.infoEnum.startCyclePubWeb, webcamConfig.startCyclePubWeb); CameraRig.addInfo(CameraRig.infoEnum.endCyclePubWeb, webcamConfig.endCyclePubWeb); CameraRig.addInfo(CameraRig.infoEnum.currentCyclePubWeb, webcamConfig.currentCyclePubWeb); CameraRig.addInfo(CameraRig.infoEnum.stampAppendPubWeb, webcamConfig.stampAppendPubWeb); CameraRig.addInfo(CameraRig.infoEnum.fileAlertPubLoc, webcamConfig.fileDirAlertLoc); CameraRig.addInfo(CameraRig.infoEnum.fileAlertPubCust, webcamConfig.fileDirAlertCust); CameraRig.addInfo(CameraRig.infoEnum.fileDirPubLoc, webcamConfig.fileDirPubLoc); CameraRig.addInfo(CameraRig.infoEnum.fileDirPubCust, webcamConfig.fileDirPubCust); CameraRig.addInfo(CameraRig.infoEnum.filenamePrefixPubLoc, webcamConfig.filenamePrefixPubLoc); CameraRig.addInfo(CameraRig.infoEnum.cycleStampCheckedPubLoc, webcamConfig.cycleStampCheckedPubLoc); CameraRig.addInfo(CameraRig.infoEnum.startCyclePubLoc, webcamConfig.startCyclePubLoc); CameraRig.addInfo(CameraRig.infoEnum.endCyclePubLoc, webcamConfig.endCyclePubLoc); CameraRig.addInfo(CameraRig.infoEnum.currentCyclePubLoc, webcamConfig.currentCyclePubLoc); CameraRig.addInfo(CameraRig.infoEnum.stampAppendPubLoc, webcamConfig.stampAppendPubLoc); CameraRig.addInfo(CameraRig.infoEnum.ipWebcamAddress, webcamConfig.ipWebcamAddress); CameraRig.addInfo(CameraRig.infoEnum.ipWebcamUser, webcamConfig.ipWebcamUser); CameraRig.addInfo(CameraRig.infoEnum.ipWebcamPassword, webcamConfig.ipWebcamPassword); } } }
public static void rigInfoPopulateForCam(string profileName, string webcam) { foreach (rigItem item in CameraRig.rig) { if (item.cameraName == webcam) { item.friendlyName = (string)(CameraRig.rigInfoGet(profileName, webcam, infoEnum.friendlyName)); item.cam.areaDetection = (bool)(CameraRig.rigInfoGet(profileName, webcam, infoEnum.areaDetection)); item.cam.areaDetectionWithin = (bool)(CameraRig.rigInfoGet(profileName, webcam, infoEnum.areaDetectionWithin)); } } }
private void calibrate_Click(object sender, EventArgs e) { ArrayList i = new ArrayList(); //i.Add(config.getProfile(bubble.profileInUse).toolTips); i.Add(toolTip1.Active); i.Add(CameraRig.getCam(selectedWebcam).camNo); //System.Diagnostics.Debug.WriteLine("cam sent: " + Convert.ToString(i[1])); calibrate calibrate = new calibrate(postCalibrate, i); calibrate.StartPosition = FormStartPosition.CenterScreen; calibrate.ShowDialog(); }
private void trkMov_ValueChanged(object sender, EventArgs e) { if (trkMov.Value == 100) { txtMov.Text = "99"; } else { txtMov.Text = trkMov.Value.ToString(); } CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.movementVal, Convert.ToDouble(txtMov.Text) / 100); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); }
private void trainDetection(ArrayList i) { CameraRig.TrainCam = CameraRig.getCam(selectedWebcam).camNo; bubble.detectionCountDown = (int)i[0]; bubble.detectionTrain = (int)i[1]; actCount.Visible = true; bubble.training.Clear(); bubble.movementSetting = true; dw.DoWork -= new DoWorkEventHandler(trainMovement); dw.DoWork += new DoWorkEventHandler(trainMovement); dw.WorkerSupportsCancellation = true; dw.RunWorkerAsync(); }
private void cameraSwitch(int button, bool load) { currentlySelectedButton = button; //int camId = CameraRig.idFromButton(button); int camId = CameraRig.idxFromButton(button); if (load || !load && camClick(button)) { if (load || !load && CameraRig.cameraExists(camId)) { selectedWebcam = CameraRig.ConnectedCameras[camId].cameraName; CameraRig.ConfigCam = camId; CameraRig.getCam(camId).MotionDetector.Reset(); camName.Text = (string)CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.friendlyName); drawModeOn.Checked = false; drawModeOff.Checked = true; txtMov.Text = Convert.ToString((double)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.movementVal)) * 100); radioButton4.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.areaDetection)); radioButton3.Checked = !radioButton4.Checked; areaOffAtMotion.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.areaOffAtMotion)); radioButton8.Checked = false; radioButton7.Checked = true; radioButton1.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.areaDetectionWithin)); radioButton2.Checked = !radioButton1.Checked; trkTimeSpike.Value = (int)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.timeSpike)); trkToleranceSpike.Value = (int)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.toleranceSpike)); rdSpikeOn.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.lightSpike)); lblTimeSpike.Text = trkTimeSpike.Value.ToString(); lblToleranceSpike.Text = trkToleranceSpike.Value.ToString() + "%"; cameraWindow.Camera = null; cameraWindow.Camera = CameraRig.getCam(camId); //CameraRig.rig[0].cam; CameraRig.getCam(camId).motionLevelEvent -= new motionLevelEventHandler(drawLevel); CameraRig.getCam(camId).motionLevelEvent += new motionLevelEventHandler(drawLevel); camButtonSetColours(); //camControl(button); } } }
private void camDown(object sender, EventArgs e) { int wasButton = CameraRig.ConnectedCameras[CameraRig.ConfigCam].displayButton; int nowButton; if (wasButton == 1) { nowButton = 9; } else { nowButton = wasButton - 1; } CameraRig.changeDisplayButton(bubble.profileInUse, selectedWebcam, CameraRig.ConfigCam, nowButton); cameraSwitch(nowButton, true); }
private void radioButton4_CheckedChanged(object sender, EventArgs e) { if (drawModeOff.Checked) { CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.areaDetection, radioButton4.Checked); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); CameraRig.getCam(selectedWebcam).MotionDetector.Reset(); config.getProfile(bubble.profileInUse).areaDetection = radioButton4.Checked; CameraRig.getCam(selectedWebcam).areaDetection = radioButton4.Checked; areaOffAtMotion.Enabled = radioButton4.Checked; groupBox4.Enabled = radioButton4.Checked; showSelection.Enabled = radioButton4.Checked; CameraRig.ConnectedCameras[CameraRig.ConfigCam].cam.MotionDetector.Reset(); } }
private void button15_Click(object sender, EventArgs e) { config.getProfile(bubble.profileInUse).rectX = 20; config.getProfile(bubble.profileInUse).rectY = 20; config.getProfile(bubble.profileInUse).rectWidth = 80; config.getProfile(bubble.profileInUse).rectHeight = 80; CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.rectX, 20); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.rectY, 20); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.rectWidth, 80); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.rectHeight, 80); CameraRig.getCam(selectedWebcam).rectX = 20; CameraRig.getCam(selectedWebcam).rectY = 20; CameraRig.getCam(selectedWebcam).rectWidth = 80; CameraRig.getCam(selectedWebcam).rectHeight = 80; cameraWindow.drawRectOnOpen(); }
private void txtMov_TextChanged(object sender, EventArgs e) { if (!bubble.IsNumeric(txtMov.Text)) { txtMov.Text = "1"; } if (txtMov.Text.Trim() == "0") { txtMov.Text = "1"; } //if (txtMov.Text.Trim() == "100") txtMov.Text = "99"; trkMov.Value = Convert.ToInt32(txtMov.Text); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.movementVal, Convert.ToDouble(txtMov.Text) / 100); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); CameraRig.ConnectedCameras[CameraRig.ConfigCam].cam.movementVal = Convert.ToDouble(txtMov.Text) / 100; }
private void button15_Click(object sender, EventArgs e) { config.getProfile(bubble.profileInUse).rectX = 20; config.getProfile(bubble.profileInUse).rectY = 20; config.getProfile(bubble.profileInUse).rectWidth = 80; config.getProfile(bubble.profileInUse).rectHeight = 80; CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, "rectX", 20); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, "rectY", 20); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, "rectWidth", 80); CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, "rectHeight", 80); CameraRig.getCam(selectedWebcam).MotionDetector.rectX = 20; CameraRig.getCam(selectedWebcam).MotionDetector.rectY = 20; CameraRig.getCam(selectedWebcam).MotionDetector.rectWidth = 80; CameraRig.getCam(selectedWebcam).MotionDetector.rectHeight = 80; cameraWindow.drawRectOnOpen(); }
private void button5_Click(object sender, EventArgs e) { if (camButtons.removeCam(camButtons.firstActiveButton())) { if (button5.Enabled) { CameraRig.cameraRemove(CameraRig.drawCam); button5.Enabled = false; button5.BackColor = System.Drawing.SystemColors.Control; camButtons.activateFirstAvailableButton(); camButtonSetColours(); int tmpInt = camButtons.firstAvailableButton(); if (tmpInt != 999) { cameraSwitch(tmpInt, true); } } } }
private void camDown(object sender, EventArgs e) { int wasButton = CameraRig.rig[CameraRig.drawCam].displayButton; int nowButton; if (wasButton == 1) { nowButton = 9; } else { nowButton = wasButton - 1; } CameraRig.changeDisplayButton(bubble.profileInUse, selectedWebcam, CameraRig.drawCam, nowButton); //cameraSwitch(nowButton, false); camButtons.changeDisplayButton(wasButton, nowButton); cameraSwitch(nowButton, true); //camButtonSetColours(); }
private void camButtonSetColours() { foreach (var buttonGroup in CameraButtons) { //display camera buttons if (buttonGroup.id == CameraRig.ConnectedCameras[CameraRig.ConfigCam].displayButton) { buttonGroup.CameraButtonIsActive(); } else { if (CameraRig.CameraIsConnectedToButton(buttonGroup.id)) { buttonGroup.CameraButtonIsInactive(); } else { buttonGroup.CameraButtonIsNotConnected(); } } } }
private void button5_Click(object sender, EventArgs e) { if (button5.Enabled && CameraButtons.Where(x => x.id == currentlySelectedButton).First().CameraButtonState != CameraButtonGroup.ButtonState.NotConnected ) { var response = MessageBox.Show("Are you sure you want to remove this camera and all the associated information?" + Environment.NewLine + Environment.NewLine + "Once the camera is removed, if you require it again you will need to add the webcam again " + "together with all the camera specific settings associated with it.", "Remove camera and associated information?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (response == DialogResult.Yes) { CameraRig.cameraRemove(CameraRig.idxFromButton(currentlySelectedButton), true); int firstAvailableButton = CameraRig.ConnectedCameras.Where(x => x.displayButton > 0).First().displayButton; cameraSwitch(firstAvailableButton, false); camButtonSetColours(); button5.Enabled = false; button5.BackColor = System.Drawing.SystemColors.Control; saveChanges(); } } }
private void cameraSwitch(int button, bool load) { //int camId = CameraRig.idFromButton(button); int camId = CameraRig.idxFromButton(button); if (load || !load && camButtons.camClick(button)) { if (load || !load && CameraRig.cameraExists(camId)) { selectedWebcam = CameraRig.rig[camId].cameraName; CameraRig.drawCam = camId; CameraRig.getCam(camId).MotionDetector.Reset(); camName.Text = (string)CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, "friendlyName"); drawModeOn.Checked = false; drawModeOff.Checked = true; txtMov.Text = Convert.ToString((double)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, "movementVal")) * 100); radioButton4.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, "areaDetection")); radioButton3.Checked = !radioButton4.Checked; areaOffAtMotion.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, "areaOffAtMotion")); radioButton8.Checked = false; radioButton7.Checked = true; radioButton1.Checked = (bool)(CameraRig.rigInfoGet(bubble.profileInUse, selectedWebcam, "areaDetectionWithin")); radioButton2.Checked = !radioButton1.Checked; cameraWindow.Camera = null; cameraWindow.Camera = CameraRig.getCam(camId); //CameraRig.rig[0].cam; CameraRig.getCam(camId).motionLevelEvent -= new motionLevelEventHandler(drawLevel); CameraRig.getCam(camId).motionLevelEvent += new motionLevelEventHandler(drawLevel); camButtonSetColours(); //camControl(button); } } }
private void webcamConfig_FormClosing(object sender, FormClosingEventArgs e) { try { //20110506 drawModeOff.Checked = true; drawModeOn.Checked = false; radioButton7.Checked = true; radioButton8.Checked = false; //20110506 returnList.Clear(); for (int i = 0; i < CameraRig.cameraCount(); i++) { CameraRig.getCam(i).motionLevelEvent -= new motionLevelEventHandler(drawLevel); CameraRig.getCam(i).calibrating = false; } //levelBitmap.Dispose(); //20130617 v - noopped as main camera window was showing a blank image //cameraWindow.Camera = null; //20130617 ^ - noopped as main camera window was showing a blank image CameraRig.ExposeArea = false; System.Diagnostics.Debug.WriteLine(CameraRig.cameraCount()); returnList.Add(mainSelectedWebcam + 1); returnList.Add(autoscroll); webcamConfigDelegate(returnList); } catch { } }
private void drawRect(int topLeftX, int topLeftY, int width, int height) { try { Graphics g = this.CreateGraphics(); if (topLeftY + height > camera.pubFrame.Height) { height = camera.pubFrame.Height - topLeftY; } if (height < 1) { height = 1; } if (topLeftY < 0) { topLeftY = 0; } if (topLeftY >= camera.pubFrame.Height) { topLeftY = camera.pubFrame.Height - 1; height = 1; } if (topLeftX + width > camera.pubFrame.Width) { width = camera.pubFrame.Width - topLeftX; } if (width < 1) { width = 1; } if (topLeftX < 0) { topLeftX = 0; } if (topLeftX >= camera.pubFrame.Width) { topLeftX = camera.pubFrame.Width - 1; width = 1; } g.DrawRectangle(MyPen, topLeftX, topLeftY, width, height); g.Dispose(); config.getProfile(bubble.profileInUse).rectX = topLeftX; config.getProfile(bubble.profileInUse).rectY = topLeftY; config.getProfile(bubble.profileInUse).rectWidth = width; config.getProfile(bubble.profileInUse).rectHeight = height; CameraRig.rig[CameraRig.drawCam].cam.rectX = topLeftX; CameraRig.updateInfo(bubble.profileInUse, CameraRig.rig[CameraRig.drawCam].cameraName, CameraRig.infoEnum.rectX, topLeftX); CameraRig.rig[CameraRig.drawCam].cam.rectY = topLeftY; CameraRig.updateInfo(bubble.profileInUse, CameraRig.rig[CameraRig.drawCam].cameraName, CameraRig.infoEnum.rectY, topLeftY); CameraRig.rig[CameraRig.drawCam].cam.rectWidth = width; CameraRig.updateInfo(bubble.profileInUse, CameraRig.rig[CameraRig.drawCam].cameraName, CameraRig.infoEnum.rectWidth, width); CameraRig.rig[CameraRig.drawCam].cam.rectHeight = height; CameraRig.updateInfo(bubble.profileInUse, CameraRig.rig[CameraRig.drawCam].cameraName, CameraRig.infoEnum.rectHeight, height); CameraRig.rig[CameraRig.drawCam].cam.Lock(); CameraRig.rig[CameraRig.drawCam].cam.MotionDetector.Reset(); CameraRig.rig[CameraRig.drawCam].cam.Unlock(); } catch { } }
private void take_ping_picture(object sender, System.EventArgs e) { haveTheFlag = true; string fName = "pingPicture.jpg"; Bitmap saveBmp = null; try { List <string> lst = new List <string>(); if (config.getProfile(bubble.profileInUse).pingStatsStamp) { statistics.movementResults stats = new statistics.movementResults(); stats = statistics.statsForCam(CameraRig.activeCam, bubble.profileInUse, "Ping"); lst.Add(stats.avgMvStart.ToString()); lst.Add(stats.avgMvLast.ToString()); lst.Add(stats.mvNow.ToString()); lst.Add(Convert.ToBoolean(CameraRig.rigInfoGet(bubble.profileInUse, CameraRig.rig[CameraRig.activeCam].cameraName, CameraRig.infoEnum.alarmActive)) ? "On" : "Off"); lst.Add(config.getProfile(bubble.profileInUse).pingInterval.ToString() + " Mins"); } imageText stampArgs = new imageText(); if (config.getProfile(bubble.profileInUse).pingAll) { mosaic mos = new mosaic(); int imgHeight = 0; int imgWidth = 0; //set the height and width to the largest image foreach (rigItem item in CameraRig.rig) { if (item.cam.pubFrame.Height > imgHeight || item.cam.pubFrame.Width > imgWidth) { imgHeight = item.cam.pubFrame.Height; imgWidth = item.cam.pubFrame.Width; } } foreach (rigItem item in CameraRig.rig) { mos.addToList(bubble.resizeImage(item.cam.pubFrame, imgWidth, imgHeight)); } stampArgs.bitmap = (Bitmap)mos.getMosaicBitmap(4).Clone(); } else//if (config.getProfile(bubble.profileInUse).pingStatsStamp) { stampArgs.bitmap = (Bitmap)camera.pubFrame.Clone(); } stampArgs.type = "Ping"; stampArgs.backingRectangle = config.getProfile(bubble.profileInUse).pingTimeStampRect; stampArgs.stats = lst; saveBmp = bubble.timeStampImage(stampArgs); ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg); System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality; EncoderParameters myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, config.getProfile(bubble.profileInUse).pingCompression); myEncoderParameters.Param[0] = myEncoderParameter; saveBmp.Save(bubble.tmpFolder + fName, jgpEncoder, myEncoderParameters); Bitmap thumb = bubble.GetThumb(saveBmp); thumb.Save(bubble.tmpFolder + bubble.tmbPrefix + fName, ImageFormat.Jpeg); saveBmp.Dispose(); thumb.Dispose(); bubble.logAddLine("Image saved: " + fName); //bubble.pingError = false; haveTheFlag = false; } catch (Exception) { haveTheFlag = false; //bubble.pingError = true; bubble.logAddLine("Error in saving image: " + fName); } }
private void testMotion(object sender, DoWorkEventArgs e) { string outFile = bubble.tmpFolder + "motionCalibrate.csv"; if (File.Exists(outFile)) { File.Delete(outFile); } int startSecs = time.secondsSinceStart(); int tm = (int)(Convert.ToDouble(trainVal.Text) * Convert.ToDouble(1000)); CameraRig.getCam(cam).detectionOn = true; CameraRig.getCam(cam).calibrating = true; //CameraRig.getCam(CameraRig.trainCam).detectionOn = true; //CameraRig.getCam(CameraRig.trainCam).calibrating = true; while (bubble.testImagePublish) { int timeLeft = CountDownFrom - (time.secondsSinceStart() - startSecs); lblCountDown.SynchronisedInvoke(() => lblCountDown.Text = "..." + timeLeft.ToString()); if (timeLeft <= 0)//Convert.ToInt32(countVal.Text)) { bubble.testImagePublish = false; } //System.Diagnostics.Debug.WriteLine("sending to bubble: " + cam.ToString()); bubble.publishTestMotion(tm, cam); } CameraRig.getCam(cam).detectionOn = false; CameraRig.getCam(cam).calibrating = false; //CameraRig.getCam(CameraRig.trainCam).detectionOn = false; //CameraRig.getCam(CameraRig.trainCam).calibrating = false; //analyse analysis = new analyse(); StreamWriter sw = new StreamWriter(outFile, true); sw.WriteLine("Sequence,Motion_Level,lowestValueOverTime,Image_File"); analysis.images.Clear(); for (int i = 0; i < bubble.testImagePublishData.Count; i++) { if (!tw.CancellationPending && File.Exists(bubble.tmpFolder + (string)bubble.testImagePublishData[i + 3])) { sw.WriteLine(string.Concat(bubble.testImagePublishData[i], ",", bubble.testImagePublishData[i + 1], ",", bubble.testImagePublishData[i + 2], ",", bubble.testImagePublishData[i + 3])); analysis.newPictureControl(bubble.tmpFolder + (string)bubble.testImagePublishData[i + 3], (string)bubble.testImagePublishData[i + 4], (long)bubble.testImagePublishData[i + 5], Color.DarkOrange, (int)bubble.testImagePublishData[i + 1]); //analysis.newPictureControl(new Bitmap(bubble.tmpFolder + (string)bubble.testImagePublishData[i + 3]), // (string)bubble.testImagePublishData[i + 4], // (long)bubble.testImagePublishData[i + 5], // Color.DarkOrange, // (int)bubble.testImagePublishData[i + 1]); } i = i + 5; } sw.Close(); populate(); startCountdown.SynchronisedInvoke(() => startCountdown.Text = "Start Calibration"); lblCountDown.SynchronisedInvoke(() => lblCountDown.Visible = false); }
private void camName_TextChanged(object sender, EventArgs e) { CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.friendlyName, camName.Text); CameraRig.rigInfoPopulateForCam(bubble.profileInUse, selectedWebcam); }
private void trkToleranceSpike_ValueChanged(object sender, EventArgs e) { lblToleranceSpike.Text = trkToleranceSpike.Value.ToString() + "%"; config.getProfile(bubble.profileInUse).toleranceSpike = trkToleranceSpike.Value; CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.toleranceSpike, trkToleranceSpike.Value); }
private void rdSpikeOn_CheckedChanged(object sender, EventArgs e) { grpSpikeSettings.Enabled = rdSpikeOn.Checked; CameraRig.updateInfo(bubble.profileInUse, selectedWebcam, CameraRig.infoEnum.lightSpike, grpSpikeSettings.Enabled); }