void Update() { if (Bridge.Status != Ros.Status.Connected) { return; } Reader.Update(); if (Reader.Status == AsyncTextureReader.ReadStatus.Finished) { var data = Reader.GetData(); #if USE_COMPRESSED Task.Run(() => { lock (jpegArray) { int length = JpegEncoder.Encode(data, videoWidth, videoHeight, Reader.BytesPerPixel, 75, jpegArray); data.Dispose(); if (length > 0) { SendImage(jpegArray, length); } } }); #else SendImage(data.ToArray(), data.Length); data.Dispose(); #endif } if (Reader.Status != AsyncTextureReader.ReadStatus.Reading && !ImageIsBeingSent) { if (manual) { if (Input.GetKeyDown(KeyCode.S)) { Reader.Start(); } } else { if (Time.time - lastTimePoint > 1.0f / sendingFPS) { lastTimePoint = Time.time; Reader.Start(); } } } }
void Update() { if (Bridge == null || Bridge.Status != Ros.Status.Connected) { return; } Reader.Update(); if (Reader.Status == AsyncTextureReaderStatus.Finished) { var data = Reader.GetData(); #if USE_COMPRESSED var copy = new NativeArray <byte>(data, Allocator.Persistent); Task.Run(() => { lock (jpegArray) { int length = JpegEncoder.Encode(copy, videoWidth, videoHeight, Reader.BytesPerPixel, JpegQuality, jpegArray); if (length > 0) { SendImage(jpegArray, length); } } copy.Dispose(); }); #else SendImage(data.ToArray(), data.Length); #endif } if (Reader.Status != AsyncTextureReaderStatus.Reading && !ImageIsBeingSent) { if (manual) { if (Input.GetKeyDown(KeyCode.M)) { Reader.Start(); } } else { if (Time.time - lastTimePoint > 1.0f / sendingFPS) { lastTimePoint = Time.time; Reader.Start(); } } } }
private void Update() { if (isEnabled && Reader != null) { Reader.Update(); if (Reader.Status != AsyncTextureReaderStatus.Reading) { Reader.Start(); } } if (isEnabled && cameraDetectedColliders != null) { detectedObjects = cameraDetectedColliders.Values.ToList(); cameraDetectedColliders.Clear(); objId = 0; if (targetEnv == ROSTargetEnvironment.AUTOWARE || targetEnv == ROSTargetEnvironment.APOLLO) { PublishGroundTruth(detectedObjects); } } }