mprerun 0.1.2
MediaPipe + Rerun..
Requires Python: >=3.8

# mprerun

MediaPipe + Rerun..

视频人物骨骼点跟踪分析工具。

参考:  
[MediaPipe](https://ai.google.dev/edge/mediapipe/solutions/vision/pose_landmarker)  
[Rerun](https://rerun.io)  

## 安装

```console
$ pip install mprerun
```

## 示例

工作目录结构

```console
.
└── resources
    ├── config_pose_video_dd.json
    ├── config_pose_video_vd.json
    ├── config_pose_video_vv.json
    └── pose
        ├── angle
        │   └── angles.json
        ├── model
        │   ├── pose_landmarker_full.task
        │   ├── pose_landmarker_heavy.task
        │   └── pose_landmarker_lite.task
        └── video
            ├── demo1.json
            ├── demo1.mp4
            ├── demo2.json
            └── demo2.mp4
```

### 示例1(视频-视频)

```console
$ mprerun -c ./resources/config_pose_video_vv.json
```

### 示例2(视频-数据)

```console
$ mprerun -c ./resources/config_pose_video_vd.json
```

### 示例3(数据-数据)

```console
$ mprerun -c ./resources/config_pose_video_dd.json
```

## 配置文件

### config_pose_video_vv.json

```json
{
    "pose": {
        "angle": {
            "angles_path": "./resources/pose/angle/angles.json"
        },
        "video1": {
            "model_path": "./resources/pose/model/pose_landmarker_heavy.task",
            "video_path": "./resources/pose/video/demo1.mp4",
            "video_frames_size": 30
        },
        "video2": {
            "model_path": "./resources/pose/model/pose_landmarker_heavy.task",
            "video_path": "./resources/pose/video/demo2.mp4",
            "video_frames_size": 30
        },
        "viewer": {
            "image_show": "true",
            "image_quality": 50
        }
    }
}
```

### config_pose_video_vd.json

```json
{
    "pose": {
        "angle": {
            "angles_path": "./resources/pose/angle/angles.json"
        },
        "video1": {
            "model_path": "./resources/pose/model/pose_landmarker_heavy.task",
            "video_path": "./resources/pose/video/demo1.mp4",
            "video_frames_size": 30
        },
        "video2": {
            "video_data_path": "./resources/pose/video/demo2.json",
            "video_frames_size": 30
        },
        "viewer": {
            "image_show": "true",
            "image_quality": 50
        }
    }
}
```

### config_pose_video_dd.json

```json
{
    "pose": {
        "angle": {
            "angles_path": "./resources/pose/angle/angles.json"
        },
        "video1": {
            "video_data_path": "./resources/pose/video/demo1.json",
            "video_frames_size": 30
        },
        "video2": {
            "video_data_path": "./resources/pose/video/demo2.json",
            "video_frames_size": 30
        },
        "viewer": {
            "image_show": "true",
            "image_quality": 50
        }
    }
}
```

### angles.json

```json
{
    "angles": [
        [11, 13, 11, 12],
        [11, 13, 11, 23],
        [12, 14, 12, 11],
        [12, 14, 12, 24],
        [23, 25, 23, 24],
        [23, 25, 23, 11],
        [24, 26, 24, 23],
        [24, 26, 24, 12],
        [13, 11, 13, 15],
        [14, 12, 14, 16],
        [25, 23, 25, 27],
        [26, 24, 26, 28]
    ]
}
```

### demo.json

```json
{
    "video_data_prop": {
        "video_prop_fps": 29.97002997002997,
        "video_prop_frame_count": 150.0,
        "video_prop_frame_width": 1920.0,
        "video_prop_frame_height": 1080.0
    },
    "video_data_frames": [
        {
            "frame_index": 1,
            "frame_timestamp": 0,
            "frame_width": 1920,
            "frame_height": 1080,
            "frame_pose_landmarks": [
                [
                    0.6374563574790955,
                    0.22732973098754883,
                    -0.006511712912470102
                ],
                [
                    0.6366084814071655,
                    0.20985430479049683,
                    0.0022674542851746082
                ],
                [
                    0.6347998976707458,
                    0.20806953310966492,
                    0.002117771888151765
                ],
                [
                    0.6331192851066589,
                    0.2063925862312317,
                    0.0022154157049953938
                ],
                [
                    0.6372619271278381,
                    0.2102280855178833,
                    -0.027459949254989624
                ],
                [
                    0.6361058354377747,
                    0.20871677994728088,
                    -0.02769499272108078
                ],
                [
                    0.6349345445632935,
                    0.20708128809928894,
                    -0.02775220386683941
                ],
                [
                    0.6230870485305786,
                    0.20044925808906555,
                    0.05012011528015137
                ],
                [
                    0.6253166198730469,
                    0.20194169878959656,
                    -0.08477848023176193
                ],
                [
                    0.6300113201141357,
                    0.23730534315109253,
                    0.017391033470630646
                ],
                [
                    0.6307024359703064,
                    0.23763401806354523,
                    -0.023179929703474045
                ],
                [
                    0.5836086273193359,
                    0.2652994692325592,
                    0.1470586210489273
                ],
                [
                    0.6042976975440979,
                    0.267763614654541,
                    -0.1643378585577011
                ],
                [
                    0.5708694458007812,
                    0.38288986682891846,
                    0.19337743520736694
                ],
                [
                    0.6120849847793579,
                    0.38835668563842773,
                    -0.21533973515033722
                ],
                [
                    0.580338716506958,
                    0.4963623583316803,
                    0.1416417807340622
                ],
                [
                    0.6419399380683899,
                    0.48194918036460876,
                    -0.19742541015148163
                ],
                [
                    0.5781050324440002,
                    0.5141136050224304,
                    0.1456950604915619
                ],
                [
                    0.6442784667015076,
                    0.5121156573295593,
                    -0.22804169356822968
                ],
                [
                    0.5839279294013977,
                    0.5076907277107239,
                    0.1166519969701767
                ],
                [
                    0.6451822519302368,
                    0.513122022151947,
                    -0.21422065794467926
                ],
                [
                    0.5867054462432861,
                    0.49632105231285095,
                    0.12904351949691772
                ],
                [
                    0.644364595413208,
                    0.5047341585159302,
                    -0.19149546325206757
                ],
                [
                    0.5628982782363892,
                    0.48322781920433044,
                    0.09788647294044495
                ],
                [
                    0.5800283551216125,
                    0.48743298649787903,
                    -0.09803758561611176
                ],
                [
                    0.5813230872154236,
                    0.6326990127563477,
                    0.12674997746944427
                ],
                [
                    0.5872686505317688,
                    0.6402515769004822,
                    -0.06517860293388367
                ],
                [
                    0.5549697279930115,
                    0.7800683379173279,
                    0.17251025140285492
                ],
                [
                    0.5570164918899536,
                    0.7945365309715271,
                    -0.025968922302126884
                ],
                [
                    0.5439797043800354,
                    0.8074240684509277,
                    0.17337089776992798
                ],
                [
                    0.5451071858406067,
                    0.8208817839622498,
                    -0.023961490020155907
                ],
                [
                    0.5878034234046936,
                    0.8053338527679443,
                    0.1353233903646469
                ],
                [
                    0.5940501093864441,
                    0.8182159066200256,
                    -0.07322924584150314
                ]
            ],
            "frame_pose_landmarks_frame": [
                [
                    1223.9162063598633,
                    245.51610946655273
                ],
                [
                    1222.2882843017578,
                    226.64264917373657
                ],
                [
                    1218.815803527832,
                    224.7150957584381
                ],
                [
                    1215.5890274047852,
                    222.90399312973022
                ],
                [
                    1223.5429000854492,
                    227.04633235931396
                ],
                [
                    1221.3232040405273,
                    225.41412234306335
                ],
                [
                    1219.0743255615234,
                    223.64779114723206
                ],
                [
                    1196.327133178711,
                    216.4851987361908
                ],
                [
                    1200.60791015625,
                    218.09703469276428
                ],
                [
                    1209.6217346191406,
                    256.28977060317993
                ],
                [
                    1210.9486770629883,
                    256.64473950862885
                ],
                [
                    1120.528564453125,
                    286.52342677116394
                ],
                [
                    1160.251579284668,
                    289.1847038269043
                ],
                [
                    1096.0693359375,
                    413.52105617523193
                ],
                [
                    1175.2031707763672,
                    419.42522048950195
                ],
                [
                    1114.2503356933594,
                    536.0713469982147
                ],
                [
                    1232.5246810913086,
                    520.5051147937775
                ],
                [
                    1109.9616622924805,
                    555.2426934242249
                ],
                [
                    1237.0146560668945,
                    553.0849099159241
                ],
                [
                    1121.1416244506836,
                    548.3059859275818
                ],
                [
                    1238.7499237060547,
                    554.1717839241028
                ],
                [
                    1126.4744567871094,
                    536.026736497879
                ],
                [
                    1237.1800231933594,
                    545.1128911972046
                ],
                [
                    1080.7646942138672,
                    521.8860447406769
                ],
                [
                    1113.654441833496,
                    526.4276254177094
                ],
                [
                    1116.1403274536133,
                    683.3149337768555
                ],
                [
                    1127.555809020996,
                    691.4717030525208
                ],
                [
                    1065.541877746582,
                    842.4738049507141
                ],
                [
                    1069.471664428711,
                    858.0994534492493
                ],
                [
                    1044.441032409668,
                    872.017993927002
                ],
                [
                    1046.6057968139648,
                    886.5523266792297
                ],
                [
                    1128.5825729370117,
                    869.7605609893799
                ],
                [
                    1140.5762100219727,
                    883.6731791496277
                ]
            ],
            "frame_pose_world_landmarks": [
                [
                    0.27402693033218384,
                    -0.5149004459381104,
                    -0.09316663444042206
                ],
                [
                    0.2724616825580597,
                    -0.5521482825279236,
                    -0.09490816295146942
                ],
                [
                    0.27470237016677856,
                    -0.5512441992759705,
                    -0.08382111042737961
                ],
                [
                    0.2752443253993988,
                    -0.5516132116317749,
                    -0.08818093687295914
                ],
                [
                    0.28051650524139404,
                    -0.5580958127975464,
                    -0.13495971262454987
                ],
                [
                    0.2825529873371124,
                    -0.5556992888450623,
                    -0.14803966879844666
                ],
                [
                    0.28463393449783325,
                    -0.5436263680458069,
                    -0.1268727034330368
                ],
                [
                    0.18447744846343994,
                    -0.5985233187675476,
                    -0.03926742449402809
                ],
                [
                    0.16803103685379028,
                    -0.5431269407272339,
                    -0.16935980319976807
                ],
                [
                    0.2489212453365326,
                    -0.5260776877403259,
                    -0.05703597515821457
                ],
                [
                    0.23907193541526794,
                    -0.4860190451145172,
                    -0.12133949995040894
                ],
                [
                    0.06885463744401932,
                    -0.4594334363937378,
                    0.1425355076789856
                ],
                [
                    0.1625959575176239,
                    -0.4987016022205353,
                    -0.13628949224948883
                ],
                [
                    0.03946474939584732,
                    -0.23554858565330505,
                    0.19225873053073883
                ],
                [
                    0.18171846866607666,
                    -0.21096602082252502,
                    -0.2258823961019516
                ],
                [
                    0.07569683343172073,
                    0.024422481656074524,
                    0.22401578724384308
                ],
                [
                    0.24413545429706573,
                    -0.0006819367408752441,
                    -0.2075652927160263
                ],
                [
                    0.06354352086782455,
                    0.04647868126630783,
                    0.25415876507759094
                ],
                [
                    0.2820682227611542,
                    0.017615634948015213,
                    -0.2598194181919098
                ],
                [
                    0.07197163999080658,
                    0.06201447546482086,
                    0.23325608670711517
                ],
                [
                    0.32051709294319153,
                    -0.0025258585810661316,
                    -0.23319636285305023
                ],
                [
                    0.08462521433830261,
                    0.05672026425600052,
                    0.21942369639873505
                ],
                [
                    0.25926440954208374,
                    -0.003456428647041321,
                    -0.2030642032623291
                ],
                [
                    -0.02859065867960453,
                    0.0012337439693510532,
                    0.12160316109657288
                ],
                [
                    0.032211266458034515,
                    -0.005233848467469215,
                    -0.12093059718608856
                ],
                [
                    0.02610205113887787,
                    0.41665369272232056,
                    0.14157110452651978
                ],
                [
                    0.08586161583662033,
                    0.33829373121261597,
                    -0.05439451336860657
                ],
                [
                    -0.024886801838874817,
                    0.7573713660240173,
                    0.22164930403232574
                ],
                [
                    -0.06269465386867523,
                    0.6956365704536438,
                    0.04010897874832153
                ],
                [
                    -0.043395787477493286,
                    0.790997326374054,
                    0.23850078880786896
                ],
                [
                    -0.06729869544506073,
                    0.7278320789337158,
                    0.012264762073755264
                ],
                [
                    0.06654155254364014,
                    0.7759133577346802,
                    0.2536061704158783
                ],
                [
                    0.07220986485481262,
                    0.7308629155158997,
                    -0.0107024060562253
                ]
            ],
            "frame_pose_landmarks_angles_values": [
                111.29503037886361,
                34.053571526379734,
                113.52579561589768,
                40.77138326792562,
                98.98463819647094,
                153.4367597071525,
                79.38328984691199,
                170.14282156781806,
                132.95820925585602,
                144.06593712645457,
                162.25286190299886,
                166.42227834900868
            ],
            "frame_pose_world_landmarks_angles_values": [
                111.73541655116284,
                15.607550211861446,
                99.94350372599621,
                26.395877099585782,
                92.29647850302189,
                159.86015811173732,
                80.18290480372676,
                154.78939931563445,
                163.8412917612716,
                154.63236927117225,
                161.07841887697393,
                149.1551189189239
            ]
        },
        ...        
    ]
}
```