views:

629

answers:

1

Hello,

I am trying to make a C# desktop application (with Emgu CV wrapper) which captures the feed from the camera, detects edges in the feed and then displays the original feed (coloured) with the edges - so somewhat of a combined coloured feed and edges. I successfully get the feed from the camera. I also detect the edges in the feed by using the Canny method. The problem is that while the original feed is in colour, the detection of edges is done in grayscale (black background, white edges). I would like to know how to "merge" the colour feed with the edge feed to output a merged feed.

I've tried with the Copy method in Emgu CV but it outputs a black background and correctly coloured edges (so for instance if I hold a red cube in front of the camera, the edges around the cube are coloured red).

Any help is very appreciated.

+1  A: 

OK, after a little bit of tinkering around I found the solution. The trick is to use the And function on an inverted Canny result and the colour feed. Here's my function that works with Application.Idle:

    private void processFunction(object sender, EventArgs e) {
        Image<Bgr, Byte> frame = c0.QueryFrame();
        Image<Gray, Byte> grayscale = frame.Convert<Gray, Byte>();
        grayscale = grayscale.Canny(new Gray(0), new Gray(255)).Not(); //invert with Not()
        frame = frame.And(grayscale.Convert<Bgr, Byte>(), grayscale); //And function in action
        imageBox1.Image = frame;

    }
brozo