Image Uploader for FB
By Tony Wong

Abstract
Create an application to facilitate the uploading of images to Facebook. Faces are automatically detected so users do not have to select them manually. Images are appropriately resized for the Facebook standard to help reduce bandwidth usage.
Introduction
The purpose of this project is to tie together some of the concepts that have been encountered during the course of the Multimedia class to create an application that can help increase productivity and efficiency. The focus of this project was to work with the Facebook API and create an application where users can efficiently upload a picture; this goal is achieved through the following:
· Face detection – to allow easy tagging by automatically detecting the faces for the user, and
· Photo Resizing – to help reduce the network load by decreasing image sizes to a Facebook standard.
Methods
The project was started in Java and the original intention was to complete the entire project in Java with the use of image manipulation functions along with the Facebook API. On building the basic GUI for the application, further thought was put into how the image processing was to be done and the project took a turn towards the use of C++. The integration of C++ was for several reasons. The primary reason was to allow the use of the OpenCV library, which is an open source Computer Vision library developed by Intel with a focus for real-time image processing. As such, OpenCV offers many functions that are geared towards multimedia projects for motion tracking, object recognition, and such. In summary, the project was coded in two separate parts:
· Java, the front-end for the user to interact with the various functions of the program, and
· C++, the back-end of the application which performs the image processing and face detection using the OpenCV library.
The facial detection is performed through C++ using the method ascribed in the basic detection sample provided by the OpenCV library. The detection method is based on the detection of what is known as Haar like features. Haar like features specify specific features of an object and their special relationship to each other. The detector used in this case is trained with samples of faces, provided through an xml file. After the detector is trained, it takes the image of interest, and moves a window across the image of interest and tries to see if it appears to be a face based on its training. Note that the detector used in this project focuses on detecting images that have faces looking forward at the camera. Faces that deviate from this, such as a face looking to the right or left, reduces the chances of detection. The following line performs the Haar face detection after it is properly setup:
CvSeq*
faces = cvHaarDetectObjects( small_img, cascade, storage,
1.1, 2, 0/*CV_HAAR_DO_CANNY_PRUNING*/,
cvSize(30,
30) );
The image detection is performed several times with the image rotated at several different angles to help increase the chance of detecting images of people with their head tilted, which is commonly found in most pictures with groups of people. This required a slight modification to the general face detection algorithm, which took into account the angle of the picture. Some trigonometry was used to detect the original location of the face before rotation, and checks were performed to ensure that duplicate faces were not kept. After the image processing was complete, a new image is generated and control is released to the Java front-end.
Java communicates with Facebook through the API provided by Facebook. Authentication is performed to ensure that the user is indeed valid. After authentication, the image is uploaded to Facebook, where it is put into a pending stage by Facebook, awaiting the user to login to the website and authorize the image. Face location data from C++ is used to generate tagging data for Facebook, and also sent through the Facebook API.
Results
The facial detection algorithm currently used performs well on faces that are correctly oriented. Faces are easily detected when they are facing forward, at the camera. The algorithm also performs image rotation to look at faces that may be tilted slightly to the left or right, thus improving facial recognition. Note that this generally reduces false negatives, however, causes an increase in false positives because when the image is looked at rotated at various angles; objects are more likely to fall into a form that looks like a face. The false positive rate is greatly reduced on images that have people with minimal surrounding objects. The more objects, the more likely those non-face objects are picked up as faces.
The use of compression definitely results in an improvement in terms of uploading the images to Facebook. An average 5 mega pixel image in JPEG format is generally around 2.5-3.5 megabytes. Compare this image to the ones that are constrained to the maximum Facebook image size, 604x604, which are about 100-150 kilobytes. This means the image can be uploaded in 2.9-6% of the original time, which is a significant increase. The benefit is greatly increased when multiple images are uploaded.