public void OnCaptureButtonClick() { tempObjectIds.Clear();//clearing object ids _sendingObjectText.SetActive(false); sendinObjectTeaxtTemp = _sendingObjectText.GetComponent <Text>(); sendinObjectTeaxtTemp.color = Color.white; sendinObjectTeaxtTemp.text = "Sending your object annotation...."; _findAnotherItemButton.SetActive(false); _nextButton.SetActive(true); TakePicture(480); _uIManagerMap = GameObject.Find("Canvas").GetComponent <UIManagerMap>(); if (_uIManagerMap == null) { Debug.LogError("UI Manager Map is Null"); } _uIManagerMap.DisplayCapturePanel(); #region Test Case For Taking Picture if (_PcdebugMode == true) { //base 64 convertor bytes = DeCompress(_testTexture).EncodeToJPG(); image64 = "data:image/jpeg;base64," + Convert.ToBase64String(bytes); //print("this is local user save id: " + _localUser.userID); GameNetworkImage captured = new GameNetworkImage(_localUser.userID, image64, "0", "0"); StartCoroutine(_gameNetwork.PostAddObject("https://harryspotter.eu.ngrok.io/addObject", captured.Serialize().ToString(), GetObjectIds)); #endregion } }
private void TakePicture(int maxSize) { NativeCamera.Permission permission = NativeCamera.TakePicture((path) => { Debug.Log("Image path: " + path); if (path != null) { texture = NativeCamera.LoadImageAtPath(path, maxSize); if (texture == null) { Debug.Log("Couldn't load texture from " + path); return; } if (_PcdebugMode == false) { photoTaken.gameObject.SetActive(true); photoTaken.texture = texture; //Sending the image which user has taken in 64bit format to the backend byte[] currenBytes = DeCompress(texture).EncodeToJPG(); //bytes = _testTexture.EncodeToPNG(); string currentImage64 = "data:image/jpeg;base64," + Convert.ToBase64String(currenBytes); GameNetworkImage captured = new GameNetworkImage(_localUser.userID, currentImage64, _locationStatus.GetLocationLat(), _locationStatus.GetLocationLon()); StartCoroutine(_gameNetwork.PostAddObject("https://harryspotter.eu.ngrok.io/addObject", captured.Serialize().ToString(), GetObjectIds)); } /* * // Assign texture to a temporary quad and destroy it after 5 seconds * GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); * quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f; * quad.transform.forward = Camera.main.transform.forward; * quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f); * * Material material = quad.GetComponent<Renderer>().material; * if (!material.shader.isSupported) // happens when Standard shader is not included in the build * material.shader = Shader.Find("Legacy Shaders/Diffuse"); * * material.mainTexture = texture; * * Destroy(quad, 5f); * * // If a procedural texture is not destroyed manually, * // it will only be freed after a scene change * Destroy(texture, 5f); */ } else { _uIManagerMap.DisplayMapPanel(); } }, maxSize); Debug.Log("Permission result: " + permission); }