Ejemplo n.º 1
0
        internal ProgramState GetChangedProgramState(ProgramState programState)
        {
            var methodSymbol = semanticModel.GetSymbolInfo(invocation).Symbol as IMethodSymbol;

            if (IsInstanceEqualsCall(methodSymbol))
            {
                return HandleInstanceEqualsCall(programState);
            }

            if (IsStaticEqualsCall(methodSymbol))
            {
                return HandleStaticEqualsCall(programState);
            }

            if (IsReferenceEqualsCall(methodSymbol))
            {
                return HandleReferenceEqualsCall(invocation, programState);
            }

            if (IsStringNullCheckMethod(methodSymbol))
            {
                return HandleStringNullCheckMethod(programState);
            }

            return programState
                .PopValues((invocation.ArgumentList?.Arguments.Count ?? 0) + 1)
                .PushValue(new SymbolicValue());
        }
Ejemplo n.º 2
0
 public ProgramState execute(ProgramState programState)
 {
     int pointer = programState.getHeap().size() + 1;
     programState.getHeap().put(pointer,expression.eval(programState.getMyDictionary(), programState.getHeap()));
     programState.getMyDictionary().put(variableName, pointer);
     return null;
 }
Ejemplo n.º 3
0
 public ProgramState execute(ProgramState programState)
 {
     int val = expression.eval(programState.getMyDictionary(), programState.getHeap());
     //insert or update
     programState.getMyDictionary().put(variableName, val);
     return null;
 }
Ejemplo n.º 4
0
        public void Run()
        {
            _state = ProgramState.Root;

            if (_npcs == null || _npcs.Count == 0)
            {
                Console.WriteLine("No Npc's were loaded.");
                return;
            }

            bool exit = false;

            while (!exit)
            {
                bool stayInMenu = false;
                do
                {
                    stayInMenu = false;

                    byte selection = ShowMenu(
                        "List Npcs",
                        "Execute Npc",
                        "List Players",
                        "Modify Player",
                        "Create Player",
                        "Exit");
                    if (selection <= 0 || selection > 6)
                    {
                        Console.WriteLine("Incorrect value.");
                        stayInMenu = true;
                    }
                    else
                    {
                        switch (selection)
                        {
                            case 1:
                                ListNpcs();
                                break;
                            case 2:
                                ShowNpcSelect();
                                break;
                            case 3:
                                ListPlayers();
                                break;
                            case 4:
                                ShowModifyPlayers();
                                break;
                            case 5:
                                ShowCreatePlayer();
                                break;
                            case 6:
                                exit = true;
                                break;
                        }
                    }
                    Console.WriteLine();
                } while (stayInMenu);

            }
        }
        public override IEnumerable<ProgramState> TrySetConstraint(SymbolicValueConstraint constraint, ProgramState currentProgramState)
        {
            var boolConstraint = constraint as BoolConstraint;
            if (boolConstraint == null)
            {
                return new[] { currentProgramState };
            }

            SymbolicValueConstraint oldConstraint;
            if (TryGetConstraint(currentProgramState, out oldConstraint) &&
                oldConstraint != constraint)
            {
                return Enumerable.Empty<ProgramState>();
            }

            SymbolicValueConstraint leftConstraint;
            var leftHasConstraint = leftOperand.TryGetConstraint(currentProgramState, out leftConstraint);
            SymbolicValueConstraint rightConstraint;
            var rightHasConstraint = rightOperand.TryGetConstraint(currentProgramState, out rightConstraint);

            var relationship = GetRelationship(boolConstraint);

            var newProgramState = currentProgramState.TrySetRelationship(relationship);
            if (newProgramState == null)
            {
                return Enumerable.Empty<ProgramState>();
            }

            if (!rightHasConstraint && !leftHasConstraint)
            {
                return new[] { newProgramState };
            }

            return SetConstraint(boolConstraint, leftConstraint, rightConstraint, newProgramState);
        }
Ejemplo n.º 6
0
 /**
  * Run the program in debug mode, one step at a time
  *
  * @param programState The program
  * @throws StatementExecutionException
  */
 private void oneStep(ProgramState programState)
 {
     IMyStack<IMyStatement> myStack = programState.getExecutionStack();
     if (myStack.isEmpty())
         throw new InsufficientExecutionStackException();
     IMyStatement statement = myStack.pop();
     statement.execute(programState);
 }
Ejemplo n.º 7
0
        public ProgramState execute(ProgramState programState)
        {
            IMyStack<IMyStatement> stack = new WrapperStack<IMyStatement>();
            stack.push(statement);

            IMyDictionary<String, int> copyDictionary = new WrapperDictionary<String, int>();

            copyDictionary.addAll(programState.getMyDictionary().getMap());
            return new ProgramState(stack, copyDictionary, programState.getOutput(), programState.getHeap(), statement);
        }
Ejemplo n.º 8
0
 public ProgramState execute(ProgramState programState)
 {
     //IMyStatement statement = programState.getExecutionStack().pop();
     int seconds = time.eval(programState.getMyDictionary(), programState.getHeap());
     if (seconds != 0)
     {
         programState.getExecutionStack().push(new SleepStatement(new ConstantExpression(seconds - 1)));
     }
     return null;
 }
        public override IEnumerable<ProgramState> TrySetConstraint(SymbolicValueConstraint constraint, ProgramState currentProgramState)
        {
            var boolConstraint = constraint as BoolConstraint;
            if (boolConstraint == null)
            {
                return new[] { currentProgramState };
            }

            return Operand.TrySetConstraint(boolConstraint.OppositeForLogicalNot, currentProgramState);
        }
Ejemplo n.º 10
0
        public void ProgramState_Diff_SymbolicValue()
        {
            var ps1 = new ProgramState();
            var ps2 = new ProgramState();

            var symbol = GetSymbol();
            ps1 = ps1.SetSymbolicValue(symbol, new SymbolicValue());
            ps2 = ps2.SetSymbolicValue(symbol, new SymbolicValue());

            Assert.AreNotEqual(ps1, ps2);
            Assert.AreNotEqual(ps1.GetHashCode(), ps2.GetHashCode());
        }
