I've tried implementing the background keying thing now like this:
kernel vec4 backgroundMasker(sampler image, sampler background_image,
sampler mask_image, __color key_color)
{
vec4 pixel_camera = sample(image, samplerCoord(image));
vec4 pixel_mask = sample(mask_image, samplerCoord(mask_image));
vec4 pixel_background = sample(background_image,
samplerCoord(background_image));
vec4 pixel_to_return = (pixel_mask.r > pixel_camera.r)
? pixel_background : pixel_camera;
pixel_to_return = (pixel_mask.r-pixel_camera.g > 0.4)
? pixel_background : pixel_camera;
pixel_to_return = (pixel_mask.r-pixel_camera.b > 0.4)
? pixel_background : pixel_camera;
return pixel_to_return;
}
I have no idea if i'm on the right track or not, so any kind of help
or pointer in the right direction would be much appreciated.
I have a bunch of red things here which i try the filter against,
that's why i check the red component. Right now it replaces some areas
with the background image, but not the red ones.
Thanks
19 jan 2009 kl. 10.02 skrev Jonathan Selander:
Thanks for a great reply!
The setup uses an imac with its built-in camera, and the green
screen is completely light green and very higly lit to prevent any
shadow. I guess the motion detection method doesn't really work with
this type of camera, so i'm looking at the method that simply masks
out the background somehow. Today i've tried making it work with
javascript/core image filter patches, but i'm still a bit new at
that. You wouldn't happen to have an old patch lying around that
uses either of these techniques? :-)
Jonathan
16 jan 2009 kl. 14.03 skrev Chris Wood:
Jonathan,
There's 2 ways I've used to do it. The first is to use a filter to
remove the background (you would need to have the camera pointing
at a plain coloured background though) and in the filter just
compare to see if the green component is much higher than the other
components, and filter on that. Noise is still an issue, but it can
at least be reduced a bit.
The other way is to do motion detection, and remove anything not
moving. To do that I just used a queue with a length of 2, so I
could feed the current and last frames into a filter. It's fairly
easy to mask out the background, but there are some quite nasty
catches.
Video noise is a huge problem, as it means the whole image is
always moving slightly. You really need a good camera to get rid of
it, otherwise you have to do a lot of noise reduction that can make
the image look blurry.
Another big problem is auto-white balance on the camera, or
anything like that.. if the camera suddenly adjusts anything, the
whole image changes so the background suddenly pops into view for a
short time. Again, a good camera with manual controls would help.
The last problem is that sometimes the thing you want to show stops
moving. Say you're filming somebody talking.. their mouth is
moving, but their eyes might stay still for a short time. They
disappear.. and even if they are moving constantly, sometimes there
will be an area with similar colour that doesn't get detected, and
you have a hole..
I guess the way ichat works is to sample the background just once,
when there is nothing in front of it, and use that for comparison.
Then even if you're still, there is still a difference. You still
have the problem of white balance changes, video noise etc., though
so you'll need a fair bit of cleaning done on the image.
Chris
2009/1/16 Jonathan Selander <[email protected]>
Hi,
I've used a couple of patches from the QCTV example application to
create a green screen effect in my composition. However, i just
compared it to Photo Booth which does it much more accurately.
What's the best way to accomplish this? Is there any patch out
there i can use that works well?
The QCTV patch seems to be very susceptible to video noise, so lots
of pixels appear everywhere, so the backdrop isn't solid.
Thanks
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected]
)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/psonice%40gmail.com
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected]
)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/jonathan%40trodon.se
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to [email protected]