iOS White Balance Problem
1. SDK Version: 3.5
2. Development Environment: Native iOS
3. Tracker/Scanner:
4. License Type(Free / Pro-One Time Fee / Pro-Subscription / Enterprise): Free
5. Target Device(Optional): iphone se, 6, 6s, 7+, X
I'm working on project based on swift scenekit instant tracking sample. But I have problem with camera.
The picture from the camera is too light.
Maybe you know some solution to this problem?
Thanks!
Screenshot from sample app:
Original Photo:
1. you can find video_fragment_func fragment shader at MetalFunction.metal file.
2. change code video_fragment_func below code. you can change white Balance as use 'gammar' value.
fragment half4 video_fragment_func(VertexOut in [[stage_in]],
texture2d<float, access::sample> textureY [[ texture(0) ]],
texture2d<float, access::sample> textureCbCr [[ texture(1) ]],
constant ColorConversion &colorConversion [[ buffer(0) ]]) {
constexpr sampler s(address::clamp_to_edge, filter::linear);
float3 ycbcr = float3(textureY.sample(s, in.texCoord).r, textureCbCr.sample(s, in.texCoord).rg);
float gamma = 0.5;
float3 rgb = colorConversion.matrix * (ycbcr + colorConversion.offset);
rgb = pow(rgb, float3(1.0/gamma));
return half4(half3(rgb), 1.0);
}
Thank you. It works. I have already tried to change the values of the correction matrix in the BackgroundCameraQuad. This partially solved the problem, but the solution looked like a crutch.
ColorConversion matrix is value that change YUV to RGB .
that problem is changing from RGB to SRGB, This is because the scenekit automatically sets the pixel format.
we will find fix that problem. thank you