Have you ever seen Saurav Ganguly batting right handed or Sachin Tendulkar batting left handed.
Well just watch this:-
You might be wondering when did sachin play such innings.
Its all mirrored.
The big question remains how to do this.
Ans.
1)Using Matlab
2)Using Java
3)Many other software's are available like photoshop
But i'll rather prefer Matlab because it is taught in my home subject(ECE)
First let me tell you what all you can do with it:-
1)Mirror a Video(or image) either horizontally or vertically or both ways.
2)Face warping(you might have seen funny mirrors).
3)Creating edges leaving behind the background.
4)Creating black and white image from coloured ones and vice versa.
and much more.
Starting with mirroring of a video(actually it is mirroring of each frame so if it canb aslo be done for an image ).
First thing i expect from you is to have a basic knowledge of matlab + you have matlab installed on your PC
(rest dont worry i'll be posting for java soon).
For reading files of every format you need to download a reader package (because matlab provides default reader of avi videos only) .
Download it from here:-
http://www.mathworks.com/matlabcentral/fileexchange/8028-mmread?controller=file_infos&download=true
Extract it to a folder.
Now create a M-file inside the same folder(change directory if need be).
Copy the video in same folder.
Copy video name along with its extension(ex:-video.avi)
note:-prefer avi video
Now write the following code:-
%For Horizontal mirror
%change video.avi with name of video
s=mmread('video.avi');
fo=avifile('Vid.avi','fps',25);
for x1=1:50
%put no of frames in place of 50
y1=s.frames(x1).cdata;
fr_size = size(y1);
width = fr_size(2);
height = fr_size(1);
for i1=1:height
for j1=1:width
xx=i1;
yy=width-j1+1;
z1(i1,j1,1)=y1(xx,yy,1);
z1(i1,j1,2)=y1(xx,yy,2);
z1(i1,j1,3)=y1(xx,yy,3);
end;
end;
sfo=addframe(sfo,z1);
end;
sfo=close(sfo);
---------------------------------------------
%For Vertical mirror
%change video.avi with name of video
s=mmread('video.avi');
fo=avifile('Vid.avi','fps',25);
for x1=1:50
%put no of frames in place of 50
y1=s.frames(x1).cdata;
fr_size = size(y1);
width = fr_size(2);
height = fr_size(1);
for i1=1:height
for j1=1:width
xx=height-i1+1;
yy=j1;
z1(i1,j1,1)=y1(xx,yy,1);
z1(i1,j1,2)=y1(xx,yy,2);
z1(i1,j1,3)=y1(xx,yy,3);
end;
end;
sfo=addframe(sfo,z1);
end;
sfo=close(sfo);
Showing posts with label Project Related. Show all posts
Showing posts with label Project Related. Show all posts
Monday, April 12, 2010
Thursday, March 4, 2010
Circular menu (using CSS)
Posted by
vaibhav
0
comments
The menu such as above can be created using HTML and CSS.
To see it working just click on menu example link present on right top corner of your screen.
All you need to do is download the following files and make the appropriate changes according to your use.
HTML page:-
CSS page:-
Now you can make the following changes according to your need:-
- In menu.css under heading anchor styles ,you will find 8 such declaration as shown:-
Now change the url to appropriate image URL you want to give for corresponding label for all 8 labels.
Also you can change the name of label in all of their occurances in whole file.
- Next open the HTML file.
Here find the definition for 8 labels such as one shown here:-
Here replace # with the URL you want the label to redirect.
Also replace strong tag and span tag content to appropriate value.
Also change the ID according to the value you changed in CSS
Finally you can add or remove the overhead text by head tags.
Warning:- I have experienced that some .GIF images are not supported so try using jpeg.
Thursday, February 25, 2010
Reading data from serial port in JAVA (using javax.comm package)
Posted by
vaibhav
0
comments
For accessing serial port (COM1 OR COM2 ) through JAVA you need to install java communication API using which you can access javax.comm package .
Download the API package from here:-
The following files are the core of JAVA Communiccation API, and they are very important to have them installed on your system for a proper operation:
* comm.jar
* win32com.dll
* javax.comm.properties
For the jdk (Java Developnment Kit) to recognize the serial ports on your machine, it is important to properly place these files in the right folders on your local machine :
* comm.jar
* win32com.dll
* javax.comm.properties
For the jdk (Java Developnment Kit) to recognize the serial ports on your machine, it is important to properly place these files in the right folders on your local machine :
comm.jar should be placed in:
jdk directory/lib
jdk directory/jre/lib/ext
win32com.dll should be placed in:
jdk directory/bin
jdk directory/jre/bin
Windows/System32(Inside drive in which windows is installed)
javax.comm.properties should be placed in:
jdk directory/lib
jdk directory/jre/lib
jdk directory/lib
jdk directory/jre/lib/ext
win32com.dll should be placed in:
jdk directory/bin
jdk directory/jre/bin
Windows/System32(Inside drive in which windows is installed)
javax.comm.properties should be placed in:
jdk directory/lib
jdk directory/jre/lib
Now you can use the following code:-
Note that the above code is set for COM2
Please change it to COM1 if your computer supports that by simply replacing COM2 by COM1 in the code.(its COM2 in my case).
Also the above code reads data to console.
You can get it on any JAVA application just by accessing the read buffer present in serialEvent function.
Still any confusion contact me at vaibhav9899@gmail.com
Sunday, February 21, 2010
HYPERTERMINAL :- Connecting a microcontroller ,moblie,computer or any other device with serial port.
Posted by
vaibhav
0
comments
Why use HYPERTERMINAL:-
When you want to transfer date to and recieve data from microcontroller through serial ports.
When you want to connect two PC's and transmit data between them.
When you want to send AT Commands to a Mobile Phone or GSM/GPRS Modem.
*Note:- for details on sending AT commands visit Nokia forum for better visualization.
RS232
RS 232 is a standard in serial communication. An 8 bit word is transmitting one after other.
The first bit sent is LSB. Some other bits are attached to the useful bits.
These bits are: START BIT, STOP BIT and some parity bits.
The START BIT is the first bit sent. Then the useful package of bits are following (LSB first).
The last bit sent is STOP BIT. In RS 232 standard an "1" is transmitted as -3 to -25 volts and "0" as +3 to +25 volts.
Some other standard for serial communication are RS 422, RS 423, RS 485.
How to connect:-
1. Connect the device to appropriate serial port.
2. Run MS HyperTerminal by selecting Start >>Programs >>Accessories>>Communications>> HyperTerminal.
3. In the Connection Description dialog box, enter a name and choose an icon you like for the connection. Then click the OK button.
4. In the Connect To dialog box, choose the COM port that you are using(either COM1 or COM2)
5. Another window will open and hyperterminal ask you to choose the baud rate.
6. Choose 9600 baud.
7. In the "Flow control" filed choose "None" and hit OK. for BOTH PCs(single PC in case microcontroller is used).
8. Then, you can start typing and you will see the characters on the second PC (or sent to microcontroller).
9. Same way whatever the microcontroller or second PC send it appears on the window.
10. To see the characters you type on your display too, you have to make two more settings. From "File" menu, choose the "Properties" submenu.
11. Choose "Settings" .Press the "ASCII setup" button and another window will open.
12. Click on the "Send line ends with line feeds" to check it and on the "Echo typed characters locally".
13. Hit now OK and close the window. Now, you can start typing characters and send them to the other PC.
NOTE: In HYPERTERMINAL tha data you are typing (sending serially) is not displayed on the screen. Whereas the data that is received is displayed on the Hyperterminal Screen.
Thursday, January 21, 2010
A simple generator
Posted by
vaibhav
0
comments
Learn how to create a generator in a super simplified manner.
Subscribe to:
Posts (Atom)







