( int)boundsF.Width, ( int)boundsF.Height) Rectangle bounds = new Rectangle(( int)boundsF.X, ( int)boundsF.Y, RectangleF boundsF = bitmap.GetBounds( ref unit) Return new Point(( int)bounds.Width, ( int)bounds.Height) RectangleF bounds = bitmap.GetBounds( ref unit) This.bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb) Public UnsafeBitmap( int width, int height) Once the light source is defined, the program can go through the pixels near the defined light source and calculate the average brightness of each pixel. So, I made an assumption that the camera source will be stationery, and the user will have to define the light source by a mouse click within the webcam window (see the image below: the point of interception of the two yellow lines is the marker which defines the light source). The program watches the on/off sequence of the LED and converts it into English!Įarlier, I was thinking of processing the whole webcam frame and finding the on/ off state of the LED, but this technique made the application work too slow that it couldn't even differentiate between a dot and a dash. To add more fun, I added another feature of decoding this Morse code. PortInterop.Output( 888, 0) // set all data pins to 0 PortInterop.Output( 888, 255) // set all data pins to 1 Int sleep = Convert.ToInt16(some vaue) // pause between dot and dash if (ch = '. Int mul_fac = Convert.ToInt16(comboBox1.Text) Private void stringToLed( string str) // generated morse code is argument It also has an option for putting out the audio depicting Morse code.įirst of all, a written text is converted to Morse code by a string extension, and finally, the generated Morse code is used to control the LED and audio part. All I have to do is enter a phrase in English and press the button. Generating the Morse code (by flashing an LED)Īs, you can see in the picture above, the program can control an LED connected to the parallel port of my computer and make it flash Morse code. Watch this YouTube video and check out this program in action. One really cool thing with this program would be using two computers, one having a parallel port (LED attached) and the other with a USB webcam. and ended up writing this program!īefore we begin, I would recommend you to go through I/O Ports Uncensored - 1 - Controlling LEDs (Light Emitting Diodes) with Parallel Port by Levent Saltuklaroglu, and be sure to read the sections on Parallel Ports and Hexadecimal / Decimal / Binary if you haven't already done so, as we will use the same procedure to reach the parallel port in our application. Ever since I made the webcam enabled Tic-Tac-Toe, I was thinking of some unique ways to communicate with my computer using something real and physical. Perhaps you are asking, "What's the use?" Well, no practical use. Not to forget the most interesting part: the program can use the webcam and a little bit of image processing to make the computer understand the Morse code flashing LED and convert it back to English. ![]() For dots, the LED remains "on" for lesser time than dashes, thus giving an impression of Morse code. Well, in this article, I'm demonstrating a program that can control an LED connected to the parallel port of my computer and make it flash Morse code. I hope you all know what Morse code is for those who are not aware of it, Morse code is a standardized sequence of dots and dashes to represent any character and number.
0 Comments
Leave a Reply. |