2
Silverlight 용 HLSL 픽셀 쉐이더를 사용하여 비디오 이미지에서 배경 이미지를 뺍니다. 누구든지 내 알고리즘이 올바르게하고 있지 않기 때문에 내가 사용하고있는 것보다 더 정교한 알고리즘을 제안 할 수 있습니까? 배경 이미지를 빼는 HLSL 쉐이더
float Tolerance : register(C1);
SamplerState ImageSampler : register(S0);
SamplerState BackgroundSampler : register(S1);
struct VS_INPUT
{
float4 Position : POSITION;
float4 Diffuse : COLOR0;
float2 UV0 : TEXCOORD0;
float2 UV1 : TEXCOORD1;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Color : COLOR0;
float2 UV : TEXCOORD0;
};
float4 PS(VS_OUTPUT input) : SV_Target
{
float4 color = tex2D(ImageSampler, input.UV);
float4 background = tex2D(BackgroundSampler, input.UV);
if (abs(background.r - color.r) <= Tolerance &&
abs(background.g - color.g) <= Tolerance &&
abs(background.b - color.b) <= Tolerance)
{
color.rgba = 0;
}
return color;
}
이의 예를 확인하려면, 당신은 웹캠으로 컴퓨터가 필요 :
- 페이지 http://xmldocs.net/alphavideo/background.html
- 을 눌러 [녹화 시작]로 이동합니다.
- 장면에서 몸을 움직여 [배경 캡처]를 누릅니다.
- 그런 다음 본문을 다시 장면으로 이동하고 슬라이더를 사용하여 Toleance 값을 쉐이더로 조정하십시오.
정확히 "올바르게하지 못하고"얼마나 정확합니까? 그리고 당신의 쉐이더가 전혀 작동하지 않는다는 것에 놀랐다. – Denis
HLSL의 적응 형 배경 제거에 대한 다음 예제를 살펴보십시오. http://vvvv.org/forum/adaptive-background-substraction – appas