public override IEnumerator RunJob() { Debug.Log("*************************** CoroutineJobCapture ***************************"); BaseMapper mapper = host as BaseMapper; byte[] capture = new byte[channels * width * height + 1024]; Task <(string, icvCaptureInfo)> t = Task.Run(() => { icvCaptureInfo info = Core.CaptureImage(capture, capture.Length, pixels, width, height, channels); return(Convert.ToBase64String(capture, 0, info.captureSize), info); }); while (!t.IsCompleted) { yield return(null); } string encodedImage = t.Result.Item1; icvCaptureInfo captureInfo = t.Result.Item2; mapper.NotifyIfConnected(captureInfo); SDKImageRequest imageRequest = new SDKImageRequest(); imageRequest.token = mapper.token; imageRequest.run = this.run; imageRequest.bank = mapper.currentBank; imageRequest.index = this.index; imageRequest.anchor = this.anchor; imageRequest.px = position.x; imageRequest.py = position.y; imageRequest.pz = position.z; imageRequest.r00 = rotation.m00; imageRequest.r01 = rotation.m01; imageRequest.r02 = rotation.m02; imageRequest.r10 = rotation.m10; imageRequest.r11 = rotation.m11; imageRequest.r12 = rotation.m12; imageRequest.r20 = rotation.m20; imageRequest.r21 = rotation.m21; imageRequest.r22 = rotation.m22; imageRequest.fx = intrinsics.x; imageRequest.fy = intrinsics.y; imageRequest.ox = intrinsics.z; imageRequest.oy = intrinsics.w; imageRequest.latitude = latitude; imageRequest.longitude = longitude; imageRequest.altitude = altitude; imageRequest.b64 = encodedImage; string jsonString = JsonUtility.ToJson(imageRequest); using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, mapper.server, Endpoint.CAPTURE_IMAGE), jsonString)) { request.method = UnityWebRequest.kHttpVerbPOST; request.useHttpContinue = false; request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Accept", "application/json"); yield return(request.SendWebRequest()); Debug.Log("Response code: " + request.responseCode); if (request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else if (request.responseCode == (long)HttpStatusCode.OK) { SDKImageResult result = JsonUtility.FromJson <SDKImageResult>(request.downloadHandler.text); if (result.error == "none") { Debug.Log("Image uploaded successfully"); } } } }