Ejemplo n.º 11
0
 public ProgramState execute(ProgramState programState)
 {
     if (expression.eval(programState.getMyDictionary(), programState.getHeap()) != 0)
     {
         programState.getExecutionStack().push(thenStatement);
     }
     else
     {
         programState.getExecutionStack().push(elseStatement);
     }
     return null;
 }
        internal override IEnumerable<ProgramState> SetConstraint(BoolConstraint boolConstraint,
            SymbolicValueConstraint leftConstraint, SymbolicValueConstraint rightConstraint,
            ProgramState programState)
        {
            if (boolConstraint == BoolConstraint.False)
            {
                return rightOperand.TrySetConstraint(leftConstraint, programState)
                    .SelectMany(ps => leftOperand.TrySetConstraint(rightConstraint, ps));
            }

            return rightOperand.TrySetConstraint(leftConstraint?.OppositeForLogicalNot, programState)
                .SelectMany(ps => leftOperand.TrySetConstraint(rightConstraint?.OppositeForLogicalNot, ps));
        }
Ejemplo n.º 13
0
 public ProgramState execute(ProgramState programState)
 {
     IHeap<int, int> heap = programState.getHeap();
     IMyDictionary<String, int> myDictionary = programState.getMyDictionary();
     IMyList<String> output = programState.getOutput();
     IMyStack<IMyStatement> secondStack = new WrapperStack<IMyStatement>();
     ProgramState secondProgramState = new ProgramState(secondStack, myDictionary, output, heap, getStatement());
     while (getExpression().eval(myDictionary, heap) != 0)
     {
         runAllSteps(secondProgramState);
         secondStack.push(getStatement());
     }
     return null;
 }
Ejemplo n.º 14
0
        public void ProgramState_Diff_Constraint()
        {
            var ps1 = new ProgramState();
            var ps2 = new ProgramState();

            var symbol = GetSymbol();
            var sv = new SymbolicValue();
            ps1 = ps1.SetSymbolicValue(symbol, sv);
            ps1 = sv.SetConstraint(new FakeConstraint(), ps1);
            ps2 = ps2.SetSymbolicValue(symbol, sv);
            ps2 = sv.SetConstraint(new FakeConstraint(), ps2);

            Assert.AreNotEqual(ps1, ps2);
            Assert.AreNotEqual(ps1.GetHashCode(), ps2.GetHashCode());
        }
Ejemplo n.º 15
0
        private static ProgramState HandleStringNullCheckMethod(ProgramState programState)
        {
            SymbolicValue arg1;

            var newProgramState = programState
                .PopValue(out arg1)
                .PopValue();

            if (arg1.HasConstraint(ObjectConstraint.Null, newProgramState))
            {
                // Value is null, so the result of the call is true
                return newProgramState.PushValue(SymbolicValue.True);
            }

            return newProgramState.PushValue(new SymbolicValue());
        }
        public override IEnumerable<ProgramState> TrySetConstraint(SymbolicValueConstraint constraint, ProgramState currentProgramState)
        {
            var boolConstraint = constraint as BoolConstraint;
            if (boolConstraint == null)
            {
                return new[] { currentProgramState };
            }

            var relationship = GetRelationship(boolConstraint);

            var newProgramState = currentProgramState.TrySetRelationship(relationship);
            if (newProgramState == null)
            {
                return Enumerable.Empty<ProgramState>();
            }

            return new[] { newProgramState };
        }
Ejemplo n.º 17
0
        public override IEnumerable<ProgramState> TrySetConstraint(SymbolicValueConstraint constraint, ProgramState currentProgramState)
        {
            var boolConstraint = constraint as BoolConstraint;
            if (boolConstraint == null)
            {
                return new[] { currentProgramState };
            }

            if (boolConstraint == BoolConstraint.False)
            {
                return leftOperand.TrySetConstraint(BoolConstraint.False, currentProgramState)
                    .SelectMany(ps => rightOperand.TrySetConstraint(BoolConstraint.False, ps));
            }

            return leftOperand.TrySetConstraint(BoolConstraint.True, currentProgramState)
                    .SelectMany(ps => rightOperand.TrySetConstraint(BoolConstraint.False, ps))
                .Union(leftOperand.TrySetConstraint(BoolConstraint.False, currentProgramState)
                    .SelectMany(ps => rightOperand.TrySetConstraint(BoolConstraint.True, ps)))
                .Union(leftOperand.TrySetConstraint(BoolConstraint.True, currentProgramState)
                    .SelectMany(ps => rightOperand.TrySetConstraint(BoolConstraint.True, ps)));
        }
Ejemplo n.º 18
0
 /// <summary> 
 /// Create a new object by specifying all fields (except the auto-generated primary key field). 
 /// </summary> 
 public Program(int idChannel, DateTime startTime, DateTime endTime, string title, string description, string genre,
                ProgramState state, DateTime originalAirDate, string seriesNum, string episodeNum, string episodeName,
                string episodePart, int starRating,
                string classification, int parentalRating)
 {
   isChanged = true;
   this.idChannel = idChannel;
   this.startTime = startTime;
   this.endTime = endTime;
   this.title = title;
   this.description = description;
   this.genre = genre;
   this.state = (int)state;
   this.originalAirDate = originalAirDate;
   this.seriesNum = seriesNum;
   this.episodeNum = episodeNum;
   this.episodeName = episodeName;
   this.episodePart = episodePart;
   this.starRating = starRating;
   this.classification = classification;
   this.parentalRating = parentalRating;
 }
