This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: resolve mirroring issue

+38 -37
+1 -1
README.md
··· 8 8 Import the Compose library 9 9 10 10 ```kotlin 11 - implementation("com.performancecoachlab.posedetection:posedetection-compose:4.1.0") 11 + implementation("com.performancecoachlab.posedetection:posedetection-compose:4.1.3") 12 12 ``` 13 13 14 14 Add camera use to your android manifest
+1 -1
posedetection/build.gradle.kts
··· 6 6 7 7 mavenPublishing { 8 8 publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) 9 - coordinates("com.performancecoachlab.posedetection", "posedetection-compose", "4.1.0") 9 + coordinates("com.performancecoachlab.posedetection", "posedetection-compose", "4.1.3") 10 10 11 11 pom { 12 12 name.set("Pose Detection")
+3 -3
posedetection/src/androidMain/kotlin/com.performancecoachlab/posedetection/camera/CameraView.android.kt
··· 122 122 val path = builder.finalize() 123 123 onVideoSaved(id, path) 124 124 } catch (e: Exception) { 125 - println("Error finalizing recording $id: ${e.message}") 125 + //println("Error finalizing recording $id: ${e.message}") 126 126 } 127 127 } 128 128 activeRecordings = activeRecordings - id ··· 151 151 } 152 152 } catch (e: Exception) { 153 153 // Handle recording errors gracefully 154 - println("Error recording frame for ID $id: ${e.message}") 154 + //println("Error recording frame for ID $id: ${e.message}") 155 155 } 156 156 } 157 157 } ··· 209 209 ){ 210 210 customObjectRepository.updateCustomObject(it.objects) 211 211 it.skeleton?.let { skel -> 212 - skeletonRepository.updateSkeleton(skel.mirror()) 212 + skeletonRepository.updateSkeleton(skel) 213 213 } 214 214 bitmap = 215 215 imageProxy.toBitmap().rotate(imageProxy.imageInfo.rotationDegrees.toFloat())
+1 -1
posedetection/src/androidMain/kotlin/com/performancecoachlab/posedetection/camera/Utils.android.kt
··· 201 201 poseDetector?.process(it)?.addOnSuccessListener { pose -> 202 202 skeleton = skeleton(pose, timestamp, width, height) 203 203 }?.addOnFailureListener { e -> 204 - println(e) 204 + //println(e) 205 205 } 206 206 } 207 207 Tasks.whenAllComplete(listOfNotNull(poseDetectionTask)).addOnCompleteListener {
+1 -1
posedetection/src/androidMain/kotlin/com/performancecoachlab/posedetection/encoding/VideoBuilder.android.kt
··· 196 196 inputBuffer.put(yuvData) 197 197 } else { 198 198 inputBuffer.put(yuvData, 0, bufferCapacity) 199 - println("Warning: YUV data (${yuvData.size} bytes) exceeded buffer capacity ($bufferCapacity bytes)") 199 + //println("Warning: YUV data (${yuvData.size} bytes) exceeded buffer capacity ($bufferCapacity bytes)") 200 200 } 201 201 } 202 202 val dataSize = minOf(yuvData.size, inputBuffer?.capacity() ?: 0)
+12 -5
posedetection/src/iosMain/kotlin/com/performancecoachlab/posedetection/camera/CameraEngine.kt
··· 13 13 import com.performancecoachlab.posedetection.custom.CustomObjectRespository 14 14 import com.performancecoachlab.posedetection.custom.ObjectModel 15 15 import com.performancecoachlab.posedetection.recording.AnalysisObject 16 + import com.performancecoachlab.posedetection.recording.FrameSize 16 17 import com.performancecoachlab.posedetection.skeleton.Skeleton 17 18 import com.performancecoachlab.posedetection.skeleton.SkeletonRepository 18 19 import kotlinx.cinterop.ExperimentalForeignApi ··· 132 133 cameraController.setupPreviewLayer(view) 133 134 startSession() 134 135 cameraController.onError = { error -> 135 - println("Camera Error: $error") 136 + //println("Camera Error: $error") 136 137 } 137 138 } 138 139 ··· 519 520 it.copy( 520 521 boundingBox = mapBoxToPreview( 521 522 it.boundingBox, preview, width = 480f, height = 360f 522 - ) 523 - ) 523 + ), frameSize = it.frameSize.let { 524 + mapBoxToPreview( 525 + Rect(Offset.Zero, Size(480f, 360f)), 526 + preview, 527 + width = 480f, 528 + height = 360f 529 + ).let { FrameSize(it.width.toInt(), it.height.toInt()) } 530 + }) 524 531 } 525 - previewObjects?.also{ objects-> 532 + previewObjects?.also { objects -> 526 533 customObjectRepository?.updateCustomObject(objects) 527 534 } 528 535 ··· 544 551 } 545 552 } 546 553 } catch (e: Exception) { 547 - println(e.message ?: "Unknown error in frame processing") 554 + //println(e.message ?: "Unknown error in frame processing") 548 555 } 549 556 } 550 557 }
+4 -4
posedetection/src/iosMain/kotlin/com/performancecoachlab/posedetection/camera/Conversions.kt
··· 27 27 // Lock the pixel buffer 28 28 val lockResult = CVPixelBufferLockBaseAddress(this, CVPixelBufferLockFlags.MAX_VALUE) 29 29 if (lockResult != 0) { 30 - println("Error: Failed to lock pixel buffer") 30 + //println("Error: Failed to lock pixel buffer") 31 31 return null 32 32 } 33 33 ··· 75 75 ) 76 76 return videoImage 77 77 }catch (e: Exception) { 78 - println("Error: Failed to create CGImage from CVImageBufferRef: ${e.message}") 78 + //println("Error: Failed to create CGImage from CVImageBufferRef: ${e.message}") 79 79 return null 80 80 } 81 81 } ··· 99 99 ) 100 100 return videoImage 101 101 }catch (e: Exception) { 102 - println("Error: Failed to create CGImage from CVImageBufferRef: ${e.message}") 102 + //println("Error: Failed to create CGImage from CVImageBufferRef: ${e.message}") 103 103 return null 104 104 } 105 105 } ··· 131 131 // Call a function to process the UIImage 132 132 return image.toImageBitmap() 133 133 }catch (e: Exception) { 134 - println("Error: Failed to create CGImage from CVImageBufferRef: ${e.message}") 134 + //println("Error: Failed to create CGImage from CVImageBufferRef: ${e.message}") 135 135 return null 136 136 137 137 }finally {
+6 -6
posedetection/src/iosMain/kotlin/com/performancecoachlab/posedetection/camera/FrameProcessor.kt
··· 60 60 // Process each observation to find the recognized body pose points. 61 61 return observations.map { processObservation(it) } 62 62 } catch (e: Exception) { 63 - println("Error processing observations: ${e.message}") 63 + //println("Error processing observations: ${e.message}") 64 64 return null 65 65 } 66 66 } ··· 161 161 } 162 162 requests = mutableListOf(objectRecognition) 163 163 } catch (e: Throwable) { 164 - println("Vision setup error: ${e.message}") 164 + //println("Vision setup error: ${e.message}") 165 165 } 166 166 } 167 167 } ··· 310 310 listOfNotNull(requestForObjects, requestForSkeleton), errorPtr.ptr 311 311 ) 312 312 if (errorPtr.value != null) { 313 - println("Error performing object detection request: ${errorPtr.value}") 313 + //println("Error performing object detection request: ${errorPtr.value}") 314 314 onObjectsProcessed(emptyList()) 315 315 onSkeletonProcessed(null) 316 316 } 317 317 } catch (e: Throwable) { 318 - println("Unable to perform the object detection request: ${e.message}") 318 + //println("Unable to perform the object detection request: ${e.message}") 319 319 onObjectsProcessed(emptyList()) 320 320 onSkeletonProcessed(null) 321 321 } ··· 554 554 listOfNotNull(requestForObjects, requestForSkeleton), errorPtr.ptr 555 555 ) 556 556 if (errorPtr.value != null) { 557 - println("Error performing object detection request: ${errorPtr.value}") 557 + //println("Error performing object detection request: ${errorPtr.value}") 558 558 onObjectsProcessed(emptyList()) 559 559 onSkeletonProcessed(null) 560 560 } 561 561 } catch (e: Throwable) { 562 - println("Unable to perform the object detection request: ${e.message}") 562 + //println("Unable to perform the object detection request: ${e.message}") 563 563 onObjectsProcessed(emptyList()) 564 564 onSkeletonProcessed(null) 565 565 }
+5 -6
posedetection/src/iosMain/kotlin/com/performancecoachlab/posedetection/custom/CustomObjectModel.ios.kt
··· 16 16 @OptIn(ExperimentalForeignApi::class) 17 17 fun createObjectDetector(model: String?): VNCoreMLModel? { 18 18 if(model == null) { 19 - println("Model path is null") 20 19 return null 21 20 } 22 - println("Model input: $model") 21 + //println("Model input: $model") 23 22 val path = NSBundle.mainBundle.pathForResource(model, "mlmodelc") 24 - println("Model path: $path") 23 + //println("Model path: $path") 25 24 val url = path?.let { NSURL.fileURLWithPath(it) } 26 - println("Model URL: $url") 25 + //println("Model URL: $url") 27 26 val modelCont = url?.let {MLModel.modelWithContentsOfURL(it, null)} 28 - println("Model content: $modelCont") 27 + //println("Model content: $modelCont") 29 28 val modelObj = modelCont?.let {VNCoreMLModel.modelForMLModel(it,null)} 30 - println("Model: $modelObj") 29 + //println("Model: $modelObj") 31 30 return modelObj 32 31 } 33 32
+2 -2
posedetection/src/iosMain/kotlin/com/performancecoachlab/posedetection/encoding/VideoBuilder.ios.kt
··· 189 189 pixelBufferAdaptor.appendPixelBuffer(pixelBuffer, withPresentationTime = presentationTime) 190 190 CVPixelBufferRelease(pixelBuffer) 191 191 } else { 192 - println("Failed to allocate pixel buffer: $status") 192 + //println("Failed to allocate pixel buffer: $status") 193 193 } 194 194 } 195 195 frameCount++ ··· 200 200 if (started) { 201 201 input?.markAsFinished() 202 202 writer?.finishWritingWithCompletionHandler { 203 - println("[VideoBuilder] Finished writing video!") 203 + //println("[VideoBuilder] Finished writing video!") 204 204 } 205 205 // Wait for writing to finish 206 206 while (writer?.status == AVAssetWriterStatusWriting) {}
+2 -7
sample/composeApp/src/commonMain/kotlin/com/nate/posedetection/App.kt
··· 48 48 import com.performancecoachlab.posedetection.permissions.PermissionProvider 49 49 import com.performancecoachlab.posedetection.recording.AnalysisObject 50 50 import com.performancecoachlab.posedetection.recording.FrameAnalyser 51 + import com.performancecoachlab.posedetection.recording.FrameSize 51 52 import com.performancecoachlab.posedetection.recording.InputFrame 52 53 import com.performancecoachlab.posedetection.recording.Label 53 54 import com.performancecoachlab.posedetection.recording.extractFrame ··· 195 196 val extractedFrame = extractFrame(url, frame) 196 197 extractedFrame?.let { frame -> 197 198 frameAnalyser.analyseFrame(frame).let { analysisResults -> 198 - analysisResults.objects.let { 199 - if (it.isNotEmpty()) { 200 - it.forEach { obj -> 201 - println("Detected Objects: ${obj.labels}") 202 - } 203 - } 204 - } 205 199 frame.drawAnalysisResults(analysisResults).also { 206 200 if (!isRecording) { 207 201 size = Pair(it.width, it.height) ··· 336 330 detectMode = DetectMode.BOTH, 337 331 drawSkeleton = true, 338 332 drawObjects = { obj -> 333 + 339 334 obj.map { 340 335 DrawableObject( 341 336 obj = it,