public Character(MainGame mainGame, string name, string characterName) { //ゲームマネージャー設定 MainGame = mainGame; //キャラクターの資料設定 Name = name; CharacterName = characterName; TurnFlag = false; myGameObject = GameObject.Find(Name); Animator = myGameObject.GetComponent <Animator>(); Detector = myGameObject.GetComponent <CharacterDetector>(); AttackRange = myGameObject.transform.GetChild(0).gameObject; AttackRange.SetActive(false); HavingTicket = false; CanMove = true; kickCnt = 0; HavingSkillEffect = myGameObject.transform.GetChild(4).gameObject; SkillStartEffect = myGameObject.transform.GetChild(5).gameObject; ExplosionEffect = myGameObject.transform.GetChild(6).gameObject; HavingSkillEffect.SetActive(false); SkillChargeCnt = 0; //移動計算動く判断 CRisRunning = false; someOneUseSkill = false; }
void Start() { this.rb = GetComponent <Rigidbody2D>(); this.characterDetector = GetComponent <CharacterDetector>(); crumblingTiles = GetComponentsInChildren <CrumblingTile>(); NotifyHealth(); }
private void GuessText_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); var isOpen = openFileDialog.ShowDialog(); if (isOpen != null && isOpen == true) { ProgressLabel.Content = "Progress: recognising..."; CharacterDetector characterDetector = new CharacterDetector(); characterDetector.DetectCharacters(ConvertToBitmap(openFileDialog.FileName)); var files = Directory.GetFiles(".\\images"); List <Task> tasks = new List <Task>(); for (int i = 0; i < files.Length; i++) { var image = getInputFromFile(files[i]); Task <List <float> > getAnswer = Task.Factory.StartNew(() => neuralNetwork.Recognise(image.Select(x => (float)x / byte.MaxValue).ToList())); tasks.Add(getAnswer); } Task.WaitAll(tasks.ToArray()); AnswerTextBox.Text = ""; for (int i = 0; i < tasks.Count; i++) { var taskResult = ((Task <List <float> >)tasks[i]).Result; AnswerTextBox.Text += getCharFromOutput(taskResult); } AnswerTextBox.Text = neuralNetworks.Recognise(ConvertToBitmap(openFileDialog.FileName)); ProgressLabel.Content = "Progress: complete..."; } //FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); //var result = folderBrowserDialog.ShowDialog(); //ProgressLabel.Content = "Progress: recognising..."; //List<Task> tasks = new List<Task>(); //if (result == System.Windows.Forms.DialogResult.OK) //{ // var files = Directory.GetFiles(folderBrowserDialog.SelectedPath); // for (int i = 0; i < files.Length; i++) // { // var image = getInputFromFile(files[i]); // Task<List<float>> getAnswer = Task.Factory.StartNew(() => // neuralNetwork.Recognise(image.Select(x => (float)x / byte.MaxValue).ToList())); // tasks.Add(getAnswer); // } // Task.WaitAll(tasks.ToArray()); // AnswerTextBox.Text = ""; // for (int i = 0; i < tasks.Count; i++) // { // var taskResult = ((Task<List<float>>)tasks[i]).Result; // AnswerTextBox.Text += getCharFromOutput(taskResult); // } // ProgressLabel.Content = "Progress: complete..."; //} }
public void Init(PictureBox ibOriginal, PictureBox ibDetected, PictureBox ibDraw, int tableCalibX, int tableCalibY, int tableCalibSens, int nextPieceCalibX, int nextPieceCalibY, int nextPieceCalibSens, string fontType) //Inicializálás { try { calOk = false; newGame = true; this.ibOriginal = ibOriginal; this.ibDetected = ibDetected; this.ibDraw = ibDraw; this.tableCalibX = tableCalibX; this.tableCalibY = tableCalibY; this.tableCalibSens = tableCalibSens; this.nextPieceCalibX = nextPieceCalibX; this.nextPieceCalibY = nextPieceCalibY; this.nextPieceCalibSens = nextPieceCalibSens; /*tableCalibX = 17; * tableCalibY = 452; * tableCalibSens = 40; * nextPieceCalibX = 574; * nextPieceCalibY = 359; * nextPieceCalibSens = 10;*/ calib = new Calibrator(tableCalibSens, tableCalibX, tableCalibY); ocr = new CharacterDetector(); ocr.equalizeHist = false; ocr.finder.maxRotateAngle = Math.PI; ocr.minContourArea = 10; ocr.minContourLength = 15; ocr.finder.maxACFDescriptorDeviation = 4; ocr.finder.minACF = 0.96; ocr.finder.minICF = 0.85; ocr.blur = true; ocr.noiseFilter = false; ocr.cannyThreshold = 50; ocr.adaptiveThresholdBlockSize = 4; ocr.adaptiveThresholdParameter = 1.5; ocr.templates.Clear(); TemplateGenerator.GenerateChars(ocr, new char[] { 'X', 'O' }, new System.Drawing.Font(new FontFamily(fontType), 100, FontStyle.Regular)); status = GameStatus.Online; capture = new Capture(); capture.ImageGrabbed += ProcessFrame; OnGameStatusChanged(GameStatus.Online); prevPiece = false; nextPiece = false; } catch { OnGameStatusChanged(GameStatus.Offline); //Ha a kamera nem található. } }
void Start() { this.rb = GetComponent <Rigidbody2D>(); this.spriteRenderer = GetComponent <SpriteRenderer>(); this.characterDetector = GetComponentInChildren <CharacterDetector>(); }