private void radButton1_Click(object sender, EventArgs e) { panel1.Invalidate(); Application.DoEvents(); Rectangle[] Blocks = new Rectangle[] { OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock1), OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock2), OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock3), OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock4) }; List <Bitmap[]> bmps = new List <Bitmap[]>(); for (int i = 0; i < 4; i++) { bmps.Add(rr.SliceOMarkBlock(panel1.BackgroundImage, Blocks[i], 10)); } DataSet dsMarks = DB_Connect.ExecuteQuery("SELECT a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40 FROM mcq_marking_scheme_tab WHERE marking_scheme_id = '" + markingSchemeId + "';"); int[] ans_arr; ans_arr = new int[40]; string img_path = txtFileName.Text.ToString(); int cnt = 0; int result = 0; foreach (Bitmap[] blk in bmps) { foreach (Bitmap line in blk) { ans_arr[cnt] = rr.rateSlice(line, 5); if (ans_arr[cnt] == int.Parse(dsMarks.Tables[0].Rows[0][cnt].ToString())) { result++; } cnt++; } } DB_Connect.InsertQuery("INSERT INTO mcq_answers_tab(candidate_id,exam_id,answersheet_path,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,total_mark) VALUES('" + candidateId + "','" + examId + "','" + img_path + "', " + ans_arr[0] + ", " + ans_arr[1] + ", " + ans_arr[2] + ", " + ans_arr[3] + "," + ans_arr[4] + "," + ans_arr[5] + "," + ans_arr[6] + "," + ans_arr[7] + "," + ans_arr[8] + "," + ans_arr[9] + "," + ans_arr[10] + "," + ans_arr[11] + "," + ans_arr[12] + "," + ans_arr[13] + "," + ans_arr[14] + "," + ans_arr[15] + "," + ans_arr[16] + "," + ans_arr[17] + "," + ans_arr[18] + "," + ans_arr[19] + "," + ans_arr[20] + ", " + ans_arr[21] + "," + ans_arr[22] + "," + ans_arr[23] + "," + ans_arr[24] + "," + ans_arr[25] + "," + ans_arr[26] + "," + ans_arr[27] + "," + ans_arr[28] + "," + ans_arr[29] + "," + ans_arr[30] + "," + ans_arr[31] + "," + ans_arr[32] + "," + ans_arr[33] + "," + ans_arr[34] + "," + ans_arr[35] + "," + ans_arr[36] + "," + ans_arr[37] + "," + ans_arr[38] + "," + ans_arr[39] + "," + result + ");"); lblResult.Text = result.ToString(); }
private void AlertTimer_Tick(object sender, EventArgs e) { //foreach (int i in motionQueue.GroupBy(x => x).OrderByDescending(g => g.Count()).Select(g => g.Key) ) var selectedCategories = motionQueue.GroupBy(x => x).OrderByDescending(g => g.Count()).Select(g => new { pos = g.Key, cnt = g.Count() }); foreach (var pos in selectedCategories) { bool isAlert = false; if (severetyThreshold < pos.cnt) { isAlert = true; } if (isAlert) { if (pos.pos == 1) { red1 = true; } else if (pos.pos == 2) { red2 = true; } else if (pos.pos == 3) { red3 = true; } else if (pos.pos == 4) { red4 = true; } //lbAlerts.Items.Add("Suspicious Act at #" + pos.pos.ToString()); dgAlerts.Rows.Add("Suspicious Act", pos.pos.ToString()); DB_Connect.InsertQuery("INSERT INTO alert_tab(exam_id,position_id,alert_type,alert_time) VALUES(" + examid + "," + pos.pos.ToString() + ",'S','" + DateTime.Now + "')"); //GCM cheat //AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification(); //string strResponse = apnGCM.SendNotification(regID, pos.pos.ToString() + " "+ DateTime.Now, "S"); dgAlerts.FirstDisplayedScrollingRowIndex = dgAlerts.RowCount - 1; } motionQueue.Clear(); } }
private void btnSave_Click(object sender, EventArgs e) { DB_Connect.InsertQuery("INSERT INTO examination_tab ( exam_date, exam_start_time, exam_end_time, exam_hall_id, exam_subject_id) VALUES ('" + radDateTimePicker1.Value + "', '" + radDateTimePicker3.Value.TimeOfDay + "', '" + radDateTimePicker4.Value.TimeOfDay + "', " + cbSubject.SelectedValue + ", " + cbHall.SelectedValue + ");"); }
void FrameGrabber(object sender, EventArgs e) { try { //Get the current frame form capture device currentFrame = grabber.QueryFrame().Resize(520, 340, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); } catch (NullReferenceException e1) { _motionHistory = new MotionHistory(2.0, 0.05, 0.5); _forgroundDetector = null; motionQueue.Clear(); helpQueue.Clear(); grabber = new Capture(vidlist[excnt]); excnt++; if (excnt == 5) { excnt = 0; } currentFrame = grabber.QueryFrame().Resize(520, 340, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); green1 = false; green2 = false; green3 = false; green4 = false; red1 = false; red2 = false; red3 = false; red4 = false; } //Convert it to Grayscale gray = currentFrame.Convert <Gray, Byte>(); //Face Detector MCvAvgComp[][] facesDetected = gray.DetectHaarCascade( face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); //Action for each element detected foreach (MCvAvgComp f in facesDetected[0]) { t = t + 1; result = currentFrame.Copy(f.rect).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //MessageBox.Show("wiidth " + f.rect.Width + " height " + f.rect.Height + " area " + f.rect.Width * f.rect.Height); if (f.rect.Width > 80) { continue; } //draw the face detected in the 0th (gray) channel with blue color if (showHand) { currentFrame.Draw(f.rect, new Bgr(Color.LightGreen), 2); } int nearespos = nearestPosition(f.rect.X, f.rect.Y); if (helpQueue.ToArray().ToList().IndexOf(nearespos) == -1) { //lbAlerts.Items.Add("Help request at #" + nearespos.ToString()); dgAlerts.Rows.Add("Help Request", nearespos.ToString()); DB_Connect.InsertQuery("INSERT INTO alert_tab(exam_id,position_id,alert_type,alert_time) VALUES(" + examid + "," + nearespos.ToString() + ",'H','" + DateTime.Now + "')"); dgAlerts.FirstDisplayedScrollingRowIndex = dgAlerts.RowCount - 1; //GCM - help //AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification(); //string strResponse = apnGCM.SendNotification(regID, nearespos.ToString() + " "+ DateTime.Now, "H"); if (nearespos == 1) { green1 = true; } else if (nearespos == 2) { green2 = true; } else if (nearespos == 3) { green3 = true; } else if (nearespos == 4) { green4 = true; } if (helpQueue.Count == 10) { helpQueue.Dequeue(); helpQueue.Enqueue(nearespos); } else { helpQueue.Enqueue(nearespos); } } } //Show the faces procesed and recognized imageBoxFrameGrabber.Image = ProcessFrame(currentFrame); if (captureOutput == null && xdoc.Descendants("RecordVideo").First().Value == "1") { MessageBox.Show("reording start"); captureOutput = new VideoWriter(@"video" + examid + ".avi", (int)grabber.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FOURCC), 15, 520, 340, true); } if (currentFrame != null && xdoc.Descendants("RecordVideo").First().Value == "1") { captureOutput.WriteFrame <Bgr, Byte>(currentFrame); } }
public void insertCandidate(Candidate c) { DB_Connect.InsertQuery("INSERT INTO candidate_tab(candidate_full_name,candidate_name_initials,candidate_title,candidate_nationality_id,candidate_nic,candidate_dob,candidate_gender,candidate_addr_l1,candidate_addr_l2, candidate_addr_l3, candidate_telno,candidate_email) VALUES('" + c.fullName + "', '" + c.nameInitials + "', '" + c.title + "', '" + c.nationality + "', '" + c.nic + "', '" + c.dob + "','" + c.gender + "','" + c.addr_l1 + " ','" + c.addr_l2 + " ','" + c.addr_l3 + " ', '" + c.telNo + "', '" + c.email + "');"); }