29th January 2007, 01:09 am
How to use a Logitech WebCam in Java
With a bit of effort I was able to get Java Media Framework running. There were two key problems I ran into
1) The web-cam I was using wasn’t working. If you run the JMF app that comes with the API from Sun and your web-cam isn’t detected, make sure your camera actually works. The other issue may be that your camera was not detected because it was plugged in after you ran the tool the first time. You can run
java VFWAuto
from the command line (provided that the JMF classpaths are set properly) which will force Java to redetect all cameras connected to your system. Java doesn’t care what USB web-cam you use as long as it’s installed and working properly.
2) Eclipse was not seeing the classes. I had to add the JARs for the JMF just like I had to add the java runtime environment.
Once you have all that sorted out you’re ready to start using Test.java to get started playing with your web-cam. One other thing is that my video capture card was not detected. There may be a way to make use of your capture card but I havn’t figured that one out yet. The code that’s given at the above site and JMF appears to only detect USB web-cams.
So far I’ve been able to draw the frames real time in black and white, with a limited color set, and have created a simple algorithm for motion detection. Back when I was doing this with C++ I couldn’t get access to the raw frame data. This meant that anything that was displayed over the screen was considered part of the screen. With this you don’t have to render the actual video buffer. You can easily just render your modified frame.
If you have gone through the Real Time Software rendering tutorials for Java you will find a number of concepts that will come in very handy for real time video processing. The person who wrote the original code used an infinite loop (while(true)) with a thread which is not the proper Java way to do things. Doing it the right way (as seen in the RTSR tutorials) nets a very good performance boost. I’m able to render 320×240 with a reasonable frame rate using a cheap web-cam. I can get as high as 640×480.
Also, every time I exit the program it dumps an error log. I havn’t looked into how to fix that yet. I’ll probably do some official tutorials on real time video processing to show off some effects you can do but I’m not sure the time frame. There are a number of other projects I’m currently working on.
28th January 2007, 01:28 am
Cubia
Cubia is a lightweight wikipedia mirror. Lightweight meaning that ever a server running at less than 1Ghz could easily handle it. It’s called “Cubia” because the main page is just a hexadecimal cube with 256 links. Each of those links will take you to a listing of all the articles in the selected section limited to 200 articles per page.
The process of loading Cubia involves first uploading 6.6GB of entries split between nearly 600 files. Each of those files then has to be read in and the data injected into the database. The entire process can take several days. But, once it’s done Google (and every other search engine) will have no trouble indexing the millions of pages that Wikipedia has. Visitors will then come from search engines and land directly on the page they’re looking for. Because it’s lightweight, even a slow server will give them what they want quickly.
Because the entire page is encoded in the database it’s quick and easy to pull it out and display the wiki page to the user. The side effect is that it’s impossible to have a search engine on the site that does full text. The only searchable part in the database is the title. But, that doesn’t really matter because again, people will be using Google, Yahoo, etc which are indexing what the user sees. We’ll see how well this little experiment does over the next month or so.
26th January 2007, 03:40 am
Wikipedia is a beast. My mirror of the english edition is quite old and contains 2.7 million pages with nearly 4 million revisions. The database file is over 7GB. My little server manages to handle it but not very well at all. Mostly because MediaWiki is a convoluted mess of wiki software. So, in order to make it more efficient I’m currently dumping all the current pages (no revision data) into 16 files with the md5 of the page title and then the contents of the table entry serialized and base64 encoded. Once this process is done another script will read those 16 files and push the data into a database with 256 tables. When a user requests a page, the title will be set to lower case and md5′d. The first two characters tell the script which table the page is in, it grabs it, decodes it and we’re done.
DMOZ is set up the same way although there are no lonely directories in DMOZ. Wikipedia has a slight challenge in that you’re not guarenteed to be able to find your way to any given article from any starting point. So, there is going to be a huge index and you’ll finally be able to see just what wikipedia had at the time of the datadump.
The net result is a wikipedia clone that will be able to be run on even low end servers. I’ll also be much easier to transfer from one server to another. Unfortunatly this process is going to take at least a couple days but when it’s done it’ll be worth it. There’s nothing more annoying than waiting half a minute for a page to load. Except knowing that there’s a simple way to improve the performance.
23rd January 2007, 11:33 pm
IcarusIndie.com was always indended to be a business. However back when it started I wasn’t interested in blowing a lot of money on domain names and I was very interested in putting up a lot of junk on the internet. So, 7 years later, IcarusIndie.com is finally turning into a real business site. Dawn of the Geeks.com is the new home for all the random stuff. Mostly it will be programming related resources just like icarusindie.com was.
When I started Icarus Independent I was doing mostly game and application programming. As the years progressed I’ve now moved into web development. Dawn of the Geeks will be the hobby site since I still enjoy making games and IcarusIndie.com will be my business site for doing freelance web-development.
23rd January 2007, 02:57 am
Original Story
Basically a customer decided to go with ProfitHost.net and after 6 weeks he finally got access to a server but it wasn’t what he had paid for. He wanted a refund. Now ProfitHost.net is throwing around accusations and doesn’t want to pay up. They claim that the customer was hosting (or intended to host) illegal things. So that gives them the right to take the money and not supply the service the money was intended to pay for?
What a bunch of jerks. If they knew that they had no intention of supplying the service or that they couldn’t supply the service then they should not have taken the money to begin with. Apparently this hosting company took 5 days to figure out that they couldn’t install the amount of memory the customer needed. That demonstrates poor technical skills on their part. They should have known immediately and straighted out the order before accepting the money.
As it is, they admit to failing to provide the service and are consulting a lawyer to decide whether or not to give the money back.
I don’t need a lawyer to figure out that I’ll never do business with this company. If you don’t provide the service you can’t keep the money. End of story.
22nd January 2007, 10:38 pm
Digg It!
Lesson 10 is complete. Bunnies now supports lights with shadows. Any number of lights can be defined. You can specify whether they are colored or not and whether they cast shadows or not. Casting shadows is currently very expensive so a fast processor is required. Global lights are very fast whether colored or not.
Check it out!
19th January 2007, 09:55 pm
Real time software rendering in Java is nearly completed. I’m currently tweaking the lighting calculations to make sure they’re correct. It is possible to have the lights cause walls to cast shadows but it kills the framerate. Global illumination (walls ignored) barely causes a hit to the framerate. The lighting class allows for both since not everyone is using an old system and it will allow for more advanced lighting when the code is more optimized, Java becomes faster, and/or the code is run on a faster system.
Currently there is a restriction so only 256 light sources can be defined per level. That’s completely arbitrary and will probably be removed before the tutorial is posted. The reason for the restriction is that a simple array is being used rather than a linked list.
I’m also planning on allowing lights to move in a circle of a defined radius. That will allow the level to look a little more alive. Historically lights have been precalculated because systems were too slow. If you don’t move the lights around and run time they might as well be.
19th January 2007, 09:46 pm
Yet another DMOZ
Believe it or not DMOZ can run very efficiently even on an old 700Mhz system. The trick is encoding the directory name as an MD5 and storing all the contents for that directory in a serialized array. When you visit the site it just sets the dir to all lower case, MD5’s it and pulls the row from the database. As an added trick the first 2 characters of the MD5 define which table to look in.
The data is deserialized into an associative array and rendered. Simple, fast.
12th January 2007, 09:28 am
Lesson 9: The Finished Game
Lesson 9 is a huge step forward. The game is now a true applet that runs in any Java enabled browser. It’s also a real game now that can be won or lost. Lesson 10 will take a step into the lighting department. We’ll see how that works out. Java is not the fastest of languages so I’m not sure how advanced I’ll be able to get with the lighting techniques but I’m going to give it a try.
Lesson 10 isn’t the end though. I have some additional plans outside of the whole Software Rendering tutorials. Check it out!
12th January 2007, 04:23 am
http://www.spiegel.de/international/0,1518,458863,00.html
An east German pensioner who breeds rabbits the size of dogs has been asked by North Korea to help set up a big bunny farm to alleviate food shortages in the communist country. Now journalists and rabbit gourmets from around the world are thumping at his door.
It all started when Karl Szmolinsky won a prize for breeding Germany’s largest rabbit, a friendly-looking 10.5 kilogram “German Gray Giant” called Robert, in February 2006.
Images of the chubby monster went around the world and reached the reclusive communist state of North Korea, a country of 23 million which according to the United Nations Food Programme suffers widespread food shortages and where many people “struggle to feed themselves on a diet critically deficient in protein, fats and micronutrients.”