Ejemplo n.º 19
0
        // Step function is called every timer tic
        //    This function moves each walker randomly according
        //    to the probabilities specified by the UI, if a
        //    walker "bumps into" the DLA cluster that has
        //    already been grown, that cell on the DLA cluser
        //    becomes activated, and the walker is reinitialized
        public void Step()
        {
            // Test if the cluster method has returned as done,
              // and if so, tell the program the simulation is done
              if (cluster_state == ParticleState.COMPLETE)
              {
            current_state = ProgramState.DONE;
              }
              else
              {
            bool deposit = false;

            // If we haven't advanced far enough (according to whatever
            // ruleset we are using), then perform a standard walker step
            if (deposit_count < deposit_rate)
            {
              deposit = StepRandom();
            }
            // Otherwise we need to update according to some ruleset
            else
            {
              deposit_count = 0;
              // This ruleset moves the genrating line upward once a certain
              // particle height has been achieved.
              if (step_method == StepMode.ADVANCE_Y)
              {
            generate_y -= 10;
            // If we've reached the top of the simulation, the cluster is done.
            if (generate_y < 50)
            {
              cluster_state = ParticleState.COMPLETE;
              SaveData();
            }
            // Otherwise, move the walkers upwards
            else
            {
              for (int i = 0; i < number_of_walkers; i++)
              {
                InitializeWalker(walkers[i]);
              }
            }
              }
              // This ruleset moves the walkers on a vertical line from the right end
              // of the simulated region to the left
              else if (step_method == StepMode.ADVANCE_X)
              {
            generate_x -= 10;
            // if we're at the left edge, then the simulation is done
            if (generate_x < 50)
            {
              cluster_state = ParticleState.COMPLETE;
              SaveData();
            }
            // otherwise, move left
            else
            {
              for (int i = 0; i < number_of_walkers; i++)
              {
                InitializeWalker(walkers[i]);
              }
            }
              }
            }

            // This boolean is true if the last step deposited a
            // particle onto the DLA cluster. Each ruleset has a
            // specific way of updating accordingly.
            if (deposit)
            {
              // If we're doing a horizontal line advancement, then
              // any deposition counts towards the total.
              if (step_method == StepMode.ADVANCE_X)
              {
            deposit_count++;
            last_deposit_x = deposit_x;
              }
              // If we're doing a vertical line advancement, then
              // we only update the deposition count if we achieve
              // a new maximum height.
              else if(step_method == StepMode.ADVANCE_Y)
              {
            if(deposit_y < last_deposit_y)
            {
              deposit_count++;
              last_deposit_y = deposit_y;
            }
              }
              // If we're depositing a horizontal line, then we're
              // done when the DLA cluster reaches the line (otherwise
              // we will end up with a solid line
              else if (step_method == StepMode.RANDOM_X_LINE)
              {
            if (deposit_y == (generate_y))
            {
              cluster_state = ParticleState.COMPLETE;
              SaveData();
            }
              }
            }
              }
        }
Ejemplo n.º 20
0
        private void NextAnswer()
        {
            State = ProgramState.Answer;
            bool correct;
            tbBWord.ReadOnly = true;
            foreach (string s in SyntaxProcessor.DoSyntax(GetText(CurrentLanguage, CurrentWord, false)))
                lbAList.Items.Add(s);
            foreach (string s in SyntaxProcessor.DoSyntax(GetText(CurrentLanguage, CurrentWord, true)))
                lbBList.Items.Add(s);
            lblBComment.Text = GetInfo(CurrentLanguage, CurrentWord, true);
            correct = SyntaxProcessor.CorrectWord(GetText(CurrentLanguage, CurrentWord, true), tbBWord.Text);

            lblComment.Text = CurrentWord.Info;

            if (correct)
            {
                btnOK.ForeColor = Color.Green;
                CountCorrect++;
            }
            else
            {
                btnOK.ForeColor = Color.Red;
                CountWrong++;
            }

            if (WordsToDo.Count == 0)
                btnOK.Text = "Schließen!";
            else
                btnOK.Text = "Weiter!";

            new Result(correct, CurrentWord, CurrentUser, CurrentLanguage, lblAWord.Text, tbBWord.Text);
            if (correct || !PresetRevise)
            {
                WordsDone.Add(CurrentWord);
                WordsToDo.Remove(CurrentWord);
            }

            diffBox1.Text = tbBWord.Text;
            diffBox1.Solution = GetText(CurrentLanguage, CurrentWord, true) ;

            UpdateProgressDisplay();
            UpdateQualityDisplay();
        }
Ejemplo n.º 21
0
        private void NextQuestion()
        {
            btnOK.ForeColor = SystemColors.ControlText;

            btnOK.Text = "OK";
            tbBWord.Focus();
            State = ProgramState.Question;
            CurrentWord = WordsToDo[rand.Next(WordsToDo.Count)];

            CurrentLanguage = PresetLanguage ?? ((rand.Next(2) == 0) ? Language.German : Language.OtherLanguage);

            lblALanguage.BackColor = lblAWord.BackColor = GetColor(CurrentLanguage, CurrentWord.Parent.ColorRecursive, false);
            lblBLanguage.BackColor = tbBWord.BackColor = GetColor(CurrentLanguage, CurrentWord.Parent.ColorRecursive, true);
            if (lblALanguage.BackColor.R + lblALanguage.BackColor.G + lblALanguage.BackColor.B < 3 * 255 / 2) lblALanguage.ForeColor = Color.White; else lblALanguage.ForeColor = Color.Black;
            if (lblBLanguage.BackColor.R + lblBLanguage.BackColor.G + lblBLanguage.BackColor.B < 3 * 255 / 2) lblBLanguage.ForeColor = Color.White; else lblBLanguage.ForeColor = Color.Black;
            if (lblAWord.BackColor.R + lblAWord.BackColor.G + lblAWord.BackColor.B < 3 * 255 / 2) lblAWord.ForeColor = Color.White; else lblAWord.ForeColor = Color.Black;
            if (tbBWord.BackColor.R + tbBWord.BackColor.G + tbBWord.BackColor.B < 3 * 255 / 2) tbBWord.ForeColor = Color.White; else tbBWord.ForeColor = Color.Black;

            lblALanguage.Text = GetLanguage(CurrentLanguage, CurrentWord.Parent.LanguageRecursive, false);
            lblBLanguage.Text = GetLanguage(CurrentLanguage, CurrentWord.Parent.LanguageRecursive, true);

            lblAWord.Text = SyntaxProcessor.GetWord(GetText(CurrentLanguage, CurrentWord, false));

            lblAComment.Text = GetInfo(CurrentLanguage, CurrentWord, false);

            tbBWord.Text = "";
            tbBWord.ReadOnly = false;

            lbAList.Items.Clear();
            lbBList.Items.Clear();

            lblComment.Text = "";
            lblBComment.Text = "";

            diffBox1.Text = "";
            diffBox1.Solution = "";
        }
