void onCapturedPhotoToMemory(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result, UnityEngine.XR.WSA.WebCam.PhotoCaptureFrame photoCaptureFrame) { if (!result.success) { Debug.LogError("Error CapturedPhotoToMemory"); return; } // 撮影画像の取得 List <byte> buffer = new List <byte>(); photoCaptureFrame.CopyRawImageDataIntoBuffer(buffer); photoCapture.StopPhotoModeAsync(onStoppedPhotoMode); // QR照準内のみを切り取る List <byte> trimmedBuffer = trimmingQrSight(buffer, 4); // QR照準内の画像を保存 Texture2D tex = createTexture(trimmedBuffer, cameraParameters.cameraResolutionWidth, cameraParameters.cameraResolutionHeight); saveToFile(tex); if (callback != null) { callback(new List <byte>(trimmedBuffer), cameraParameters.cameraResolutionWidth, cameraParameters.cameraResolutionHeight); } }
// Capture de l'image void OnCapturedPhotoToMemory(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result, UnityEngine.XR.WSA.WebCam.PhotoCaptureFrame photoCaptureFrame) { if (result.success) { Debug.Log("photo captured"); List <byte> imageBufferList = new List <byte>(); photoCaptureFrame.CopyRawImageDataIntoBuffer(imageBufferList); var cameraToWorldMatrix = new Matrix4x4(); photoCaptureFrame.TryGetCameraToWorldMatrix(out cameraToWorldMatrix); camera_pos_ = cameraToWorldMatrix.MultiplyPoint3x4(new Vector3(0, 0, -1)); camera_rot_ = Quaternion.LookRotation(-cameraToWorldMatrix.GetColumn(2), cameraToWorldMatrix.GetColumn(1)); Matrix4x4 projectionMatrix; photoCaptureFrame.TryGetProjectionMatrix(Camera.main.nearClipPlane, Camera.main.farClipPlane, out projectionMatrix); Matrix4x4 pixelToCameraMatrix = projectionMatrix.inverse; status.GetComponent <TextMesh>().text = "photo captured, processing..."; status.transform.position = camera_pos_; status.transform.rotation = camera_rot_; StartCoroutine(PostToServer(imageBufferList.ToArray(), cameraToWorldMatrix, pixelToCameraMatrix)); } photo_capture_.StopPhotoModeAsync(OnStoppedPhotoMode); }
//カメラの設定 ここまで。 private void OnCapturedPhotoToMemory(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result, UnityEngine.XR.WSA.WebCam.PhotoCaptureFrame photoCaptureFrame) { if (result.success) { List <byte> imageBufferList = new List <byte>(); // Copy the raw IMFMediaBuffer data into our empty byte list. photoCaptureFrame.CopyRawImageDataIntoBuffer(imageBufferList); DisplayImage(imageBufferList.ToArray()); //画像表示処理呼び出し StartCoroutine(GetVisionDataFromImages(imageBufferList.ToArray())); //API呼び出し } photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode); }