/ARKitRecorder

Record image and camera pos, etc. information provided by ARKit and save them into files.

Primary LanguageSwift

ARKitRecorder

Record image and camera pos, etc. information provided by ARKit and save them into files.

Demo

gif

The app will start recording the ARKit Info when users has pressed down the button. Every time the the ARFrame has been updated, the session update delegate method is called. We then extract the CVPixelBuffer from the ARFrame and convert it into jpg, and write to local file. We also convert other information including ARCamera, LightEstimate and PointCloud information into json object and stores it into the member variable. You can find the json format in the following section.

When the button is released, all of the json object will be written into the local json file, and the objects will be removed and released. The images and json file will be written into the folder into app's document directory, and the name of the folder will be the timestamp when the button is pressed, a.k.a. the time when the session starts recording.

All of the process above is done asyncronously.

Repository Content

The repository has two project folders. The ARRecorder is implemented in swift and the OCARKitTest is implemented in objective-C. They have the same function as discussed above, except that the objective-C project couldn't store the point cloud info. I don't know have to get it from a Vector3* in the ARFrame. If you do know, please make an issue or create a pull request.

Saved Json Sample File

{
    "41007.023854.jpg": {
        "cameraPos": {
            "y": 0.06280376,
            "x": 0.09753288,
            "z": 0.2484026
        },
        "cameraTransform": [
            [0.7944834, 0.1900937, -0.5767672, 0.09753288],
            [0.02751624, 0.9375021, 0.3468895, 0.06280376],
            [0.6066621, -0.2914684, 0.7395993, 0.2484026],
            [0, 0, 0, 0.9999999]
        ],
        "cameraIntrinsics": [
            [1089.032, 0, 639.5],
            [0, 1089.032, 359.5],
            [0, 0, 1]
        ],
        "lightEstimate": 900,
        "cameraEulerAngle": {
            "y": -0.6623252,
            "x": -0.3542526,
            "z": 0.02934217
        },
        "imageResolution": {
            "height": 720,
            "width": 1280
        },
        "ARPointCloud": {
            "count": 186,
            "points": [
                [0.009132311, -0.1209963, -0.3236341],
                [0.03226537, -0.200156, -0.2408179],
                [-0.03220909, -0.1751883, -0.2980332],
                [0.1577605, -0.04950373, -0.165259],
                [-0.01605938, -0.1400419, -0.3291739],
                [0.1319766, -0.008718062, -0.2003034],
                [-0.007355154, -0.1416959, -0.3188091],
                [0.3313366, 0.01935824, -0.2032971],
                [-0.07076509, -0.1112466, -0.337195],
                [-0.02018498, -0.2368188, -0.2609907],
                [-0.05286608, -0.1704044, -0.3560755],
                [0.1514294, -0.1075755, -0.3322785],
                [0.1554509, -0.09778123, -0.3796904],
                [0.02490559, -0.02921103, -0.3341784],
                [-0.05820668, -0.1893865, -0.3033345],
                [-0.04606581, -0.1827758, -0.3130469],
                [0.1270572, -0.107662, -0.2857522],
                [-0.01356305, -0.1693852, -0.3217589],
                [-0.02473646, -0.1647124, -0.3247154],
                [0.1232813, -0.1094018, -0.3111144],
                [-0.03939822, -0.07165599, -0.3489678],
                [0.1005396, -0.1922425, -0.2410965],
                [0.06187627, -0.2126638, -0.2194115],
                [0.09666727, -0.02754505, -0.2959799],
                [-0.1031297, -0.07901378, -0.3408114],
                [-0.01732007, -0.1472233, -0.3098564],
                [0.0837225, -0.1920089, -0.2348163],
                [0.1663142, -0.02802945, -0.1673914],
                [0.04758872, -0.01512341, -0.3454195],
                [0.06914417, -0.181204, -0.2058228],
                [-0.1241367, -0.1809553, -0.3325305],
                [0.1505838, -0.1211156, -0.1359289],
                [0.05341429, -0.1504091, -0.2446346],
                [-0.08765899, -0.1897943, -0.3311989],
                [0.06169243, -0.1355601, -0.2405252],
                [0.1604276, -0.04058768, -0.1757065],
                [0.0003910735, -0.1152356, -0.3201051],
                [0.07833913, 0.01322397, -0.3357955],
                [0.03521042, -0.01460005, -0.346622],
                [0.1765665, -0.1551093, -0.1198196],
                [-0.01465157, -0.1842213, -0.2829099],
                [0.0710972, -0.1908163, -0.1973532],
                [0.1122294, -0.2256657, -0.2255732],
                [0.005977526, -0.1978352, -0.2176857],
                [0.01892945, -0.1843723, -0.2875409],
                [-0.002296612, -0.1814602, -0.2926783],
                [0.3830997, 0.02660902, -0.1696825],
                [0.3424603, -0.1480667, -0.04515594],
                [0.2790607, -0.1702344, -0.06515986],
                [0.3310208, -0.1477595, -0.0511868],
                [0.1123297, -0.08321467, -0.1799812],
                [0.002445705, 0.002877697, -0.4669902],
                [0.2808658, 0.02299467, -0.2083342],
                [0.04973169, -0.1696175, -0.2238568],
                [0.4206148, 0.02419429, -0.1505612],
                [0.1261626, -0.0002518669, -0.2539964],
                [0.1734181, -0.03336413, -0.1684284],
                [0.3070028, 0.05225347, -0.2078866],
                [0.3556913, -0.08839515, -0.06064662],
                [0.3526709, -0.1415869, -0.03522892],
                [0.2639036, -0.007656161, -0.2356512],
                [0.3694809, -0.07897601, -0.06062073],
                [0.10051, 0.00210271, -0.3399099],
                [0.302935, 0.0619114, -0.2057358],
                [0.06465274, -0.008679517, -0.3407652],
                [-0.04710148, -0.1035934, -0.3194397],
                [0.4216308, 0.007393185, -0.1471725],
                [0.1666648, -0.0999988, -0.135846],
                [0.2884136, 0.06021173, -0.2152956],
                [0.09166181, -0.2140974, -0.2174672],
                [0.1416324, -0.1694568, -0.1146619],
                [0.2676041, -0.1758364, -0.06348264],
                [0.3663727, -0.145941, -0.03660239],
                [0.08252259, -0.1917904, -0.251707],
                [0.08689615, -0.1825502, -0.2488552],
                [0.2140646, -0.1224958, -0.1098965],
                [-0.05647539, -0.1985693, -0.2844332],
                [0.1109236, -0.1223, -0.1591452],
                [0.01245674, -0.1881767, -0.3100324],
                [0.3054665, 0.009664614, -0.2070585],
                [0.1033829, -0.1241416, -0.2344085],
                [0.1227538, -0.1059557, -0.1538064],
                [0.1930999, -0.1515661, -0.107386],
                [0.1196675, -0.1369747, -0.3616741],
                [0.4201573, -0.04472081, -0.06349486],
                [0.1944004, -0.0987706, -0.1073036],
                [-0.07824224, -0.2060013, -0.2955103],
                [0.3110188, 0.03562087, -0.2160631],
                [0.1998252, -0.08226287, -0.1219845],
                [0.09801094, -0.206471, -0.2345924],
                [0.1048865, -0.1586383, -0.1442322],
                [0.1073297, -0.1496385, -0.152073],
                [0.1722207, -0.1224904, -0.1289135],
                [0.2032806, -0.004749451, -0.2519913],
                [0.07196841, -0.1373988, -0.2785645],
                [0.1442089, -0.173317, -0.1201974],
                [0.3577601, -0.1352565, -0.03462374],
                [0.1264042, -0.1113145, -0.3184481],
                [0.1592344, -0.1214034, -0.1331621],
                [-0.006791152, -0.1163619, -0.3668895],
                [0.1617275, -0.02586277, -0.1605376],
                [0.196138, -0.03540482, -0.1551147],
                [0.210039, 0.02689434, -0.2399443],
                [0.05900721, 0.011053, -0.3515739],
                [0.3937826, -0.1544357, -0.01522782],
                [0.007820025, -0.03258337, -0.4051884],
                [0.2795244, 0.02334096, -0.1786707],
                [0.01348771, -0.02587302, -0.337921],
                [0.2780728, 0.02206303, -0.1811134],
                [0.3697429, 0.02831079, -0.1676253],
                [0.04950674, -0.1691051, -0.252494],
                [0.04532458, -0.115174, -0.3110057],
                [-0.003341988, -0.04226178, -0.4399728],
                [0.09552874, -0.009236868, -0.355876],
                [0.797521, -0.3218597, -0.2321984],
                [0.3462022, 0.01226659, -0.1890963],
                [0.05017391, -0.1836739, -0.2220949],
                [0.1830946, -0.1227164, -0.124518],
                [0.2253338, -0.040475, -0.1317491],
                [0.6147396, -0.1989499, -0.07369515],
                [0.1809842, -0.1198135, -0.1185632],
                [-0.03208344, -0.1777039, -0.2850993],
                [0.444177, -0.03648546, -0.04566325],
                [0.003182702, -0.1922599, -0.2917473],
                [-0.09219475, -0.2217075, -0.3172447],
                [0.2124138, -0.1212637, -0.1079484],
                [0.003292046, -0.1373492, -0.3109075],
                [0.005007848, -0.1060771, -0.352671],
                [0.2065314, -0.124196, -0.1179986],
                [0.2821119, -0.1103951, -0.08312163],
                [0.03460646, -0.1288961, -0.3110766],
                [-0.04029401, -0.1448512, -0.3531353],
                [-0.072791, -0.2116724, -0.2673474],
                [0.1552607, -0.04470988, -0.1642226],
                [0.408096, -0.02645793, -0.06409821],
                [0.03514388, -0.02137767, -0.3337263],
                [0.2296386, -0.04228944, -0.1379578],
                [0.08471067, 0.02180198, -0.336098],
                [0.4279425, 0.03443981, -0.1442262],
                [0.2126466, 0.03897433, -0.2483299],
                [-0.0269919, -0.2658695, -0.3893555],
                [0.02834117, -0.1059742, -0.3116994],
                [-0.0750197, -0.1918698, -0.3111069],
                [0.0797745, -0.1291811, -0.3261306],
                [0.269743, -0.1663122, -0.07008553],
                [0.07034296, -0.1012917, -0.3414575],
                [-0.06826667, -0.1457474, -0.3675424],
                [0.021018, -0.1801375, -0.2975871],
                [0.3637897, -0.02208397, -0.0655427],
                [0.3849052, 0.02818482, -0.1659206],
                [0.1019772, -0.2095834, -0.220565],
                [0.2177141, 0.0412197, -0.2555601],
                [0.0762476, -0.1267926, -0.3170301],
                [0.2093235, 0.02460798, -0.2345395],
                [0.06951919, -0.187148, -0.1943797],
                [0.01535216, -0.2047837, -0.2190906],
                [0.4861624, -0.004430309, -0.101487],
                [0.007924154, -0.1747141, -0.2803136],
                [0.06286739, -0.1413551, -0.2296054],
                [0.1130772, -0.102984, -0.1932746],
                [0.1642656, -0.09875938, -0.133059],
                [0.2337254, -0.04561256, -0.1488943],
                [0.2865162, -0.1131881, -0.08873889],
                [-0.00916826, -0.1923979, -0.3029325],
                [-0.01515413, -0.1746025, -0.3327633],
                [0.2962177, -0.1892772, -0.04538584],
                [0.3478931, -0.1912441, -0.03035541],
                [0.4735448, -0.01056055, -0.0836058],
                [0.3653644, -0.08800904, -0.05968162],
                [0.04216598, -0.1101882, -0.2964901],
                [0.1557866, -0.1132867, -0.1165269],
                [0.248346, -0.03984988, -0.1248649],
                [0.1580038, -0.04755152, -0.1729901],
                [0.3615348, -0.06668775, -0.06929395],
                [0.2416582, -0.04151135, -0.1365539],
                [0.0845318, -0.1591054, -0.2215261],
                [0.1602972, -0.123395, -0.1369614],
                [-0.005372144, -0.05343307, -0.4798136],
                [0.05753894, -0.1381211, -0.2872882],
                [0.2741682, -0.0767476, -0.08593756],
                [0.2984598, -0.04769394, -0.1338264],
                [0.430488, 0.03482831, -0.1466277],
                [0.4127716, 0.02635332, -0.157829],
                [0.3837153, 0.02754945, -0.1639924],
                [0.490288, 0.06533278, -0.1150273],
                [0.2891606, 0.02491214, -0.2227395]
            ]
        },
        "imageName": "41007.023854.jpg",
        "timeStamp": 41007.023853791
    }
}

You can find more sample json and image data in the sampleAppData.xcappdata container.