Ejemplo n.º 22
0
        private void startButton_Click(object sender, EventArgs e)
        {
            // if we have no data then don't do anything
            if (Processor.HasTrainingData)
            {
                // start visualization
                _main_form.visualizeReconstructionError.Start();
                _main_form.visualizeVisible.Start();
                _main_form.visualizeHidden.Start();
                _main_form.visualizeWeights.Start();

                // log this shit
                _main_form.trainingLog.AddLog("Training Started");

                if (CurrentState == ProgramState.TrainerStopped)
                {
                    _main_form.Cursor = Cursors.WaitCursor;
                    CurrentState = ProgramState.TrainerInitializing;

                    // start training, give a callback to update our current_state
                    Processor.Start(new Action(() =>
                    {
                        this.Invoke(new Action(() => _main_form.Cursor = Cursors.Default));
                        this.CurrentState = ProgramState.TrainerRunning;
                    }));
                }
                else if (CurrentState == ProgramState.TrainerPaused)
                {
                    CurrentState = ProgramState.TrainerRunning;
                    Processor.Start(null);	// no callback needed
                }
                else if (CurrentState == ProgramState.TrainerScheduleLoaded)
                {
                    CurrentState = ProgramState.TrainerScheduleRunning;
                    Processor.Start(null);	// no callback needed
                }
                else
                {
                    Debug.Assert(false);
                }
            }
        }
Ejemplo n.º 23
0
        private void stopButton_Click(object sender, EventArgs e)
        {
            CurrentState = ProgramState.TrainerStopped;

            _main_form.visualizeReconstructionError.Stop();
            _main_form.visualizeVisible.Stop();
            _main_form.visualizeHidden.Stop();
            _main_form.visualizeWeights.Stop();

            _main_form.trainingLog.AddLog("Training Stopped");

            Processor.Stop();
        }
Ejemplo n.º 24
0
        private void pauseButton_Click(object sender, EventArgs e)
        {
            CurrentState = ProgramState.TrainerPaused;

            _main_form.visualizeVisible.Pause();
            _main_form.visualizeHidden.Pause();
            _main_form.visualizeWeights.Pause();

            _main_form.trainingLog.AddLog("Training Paused");

            Processor.Pause();
        }
Ejemplo n.º 25
0
        private void selectIdxButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "IDX|*.idx";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                _main_form.Cursor = Cursors.WaitCursor;
                // load IDX file
                if (Processor.SetTrainingData(ofd.FileName) == false)
                {
                    _main_form.Cursor = Cursors.Default;
                    return;
                }
                _main_form.Cursor = Cursors.Default;

                // update labels
                traingingIdxPathTextBox.Text = ofd.FileName;
                visibleUnitsLabel.Text = Processor.VisibleUnits.ToString();

                int total_vals = Processor.VisibleUnits;
                ImageWidth = (int)SquareRoot((uint)total_vals);
                ImageHeight = total_vals / ImageWidth;
                if (ImageHeight * ImageWidth < total_vals)
                    ++ImageHeight;

                widthTextBox.Text = ImageWidth.ToString();
                heightTextBox.Text = ImageHeight.ToString();
                pixelFormatComboBox.SelectedIndex = 0;

                training_data_loaded = true;
                validation_data_loaded = false;

                _main_form.trainingLog.AddLog("Loaded Training .IDX: {0}", ofd.FileName);

                // get rid of any validation data that's here
                Processor.SetValidationData(null);
                validationIdxPathTextBox.Text = "";

                if (current_state == ProgramState.ProgramStarted)
                {
                    CurrentState = ProgramState.TrainerStopped;
                }
            }
        }
Ejemplo n.º 26
0
 private void ChangeState(ProgramState new_state)
 {
     walk.SetState(new_state);
       label_state.Text = new_state.ToString();
 }
Ejemplo n.º 27
0
            private ProgramState SetConstraint(ReferenceEqualsSymbolicValue refEquals, ProgramState programState)
            {
                if (AreBothArgumentsNull())
                {
                    return(programState.SetConstraint(refEquals, BoolConstraint.True));
                }

                if (IsAnyArgumentNonNullValueType() ||
                    ArgumentsHaveDifferentNullability())
                {
                    return(programState.SetConstraint(refEquals, BoolConstraint.False));
                }

                if (this.valueLeft == this.valueRight)
                {
                    return(programState.SetConstraint(refEquals, BoolConstraint.True));
                }

                return(programState);
            }
Ejemplo n.º 28
0
 public SettingsModule(ProgramState currentState, AppSetting settings) : base(currentState)
 {
     _settings = settings;
     _knownsettings = FillKnownSettings();
 }
