示例#1
0
 private void ZminusBtn_Click(object sender, EventArgs e)
 {
     MovingRobotXYZ.MoveRobotXYZ(MovingRobotXYZ.XYZenum.Zm, serialPort);
 }
示例#2
0
        private void Capture_ImageGrabbed(object sender, EventArgs e)
        {
            try
            {
                int sizeOfPicBox = Convert.ToInt32(picBoxCameraView.Height);

                currentFrame      = cameraCapture.QueryFrame().ToImage <Bgr, Byte>();
                hsvFrame          = currentFrame.Convert <Hsv, Byte>();
                hsvFindColorFrame = ImageProcessing.ImageProcessing.FindColor(hsvFrame);
                binaryFrame       = ImageProcessing.ImageProcessing.ConvertImageToBinary(hsvFindColorFrame);

                rectanglesFist       = fistClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12);
                rectanglesPalm       = palmClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12);
                rectanglesTomb       = tombClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12);
                rectanglesTwoFingers = twoFingersClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12);
                rectanglesFinger     = fingerClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12);
                rectanglesTwoFingers = victoryClassifier.DetectMultiScale(binaryFrame, scaleFactor: 1.1, minNeighbors: 12);

                foreach (var rectangle in rectanglesPalm)
                {
                    currentFrame.Draw(rectangle, new Bgr(50, 255, 50));
                    richTextBoxStatus.Text          = string.Empty + "Run";
                    richTextBoxRecognitionData.Text = "x = " + rectangle.X + "y = " + rectangle.Y;
                    MovingRobotXYZ.MoveRobotXYZ(rectangle, richTextBoxRecognitionData, serialPort);
                }

                foreach (var rectangle in rectanglesFist)
                {
                    currentFrame.Draw(rectangle, new Bgr(255, 0, 0));
                    richTextBoxStatus.Text = string.Empty + "Stop";
                }

                foreach (var rectangle in rectanglesTomb)
                {
                    currentFrame.Draw(rectangle, new Bgr(128, 0, 128));
                    richTextBoxStatus.Text = string.Empty + "Chwytak ON";
                    SendingCommandsToRobot.SendCommand("HNDOFF1", serialPort);
                }

                foreach (var rectangle in rectanglesTwoFingers)
                {
                    currentFrame.Draw(rectangle, new Bgr(75, 0, 130));
                    richTextBoxStatus.Text = string.Empty + "Chwytak OFF";
                    SendingCommandsToRobot.SendCommand("HNDON1", serialPort);
                }

                foreach (var rectangle in rectanglesVictory)
                {
                    currentFrame.Draw(rectangle, new Bgr(0, 0, 128));
                    int actualSpeed = Convert.ToInt32(speedTxtBox.Text);
                    int newSpeed;
                    if (actualSpeed == 100)
                    {
                        newSpeed = 100;
                    }
                    else
                    {
                        newSpeed = actualSpeed + 10;
                    }

                    SpeedControl.SpeedChange(newSpeed, serialPort, speedTxtBox);
                }

                foreach (var rectangle in rectanglesFinger)
                {
                    currentFrame.Draw(rectangle, new Bgr(135, 200, 255));
                    int actualSpeed = Convert.ToInt32(speedTxtBox.Text);
                    int newSpeed;
                    if (actualSpeed == 0)
                    {
                        newSpeed = 0;
                    }
                    else
                    {
                        newSpeed = actualSpeed - 10;
                    }

                    SpeedControl.SpeedChange(newSpeed, serialPort, speedTxtBox);
                }

                Bitmap bitmap = currentFrame.ToBitmap();
                bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);
                picBoxCameraView.Image = bitmap;
            }
            catch (Exception)
            {
            }
        }