Image processing Effects---lightsaber effects

Source: Internet
Author: User

A few days ago wrote a can play lightsaber program, personally think very cool

This app you can play on your own computer, there is Star Wars in the Jedi feeling

In the program, there is no need to use OPENCV, but try to combine OpenCV and MFC dialog, so the final implementation is as follows:

OPENCV capture Image, MFC double buffered display, GDI + display lightsaber pictures

The combination of OpenCV and MFC cost a little effort to think of methods.

and found that in XP (at least on my computer), the memory mode is the Bgra order, do not know whether the experts agree. At first I thought it was RGB but it was very strange to show the results.

The Iplimage data (BGR) is displayed correctly when it is displayed again by Bgra (a=0)

As for image processing, it is simple to find a target after a simple threshold and then display the image

In order to make the lightsaber more beautiful, learn a little Photoshop, the effect is passable, if you can ps out better pictures, you can replace the program in the picture, the file name will be the same

In someone else's video, a little lightsaber-waving sound.

Video Demo: http://v.youku.com/v_show/id_XMjM1NDM0OTEy.html,

Video equipment is too poor, sound effect is not good, so turned off the sound. You hear sounds when you run the program, you feel it.

Code Download: http://download.csdn.net/source/2969385

How to play with the introduction:

1: Find a bright color stick (two props I used in the demo: A stick around a red plastic bag, the handle of a garbage shovel), the requirements are not high, as long as there is a major hue, such as blue, red. In the figure 1 is a stick that is wrapped around a red plastic bag.

2: Adjust the threshold value. If you're not familiar with RGB, this step doesn't seem easy. Click on the stick you use (Figure 1), in the Figure 2 has RGB display, a few more points, to see the approximate range. Then adjust the 4 RGB thresholds in the diagram. If the corresponding multi-box is selected, it means that the component of your stick is less than the threshold value, otherwise it is greater than. In the illustration, I use the red keynote, so R is not selected, G, B is selected. Adjust to achieve the effect is to make the figure 3 clearly show your stick position, not the area of the stick to minimize

3: In Figure 5, choose the color you like. I did six simple effects and you can make a more beautiful replacement by yourself

4: Figure 6 can be turned off the lightsaber display

5: Figure 7 is for the convenience of debugging, you can display the program to find the line of sticks

It doesn't have to be a stick, I use a line that fits the largest target area.

My webcam is 640*480, if you are 320*240 or something else, the display window may not be the same, but both can play

Here are a few:

Garbage Shovel

Play with your hands

Several effects of lightsaber:

Welcome friends to give some advice!

==============================================================================

Update

Thank wo_men123456 for his comments in the comments:

wo_men123456: Hough Straight line detection, in the use of DX painting

Today I used a straight line to do a bit of testing, just do when using canny edge detection, the effect came to realize that the stick has two sides, and this program needs not only a straight line, but also should be the midline. So after the use of refined processing +hough detection, the effect is good.

But want to think straight line detection and I used the straight line fitting in the application of this program is still a difference:

Because of the changing illumination, the thresholding image will be different between the adjacent frames, and the difference is mainly in the target edge part.
So the refinement of the line mainly at both ends of the large change (the structure of the image at the end of the effect of thinning results is relatively large), so that this line can not be very good to represent the stick. and Hough straight line detection, because only the detection of this line, the linear slope of the change is relatively fast, in the lightsaber program is not very suitable.
The linear fitting method is more stable in the experiment because of the use of all the points of the stick, that is, the slope changes smoothly.
The inadequacy of my original approach: to require that the target area be connected.
When the target has a small distance interrupt, the detected line segment suddenly becomes shorter, while the Hough line detection can avoid this problem better. The workaround is to widen the distance of the pixel connections when detecting connected domains. But then comes the decline in efficiency to a certain extent.

Hough line detection code download: http://download.csdn.net/source/2977153

Single-Frame effect comparison:

1, refined +hough line detection

2, Canny edge +hough line

3, my original method: Straight line Fitting

http://blog.csdn.net/onezeros/article/details/6124073

http://blog.csdn.net/cinmyheart/article/details/41075869

Image processing Effects---lightsaber effects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.