Ejemplo n.º 29
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = false;
            int cameraHandle = 0;

            int r = FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle);

            if (r != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            btnRemember.Enabled = true;

            // set realtime face detection parameters
            FSDK.SetFaceDetectionParameters(false, false, 100);
            FSDK.SetFaceDetectionThreshold(3);

            // list where we store face templates
            // faceTemplates = new List();
            faceTemplates = new List <FaceTemplate>();


            while (!needClose)
            {
                Int32 imageHandle = 0;
                if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandle, ref imageHandle)) // grab the current frame from the camera
                {
                    Application.DoEvents();
                    continue;
                }

                FSDK.CImage image = new FSDK.CImage(imageHandle);

                Image    frameImage = image.ToCLRImage();
                Graphics gr         = Graphics.FromImage(frameImage);

                FSDK.TFacePosition facePosition = image.DetectFace();
                // if a face is detected, we can recognize it
                if (facePosition.w != 0)
                {
                    gr.DrawRectangle(Pens.LightGreen, facePosition.xc - facePosition.w / 2, facePosition.yc - facePosition.w / 2,
                                     facePosition.w, facePosition.w);

                    // create a new face template
                    FaceTemplate template = new FaceTemplate();

                    template.templateData = new byte[FSDK.TemplateSize];
                    FaceTemplate template1 = new FaceTemplate();
                    if (programState == ProgramState.psRemember || programState == ProgramState.psRecognize)
                    {
                        template.templateData = image.GetFaceTemplateInRegion(ref facePosition);
                    }


                    switch (programState)
                    {
                    case ProgramState.psNormal:     // normal state - do nothing
                        break;

                    case ProgramState.psRemember:     // Remember Me state - store facial templates

                        label1.Text = "Templates stored: " + faceTemplates.Count.ToString();
                        faceTemplates.Add(template);
                        if (faceTemplates.Count > 9)
                        {
                            // get the user name
                            InputName inputName = new InputName();
                            inputName.ShowDialog();
                            userName = inputName.userName;


                            try
                            {
                                cmd = new SqlCommand("insert into facetb values(@Name,@face)", con);
                                cmd.Parameters.AddWithValue("@Name", userName);

                                cmd.Parameters.AddWithValue("@face", template.templateData);

                                con.Open();
                                cmd.ExecuteNonQuery();
                                con.Close();
                                MessageBox.Show("Record Save!");

                                programState = ProgramState.psRecognize;
                            }

                            catch (Exception ex)
                            {
                            }
                        }
                        break;

                    case ProgramState.psRecognize:     // recognize the user
                        bool match = false;


                        int ii = 0;

                        foreach (FaceTemplate t in faceTemplates)
                        {
                            float        similarity = 0.0f;
                            FaceTemplate t1         = t;
                            FSDK.MatchFaces(ref template.templateData, ref t1.templateData, ref similarity);
                            float threshold = 0.0f;
                            FSDK.GetMatchingThresholdAtFAR(0.01f, ref threshold);     // set FAR to 1%
                            if (similarity > threshold)
                            {
                                match = true;
                                break;
                            }

                            ii++;
                        }

                        con.Close();



                        if (match)
                        {
                            StringFormat format = new StringFormat();
                            format.Alignment = StringAlignment.Center;

                            gr.DrawString(userName, new System.Drawing.Font("Arial", 16),
                                          new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen),
                                          facePosition.xc, facePosition.yc + facePosition.w * 0.55f, format);

                            label3.Text = userName;
                        }
                        else
                        {
                            label3.Text = "UnKnow FACE";
                        }
                        break;
                    }
                }

                // display current frame
                pictureBox1.Image = frameImage;

                GC.Collect(); // collect the garbage after the deletion

                // make UI controls accessible
                Application.DoEvents();
            }

            FSDKCam.CloseVideoCamera(cameraHandle);
            FSDKCam.FinalizeCapturing();
        }
Ejemplo n.º 30
0
 private void btnRemember_Click(object sender, EventArgs e)
 {
     faceTemplates.Clear();
     programState = ProgramState.psRemember;
     label1.Text  = "Look at the camera";
 }
            public override IEnumerable <ProgramState> TrySetConstraint(SymbolicValueConstraint constraint, ProgramState programState)
            {
                var boolConstraint = constraint as BoolConstraint;

                if (boolConstraint == null)
                {
                    return(new[] { programState });
                }

                var nullabilityConstraint = boolConstraint == BoolConstraint.True
                    ? ObjectConstraint.NotNull
                    : ObjectConstraint.Null;

                return(MemberExpression.TrySetConstraint(nullabilityConstraint, programState));
            }
