void OnCapturedPhotoToMemory(PhotoCapture.PhotoCaptureResult result, PhotoCaptureFrame photoCaptureFrame) { // Copy the raw image data into the target texture photoCaptureFrame.UploadImageDataToTexture(targetTexture); photoCaptureFrame.CopyRawImageDataIntoBuffer(buffer); Color32[] pix = targetTexture.GetPixels32(); int with = targetTexture.width; int hight = targetTexture.height; int index = MaxRedColor.MaxRedColors(pix); int lines = (int)(index + 1) / 640; int stakes = index - (lines * 640); if (Variabless.First_x == -1) { Variabless.First_x = stakes; Variabless.First_y = lines; print(stakes); } else if (Variabless.Second_x == -1) { Variabless.Second_x = stakes; Variabless.Second_y = lines; print(stakes); } else if (Variabless.Third_x == -1) { Variabless.Third_x = stakes; Variabless.Third_y = lines; print(stakes); } else if (Variabless.Four_x == -1) { Variabless.Four_x = stakes; Variabless.Four_y = lines; print(stakes); } // Deactivate the camera photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode); }
void Update() { Color32[] pix = WebCamTexture.GetPixels32(); int with = WebCamTexture.width; int hight = WebCamTexture.height; int index = MaxRedColor.MaxRedColors(pix); if (index > 0) { int lines = (int)(index + 1) / 640; int stakes = index - (lines * 640); float x_position = -((-Variabless.x_scale) + (stakes - x_Right) * Variabless.x_step); float y_position = (-Variabless.y_scale) + (lines - y_Down) * Variabless.y_step; if (x_position > 4.5f) { x_position = 4.5f; } else if (x_position < -4.5f) { x_position = -4.5f; } if (y_position > 1.7f) { y_position = 1.7f; } else if (y_position < -1.7f) { y_position = -1.7f; } lightPoint.transform.position = new Vector3(x_position, y_position, -11.14f); } }