// in start function the sprites for player areas and cards should be created, we can use // - one sprite for each player area // - one sprite for each card size public void Start() { camC = CameraControl.CameraControl.cameraControl; gamC = GameControl.GameControl.gameControl; OffsetX = camC.GetOffsetInX(); OffsetY = camC.GetOffsetInY(); // copy the data about table to local class variable _tableX = -(float)camC.GetTableCornersById(2) / 2f; _tableY = -(float)camC.GetTableCornersById(3) / 2f; _tableWidth = (float)camC.GetTableCornersById(2); _tableHeight = (float)camC.GetTableCornersById(3); }
private void Awake() { // check if we already have Game Control object, instantiate it otherwise /*if (CameraControl.CameraControl.cameraControl == null) * { * Instantiate(CameraControl.CameraControl.cameraControl) as GameObject; * }*/ cam = CameraControl.CameraControl.cameraControl; canvasSize = new Vector2(currentCanvas.GetComponent <RectTransform>().rect.width, currentCanvas.GetComponent <RectTransform>().rect.height); size = new Vector2(canvasSize.x, canvasSize.y); changeChessboardSize = true; timesOfSizeChange = 0; }
// Update is called once per frame void Update() { if (CameraControl.CameraControl.cameraControl != null) { camC = CameraControl.CameraControl.cameraControl; if (camC.IsCameraCalibrated() && camC.IsTableCalibrated() && camC.IsProjectorCalibrated()) { if (StartGameButton != null) { StartGameButton.interactable = true; } } } }
// Update is called once per frame void Update() { camControl = CameraControl.CameraControl.cameraControl; if (camControl != null) { if (camControl.IsCameraChosen()) { DetectMarkersButton.GetComponent <Button>().interactable = true; if (_showchessboard) { //ImagePlane.texture = ChessboardTexture; //(ImagePlane.texture as Texture2D).Apply(); } else if (!_markersDetected || _tableCalibrated) { Texture2D frame = camControl.GetNextFrameAsImage(); ImagePlane.texture = frame; (ImagePlane.texture as Texture2D).Apply(); } } } }
public void Start() { camControl = CameraControl.CameraControl.cameraControl; }
// --------------------------- CALIBRATION ---------------------------------------------------------------- public void CalibrateCameraButtonEvent() { // get values from user string widthSS = ChessboardWidth.transform.Find("Text").GetComponent <Text>().text; string heightSS = ChessboardHeight.transform.Find("Text").GetComponent <Text>().text; string sizeSS = ChessboardSquareSize.transform.Find("Text").GetComponent <Text>().text; Debug.Log("w: " + widthSS + "h: " + heightSS + "s: " + sizeSS); ushort width = 0, height = 0; double size = 0; bool error = false; try { width = Convert.ToUInt16(widthSS); } catch (Exception e) { Debug.Log("Convert exception: " + e.Message); error = true; } try { height = Convert.ToUInt16(heightSS); } catch (Exception e) { Debug.Log("Convert exception: " + e.Message); error = true; } try { size = Convert.ToDouble(sizeSS); } catch (Exception e) { Debug.Log("Convert exception: " + e.Message); error = true; } if (!error) { // perform calibration CameraControl.CameraControl camC = CameraControl.CameraControl.cameraControl; bool success = camC.SetSquareDimensionCameraCalibration(size); success = camC.SetChessboardDimensionCameraCalibration(width, height); if (success) { success = camC.PerformCameraCalibration(); if (success) { camC.SavePerformedCameraCalibrationToFile(); camC.SetCameraCalibrated(true); } } else { Debug.Log("CalibrateCameraButtonEvent -> Cannot set params for camera calibration!"); } calibrationNote.SetActive(false); cameraCalibCanvas.interactable = true; } }