Ejemplo n.º 32
0
        public void PopulateData()
        {
            //if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("eLDwg+IxLV+w/pfOUzvf7OhNDgnO4M0ZSQZzy7Os2hUn0z3b1driMrhlq+r/eFjkQkjIL4Men2VLH29plmHC/ojpfhyrk6v0tzfc96TD72U4yqYeq4l0VR7phnG1EeFTIPzuXPRKAwtefblB7DmM6uYUrcgGZ5r8R04EdMsJl/k="))
            //{
            //    MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    Application.Exit();
            //}

            //FSDK.InitializeLibrary();
            //FSDKCam.InitializeCapturing();

            //int count;
            //cameraName = LiveFaceScan.CameraSetting.CameraName;
            //FSDKCam.VideoFormatInfo[] formatList;
            //FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

            //formatList[0].Height = 600;
            //formatList[0].Width = 800;
               // FSDKCam.SetVideoFormat(ref cameraName, formatList[0]);

            //int VideoFormat = LiveFaceScan.CameraSetting.VideoFormat;//0; // choose a video format
            //pictureBox1.Height = formatList[VideoFormat].Height;
            //pictureBox1.Width = formatList[VideoFormat].Width;
            //this.Height = formatList[VideoFormat].Height + 48;
            //this.Width = formatList[VideoFormat].Width + 96;

              //  777, 592
            //int screenWidth;
            //int screenHeight;

            //// grabs the resolution of the monitor
            //Screen screen = Screen.PrimaryScreen;
            //screenWidth = 777;//screen.Bounds.Width;
            //screenHeight = 570;//screen.Bounds.Height;
            //// MessageBox.Show("height = " + screenHeight + "\n" + "Width = " + screenWidth);
            //// grabs the resolution of the monitor

            //// sets the size of the window of Pictureviewer
            //this.ClientSize = new Size(screenWidth, screenHeight);
            //// sets the size of the window of Pictureviewer

            //pictureBox1.Size = new Size(screenWidth, screenHeight);

            //pictureBox1.Location = new Point((ClientSize.Width / 2) - (pictureBox1.Width / 2), (ClientSize.Height / 2) - (pictureBox1.Height / 2));

                 try
            {

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("J98H0OOSi4gGwMxLZ0daeM5sCGAFl4wyClviJFdPlYpa48vaFm46LvwLq9T9L0W3vMjimMsBOFFSuTmn8S7nsWoLdS0GLiwGXHuXDJxlgYMo4ufYFVraAPrJfiDeKWaLLoxlR4ZbMIMnujLnM+t/NjixxITVxO522C0Sh8BcbAU="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string[] cameraList;
            int count;
            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = LiveFaceScan.CameraSetting.CameraName;

            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

            int VideoFormat = LiveFaceScan.CameraSetting.VideoFormat; // choose a video format
            //pictureBox1.Width = formatList[VideoFormat].Width;
            //pictureBox1.Height = formatList[VideoFormat].Height;
            //this.Width = formatList[VideoFormat].Width + 48;
            //this.Height = formatList[VideoFormat].Height + 96;
            pictureBox1.Location = new Point(0, 188);
               pictureBox1.Width = 800;
               pictureBox1.Height = 800;
            this.Width = 800;
            this.Height = 1224;

               pictureSearch.Location = new Point(222,800+260);

            int cameraHandle = 0;

            int r = FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle);
            if (r != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            int tracker = 0; 	// creating a Tracker
            if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile)) // try to load saved tracker state
                FSDK.CreateTracker(ref tracker); // if could not be loaded, create a new tracker

            int err = 0; // set realtime face detection parameters
            FSDK.SetTrackerMultipleParameters(tracker, "HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);
            string IsDetect;
            while (!needClose)
            {

                Int32 imageHandle = 0;
                if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandle, ref imageHandle)) // grab the current frame from the camera
                {
                    Application.DoEvents();
                    continue;
                }
                FSDK.CImage image = new FSDK.CImage(imageHandle);

                long[] IDs;
                long faceCount = 0;
                FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeof(long) * 256); // maximum of 256 faces detected
                Array.Resize(ref IDs, (int)faceCount);

                // make UI controls accessible (to find if the user clicked on a face)
                Application.DoEvents();

                Image frameImage = image.ToCLRImage();
                Graphics gr = Graphics.FromImage(frameImage);
                IsDetect = "False";
                for (int i = 0; i < IDs.Length; ++i)
                {
                    IsDetect = "True";
                    //pictureBox1.Image = frameImage;
                    //string strapppath = "D:\\Kiosk_Image_Search\\imagecompare.jpg";// System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\imagesearch\\imagecompare.jpg";
                    //if (System.IO.File.Exists(strapppath.Replace("\\", "/")))
                    //{
                    //    System.IO.File.Delete(strapppath.Replace("\\", "/"));
                    //}
                    //pictureBox1.Image.Save(strapppath.Replace("\\", "/"), ImageFormat.Jpeg);

                    FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                    FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);

                    int left = facePosition.xc - (int)(facePosition.w * 0.6);
                    int top = facePosition.yc - (int)(facePosition.w * 0.5);
                    int w = (int)(facePosition.w * 1.2);

                    String name;
                    int res = FSDK.GetAllNames(tracker, IDs[i], out name, 65536); // maximum of 65536 characters

                    if (FSDK.FSDKE_OK == res && name.Length > 0)
                    { // draw name
                        StringFormat format = new StringFormat();
                        format.Alignment = StringAlignment.Center;

                        gr.DrawString(name, new System.Drawing.Font("Arial", 16),
                            new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen),
                            facePosition.xc, top + w + 5, format);
                    }

                    Pen pen = Pens.LightGreen;
                    if (mouseX >= left && mouseX <= left + w && mouseY >= top && mouseY <= top + w)
                    {
                        pen = Pens.Blue;
                        if (ProgramState.psRemember == programState)
                        {
                            if (FSDK.FSDKE_OK == FSDK.LockID(tracker, IDs[i]))
                            {

                            }
                        }
                    }
                    gr.DrawRectangle(pen, left, top, w, w);
                }
                programState = ProgramState.psRecognize;

                // display current frame
               pictureBox1.Image = frameImage;
                GC.Collect(); // collect the garbage after the deletion
                if (IsDetect == "True")
                {
                    //string strapppath = "D:\\Kiosk_Image_Search\\imagecompare.jpg";// System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\imagesearch\\imagecompare.jpg";
                    ////if (System.IO.File.Exists(strapppath.Replace("\\", "/")))
                    ////{
                    ////    System.IO.File.Delete(strapppath.Replace("\\", "/"));
                    ////}

                    ////pictureBox1.Image.Save(strapppath.Replace("\\", "/"), ImageFormat.Jpeg);
                    ////pictureBox1.Dispose();
                    ////pictureBox1.Refresh();

                    //Image img;
                    //string file = @"D:\Kiosk_Image_Search\imagecompare.jpg";
                    //using (Bitmap bmp = new Bitmap(file))
                    //{
                    //    img = new Bitmap(bmp);
                    //   // pictureBox1.Image = img;
                    //}
                    //if (System.IO.File.Exists(file))
                    //{
                    //    System.IO.File.Delete(file);
                    //    pictureBox1.Image.Save(file, ImageFormat.Jpeg);
                    //}
                    //else
                    //    pictureBox1.Image.Save(file, ImageFormat.Jpeg);

                  // needClose = true;

                    //frCompare.ImageFileName = "imaggecompre";
                    //frCompare.FacePosition = new FSDK.TFacePosition();
                    //frCompare.FacialFeatures = new FSDK.TPoint[2];
                    //frCompare.Template = new byte[FSDK.TemplateSize];
                    //frCompare.image = new FSDK.CImage(pictureBox1.Image);

                    //int images;
                    //int img1;

                    //FSDK.LoadImageFromFile(ref img1, strapppath);
                    //FSDK.SaveImageToFile(img1, strapppath.Replace("\\", "/"));
                    //  ImageDetect();
                   // PopulateAllImage();
                    //if (FaceList.Count > 0)
                    //{
                    //    ImageDetect();
                    //}

                   // MessageBox.Show(FaceList.Count + "");
                    //MessageBox.Show("Face");
                    //FaceList = new List<TFaceRecord>();
                    //string strapppathTemp = "D:\\Kiosk_Image";
                    //String[] filenames = System.IO.Directory.GetFiles(strapppathTemp, "*.jpg");
                    ////MessageBox.Show(filenames.Length + "");
                    //for (int i = 0; i <= filenames.Length-1; i++)
                    //{

                    //    string strpath = filenames[i].Replace("\\", "/");

                    //    MessageBox.Show(strpath);
                    //    TFaceRecord fr = new TFaceRecord();
                    //    fr.ImageFileName = strpath;
                    //    fr.FacePosition = new FSDK.TFacePosition();
                    //    fr.FacialFeatures = new FSDK.TPoint[2];
                    //    fr.Template = new byte[FSDK.TemplateSize];
                    //    fr.image = new FSDK.CImage(strpath);

                    //    try
                    //    {
                    //        fr.FacePosition = fr.image.DetectFace();
                    //        if (0 != fr.FacePosition.w)
                    //        {
                    //            MessageBox.Show(fr.FacePosition.w + "");
                    //            fr.faceImage = fr.image.CopyRect((int)(fr.FacePosition.xc - Math.Round(fr.FacePosition.w * 0.5)), (int)(fr.FacePosition.yc - Math.Round(fr.FacePosition.w * 0.5)), (int)(fr.FacePosition.xc + Math.Round(fr.FacePosition.w * 0.5)), (int)(fr.FacePosition.yc + Math.Round(fr.FacePosition.w * 0.5)));

                    //            try
                    //            {
                    //                fr.FacialFeatures = fr.image.DetectEyesInRegion(ref fr.FacePosition);
                    //            }
                    //            catch (Exception ex2)
                    //            {
                    //                MessageBox.Show(ex2.Message, "Error detecting eyes.");
                    //            }

                    //            try
                    //            {
                    //                fr.Template = fr.image.GetFaceTemplateInRegion(ref fr.FacePosition); // get template with higher precision
                    //            }
                    //            catch (Exception ex2)
                    //            {
                    //                MessageBox.Show(ex2.Message, "Error retrieving face template.");
                    //            }

                    //            FaceList.Add(fr);
                    //            //imageList1.Images.Add(fr2.faceImage.ToCLRImage());
                    //            //lvRegister.Items.Add((imageList1.Images.Count - 1).ToString(), strpath, imageList1.Images.Count - 1);
                    //        }
                    //    }
                    //    catch (Exception exMain)
                    //    {
                    //        MessageBox.Show(exMain.Message, "Error retrieving face template. Main");
                    //    }

                    //    }

                    //MessageBox.Show(FaceList.Count + "");

                   // needClose = true;

                }
                }
            FSDK.SaveTrackerMemoryToFile(tracker, TrackerMemoryFile);
            FSDK.FreeTracker(tracker);

            FSDKCam.CloseVideoCamera(cameraHandle);
            FSDKCam.FinalizeCapturing();
            //if (needClose == true)
            //{
            //    Progresss();
            //}

            }
                 catch (Exception exPopulateData)
                 {

                 }
        }
