<commit_before>//
//  RGBDepthFrame.metal
//  ObjectScanner
//
//  Created by <NAME> on 19/07/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

#include <metal_stdlib>

using namespace metal;

constant float fx_rgb = 5.2921508098293293e+02;
constant float fy_rgb = 5.2556393630057437e+02;
constant float cx_rgb = 3.2894272028759258e+02;
constant float cy_rgb = 2.6748068171871557e+02;

constant float fx_d = 1.0 / 5.9421434211923247e+02;
constant float fy_d = 1.0 / 5.9104053696870778e+02;
constant float cx_d = 3.3930780975300314e+02;
constant float cy_d = 2.4273913761751615e+02;

constant uint width = 640;
constant uint height = 480;

kernel void calibrateFrame(const constant float *depthValues [[buffer(0)]],
                           device float4 *outputPointCloud [[buffer(1)]],
                           const constant float4x4 &calibrationMatrix [[buffer(2)]],
                           const uint id [[thread_position_in_grid]])
{
    if (depthValues[id] > 1.f) //if the depth value is valid
    {
        //coordinates on depth frame
        uint x = id % width;
        uint y = id / width;
        
        //transform into 3D space
        float4 tempPoint;
        
        tempPoint.z = depthValues[id] / 1000.f; // mm to meter
        tempPoint.x = ((x - cx_d) * tempPoint.z * fx_d);
        tempPoint.y = ((y - cy_d) * tempPoint.z * fy_d);
        tempPoint.w = 1.f;
        
        //calibrate 3D point to rgb frame coordinates
        outputPointCloud[id] = calibrationMatrix * tempPoint;
        
        //corresponding 2D rgb frame coordinates for calibrated 3D point
        float invZ = 1.f / tempPoint.z;
        <commit_msg>Calibration metal shader code bug fix<commit_after>//
//  RGBDepthFrame.metal
//  ObjectScanner
//
//  Created by <NAME> on 19/07/2015.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

#include <metal_stdlib>

using namespace metal;

constant float fx_rgb = 5.2921508098293293e+02;
constant float fy_rgb = 5.2556393630057437e+02;
constant float cx_rgb = 3.2894272028759258e+02;
constant float cy_rgb = 2.6748068171871557e+02;

constant float fx_d = 1.0 / 5.9421434211923247e+02;
constant float fy_d = 1.0 / 5.9104053696870778e+02;
constant float cx_d = 3.3930780975300314e+02;
constant float cy_d = 2.4273913761751615e+02;

constant uint width = 640;
constant uint height = 480;

kernel void calibrateFrame(const constant float *depthValues [[buffer(0)]],
                           device float4 *outputPointCloud [[buffer(1)]],
                           const constant float4x4 &calibrationMatrix [[buffer(2)]],
                           const uint id [[thread_position_in_grid]])
{
    if (depthValues[id] > 1.f) //if the depth value is valid
    {
        //coordinates on depth frame
        uint x = id % width;
        uint y = id / width;
        
        //transform into 3D space
        float4 tempPoint;
        
        tempPoint.z = depthValues[id] / 1000.f; // mm to meter
        tempPoint.x = ((x - cx_d) * tempPoint.z * fx_d);
        tempPoint.y = ((y - cy_d) * tempPoint.z * fy_d);
        tempPoint.w = 1.f;
        
        //calibrate 3D point to rgb frame coordinates
        tempPoint = calibrationMatrix * tempPoint;
        
        //corresponding 2D rgb frame coordinates for calibrated 3D point
        float invZ = 1.f / tempPoint.z;
        
{'fraction_non_alphanumeric': 0.10265592360489406, 'fraction_numerical': 0.11459265890778872, 'mean_word_length': 2.345309381237525, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3951076', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1096, 'n_words': 305}