Ejemplo n.º 33
0
 //
 // current_state member assignor
 //
 public void SetState(ProgramState set_state)
 {
     current_state = set_state;
 }
Ejemplo n.º 34
0
 private static bool IsValueNotNull(SymbolicValue arg, ITypeSymbol type, ProgramState programState)
 {
     return(programState.HasConstraint(arg, ObjectConstraint.NotNull) &&
            type.IsValueType);
 }
Ejemplo n.º 35
0
 //private void btnStart_Click(object sender, EventArgs e)
 //{
 //    int cameraHandle = 0;
 //    int r = FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle);
 //    if (r != FSDK.FSDKE_OK)
 //    {
 //        MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
 //        Application.Exit();
 //    }
 //    int tracker = 0; 	// creating a Tracker
 //    if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile)) // try to load saved tracker state
 //        FSDK.CreateTracker(ref tracker); // if could not be loaded, create a new tracker
 //    int err = 0; // set realtime face detection parameters
 //    FSDK.SetTrackerMultipleParameters(tracker, "HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);
 //    while (!needClose)
 //    {
 //        Int32 imageHandle = 0;
 //        if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandle, ref imageHandle)) // grab the current frame from the camera
 //        {
 //            Application.DoEvents();
 //            continue;
 //        }
 //        FSDK.CImage image = new FSDK.CImage(imageHandle);
 //        long[] IDs;
 //        long faceCount = 0;
 //        FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeof(long) * 256); // maximum of 256 faces detected
 //        Array.Resize(ref IDs, (int)faceCount);
 //        // make UI controls accessible (to find if the user clicked on a face)
 //        Application.DoEvents();
 //        Image frameImage = image.ToCLRImage();
 //        Graphics gr = Graphics.FromImage(frameImage);
 //        // txtDetect.Text = "ไม่เจอ";
 //        for (int i = 0; i < IDs.Length; ++i)
 //        {
 //            // txtDetect.Text = "เจอ";
 //            FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
 //            FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);
 //            int left = facePosition.xc - (int)(facePosition.w * 0.6);
 //            int top = facePosition.yc - (int)(facePosition.w * 0.5);
 //            int w = (int)(facePosition.w * 1.2);
 //            String name;
 //            int res = FSDK.GetAllNames(tracker, IDs[i], out name, 65536); // maximum of 65536 characters
 //            if (FSDK.FSDKE_OK == res && name.Length > 0)
 //            { // draw name
 //                StringFormat format = new StringFormat();
 //                format.Alignment = StringAlignment.Center;
 //                gr.DrawString(name, new System.Drawing.Font("Arial", 16),
 //                    new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen),
 //                    facePosition.xc, top + w + 5, format);
 //            }
 //            Pen pen = Pens.LightGreen;
 //            if (mouseX >= left && mouseX <= left + w && mouseY >= top && mouseY <= top + w)
 //            {
 //                pen = Pens.Blue;
 //                if (ProgramState.psRemember == programState)
 //                {
 //                    if (FSDK.FSDKE_OK == FSDK.LockID(tracker, IDs[i]))
 //                    {
 //                        // get the user name
 //                        frmInputBox inputName = new frmInputBox();
 //                        if (DialogResult.OK == inputName.ShowDialog())
 //                        {
 //                            userName = inputName.userName;
 //                            FSDK.SetName(tracker, IDs[i], userName);
 //                            FSDK.UnlockID(tracker, IDs[i]);
 //                        }
 //                    }
 //                }
 //            }
 //            gr.DrawRectangle(pen, left, top, w, w);
 //        }
 //        programState = ProgramState.psRecognize;
 //        // display current frame
 //        pictureBox1.Image = frameImage;
 //        GC.Collect(); // collect the garbage after the deletion
 //    }
 //    FSDK.SaveTrackerMemoryToFile(tracker, TrackerMemoryFile);
 //    FSDK.FreeTracker(tracker);
 //    FSDKCam.CloseVideoCamera(cameraHandle);
 //    FSDKCam.FinalizeCapturing();
 //}
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     programState = ProgramState.psRemember;
 }
            public override ProgramState PreProcessInstruction(ProgramPoint programPoint, ProgramState programState)
            {
                var instruction = programPoint.Block.Instructions[programPoint.Offset];

                return(instruction.IsKind(SyntaxKind.SimpleMemberAccessExpression)
                    ? ProcessMemberAccess(programState, (MemberAccessExpressionSyntax)instruction)
                    : programState);
            }
Ejemplo n.º 37
0
        public void ShowDetect()
        {
            {
                int cameraHandle = 0;

                int r = FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle);
                if (r != FSDK.FSDKE_OK)
                {
                    MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }

                int tracker = 0; 	// creating a Tracker
                if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile)) // try to load saved tracker state
                    FSDK.CreateTracker(ref tracker); // if could not be loaded, create a new tracker

                int err = 0; // set realtime face detection parameters
                FSDK.SetTrackerMultipleParameters(tracker, "HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);

                while (!needClose)
                {

                    Int32 imageHandle = 0;
                    if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandle, ref imageHandle)) // grab the current frame from the camera
                    {
                        Application.DoEvents();
                        continue;
                    }
                    FSDK.CImage image = new FSDK.CImage(imageHandle);

                    long[] IDs;
                    long faceCount = 0;
                    FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeof(long) * 256); // maximum of 256 faces detected
                    Array.Resize(ref IDs, (int)faceCount);

                    // make UI controls accessible (to find if the user clicked on a face)
                    Application.DoEvents();

                    Image frameImage = image.ToCLRImage();
                    Graphics gr = Graphics.FromImage(frameImage);

                    IsDetect= "False";
                    //txtDetect.Text = "ไม่เจอ";
                    for (int i = 0; i < IDs.Length; ++i)
                    {
                        //txtDetect.Text = "เจอ";
                        IsDetect = "True";

                        FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                        FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);

                        int left = facePosition.xc - (int)(facePosition.w * 0.6);
                        int top = facePosition.yc - (int)(facePosition.w * 0.5);
                        int w = (int)(facePosition.w * 1.2);

                        String name;
                        int res = FSDK.GetAllNames(tracker, IDs[i], out name, 65536); // maximum of 65536 characters

                        if (FSDK.FSDKE_OK == res && name.Length > 0)
                        { // draw name
                            StringFormat format = new StringFormat();
                            format.Alignment = StringAlignment.Center;

                            gr.DrawString(name, new System.Drawing.Font("Arial", 16),
                                new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen),
                                facePosition.xc, top + w + 5, format);
                        }

                        Pen pen = Pens.LightGreen;
                        if (mouseX >= left && mouseX <= left + w && mouseY >= top && mouseY <= top + w)
                        {
                            pen = Pens.Blue;
                            if (ProgramState.psRemember == programState)
                            {
                                if (FSDK.FSDKE_OK == FSDK.LockID(tracker, IDs[i]))
                                {
                                    // get the user name
                                    //frmInputBox inputName = new frmInputBox();
                                    //if (DialogResult.OK == inputName.ShowDialog())
                                    //{
                                    //    userName = inputName.userName;
                                    //    FSDK.SetName(tracker, IDs[i], userName);
                                    //    FSDK.UnlockID(tracker, IDs[i]);
                                    //}
                                }
                            }
                        }
                        gr.DrawRectangle(pen, left, top, w, w);
                    }
                    programState = ProgramState.psRecognize;

                    // display current frame
                    pictureBox1.Image = frameImage;

                    GC.Collect(); // collect the garbage after the deletion
                    if (IsDetect == "True") {
                    string strapppath = LiveFaceScan.CameraSetting.Drive + ":\\Kiosk_Image_Search\\imagecompare.jpg";// System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\imagesearch\\imagecompare.jpg";
                    if (System.IO.File.Exists(strapppath.Replace("\\", "/")))
                    {
                        System.IO.File.Delete(strapppath.Replace("\\", "/"));
                    }
                          pictureBox1.Image.Save(strapppath.Replace("\\", "/"),ImageFormat.Jpeg);

                        //ImageDetect();
                    }

                }
                FSDK.SaveTrackerMemoryToFile(tracker, TrackerMemoryFile);
                FSDK.FreeTracker(tracker);

                FSDKCam.CloseVideoCamera(cameraHandle);
                FSDKCam.FinalizeCapturing();
                //if (needClose == true) {

                //    if (frmCameraDetect.FaceList.Count == 0)
                //    {
                //     MessageBox.Show("Please enroll faces first", "Error");
                //    }
                //    else {

                //    }

                //}
            }
        }
            internal bool TryProcessInstruction(MemberAccessExpressionSyntax instruction, ProgramState programState, out ProgramState newProgramState)
            {
                if (IsHasValueAccess(instruction))
                {
                    newProgramState = programState.PopValue(out var nullable);
                    newProgramState = newProgramState.PushValue(new HasValueAccessSymbolicValue(nullable));
                    return(true);
                }

                newProgramState = programState;
                return(false);
            }