
Face detection in pure PHP (without OpenCV) / Blog de Maurice Svay Une résumé en français est disponible en fin d’article. Lately, I’ve been looking for ways to detect faces in photos with PHP. Nowadays, face detection is built in many consumer products (camera obviously, but also Google and iPhoto), and seems to be a pretty common job. So I expected to find many solutions for doing it with PHP. Surprisingly, the only one I could find is OpenCV, an opensource lib that was originally developed by Intel. Learning about face detection So I started to think about implementing it myself. Always look at what others are doing Then I looked for existing implementations in other languages. The code Update: the code has moved to Once the code converted to PHP, here’s the result: And you simply use the class this way: $detector = new Face_Detector('detection.dat'); $detector->face_detect('maurice_svay_150.jpg'); $detector->toJpeg(); Which gives the following result: Résumé en français
Namespaces With PHP PHP namespaces was introduced in version 5.3. Namespaces is a way of group classes together into virtual directories, the main reason we would want to do this is to help avoid collision of class names in your application. In PHP you can not define two classes with the same name, if you do this PHP will display a fatal error in your application. Using namespaces means that you can define two classes with the same name as long as they are in different namespaces. For example if you had two classes both named Table and both classes perform different tasks, one will be used to read a database table and the other will be used to display a HTML table. The database table class would now be called Database_Class and the HTML class will now be called Html_Class. Defining Namespaces All your code can be contented by a namespace but only four types of code can be affected by namespaces, classes, interfaces, functions and constants. Defining Sub Namespaces Defining Multiple Namespaces Using Namespaces
Facebook : bientôt une reconnaissance faciale automatique ? Le réseau social a annoncé sa volonté de collecter les photos de profil de ses membres pour sa base de données biométriques. Une technique qui suscite de nombreuses interrogations... L'annonce a été glissée mine de rien. Depuis quelques jours, Facebook a changé ses conditions d'exploitation des photos de profil de ses utilisateurs. Le réseau social a en effet mis au point une base de données biométriques permettant de "ficher" ses utilisateurs grâce aux photographies où chacun est identifié. Facebook avait aussi lancé cet outil de reconnaissance facial en Europe en 2011 mais la CNIL (Commission nationale de l'informatique et des libertés) avait tout de suite émis des réserves qui avaient poussé le géant à retirer ce processus. Malgré une transparence qui se veut totale du côté du réseau social, la question est bien plus sensible qu'il n'y parait.
Practical PHP Programming Lambda Labs Face Recognition API βeta Formatted Strings With PHP When you are using PHP to output a string on the page most of the time you will use the syntax echo, which will take the following string and display that string in HTML. You can even concaternate multiple strings or variables together to be outputted by the echo syntax. Here is an example of using echo to output multiple options in a select box. As you can see from the echo syntax that you can create a HTML element by using PHP. This code uses a concatenated string to insert the variables into the value attribute and a title inside the option tag. This will create 5 image tags which will populate the a number of different attributes. This time if you look at the echo syntax to output the image tags it's not very readable and can be hard to work out what we are joining together to create the image tag, especially with the different single and double quotes it becomes really hard to read. This is how it will be used to display the image tag. Printf() Function Displaying Image Tag
PHP & MySQL For Dummies Cheat Sheet Cheat Sheet When writing PHP programs to create your Web database application and communicate with a MySQL database, you have many things to remember. You must spell code correctly and use perfect syntax. This Cheat Sheet provides a reference for quickly looking up the correct syntax for the code you use most frequently. Use PHP Statements to Create Programs PHP programs are a series of PHP statements, executed one at a time. Communicate with a Database through PHP MySQL Functions PHP communicates with MySQL databases by using a set of functions developed specifically for this purpose. mysqli_connect("host","accnt","passwd")mysqli_select_db($cxn, "dbname",)mysqli_query($cxn,"query")mysqli_fetch_assoc($result)mysqli_num_rows($result)mysqli_insert_id($cxn) Make MySQL Database Changes with the ALTER Query The ALTER query is used to change the structure of a MySQL database. Access and Adapt a Database with MySQL Queries PHP communicates with MySQL databases by sending SQL queries.
PHP MySQL Web Development Security Tips We are closing down our forums, it’s time to move on, but we are keeping some important threads, here is one… I read about many of these points in books and tutorials but I was rather lazy to think about many of them initially learned some of these lessons the hard way. Fortunately I didn’t lose any major data over security issues with PHP MySQL, but my suggestion to everyone who is new to PHP is to read these tips and apply them *before* you end up with a big mess. If you are expecting an integer call intval() (or use cast) or if you don’t expect a username to have a dash (-) in it, check it with strstr() and prompt the user that this username is not valid. Here is an example: $post_id = intval ( $_GET [ 'post_id' ] ) ; mysql_query ( "SELECT * FROM post WHERE id = $post_id " ) ; Now $post_id will be an integer for sure JavaScript validation is only good to reduce the server load. Use mysql_real_escape_string() to escape the user input. Then you can use it like this: deny from all Thanks!
PHP: The Right Way How to Handle Bookmarks and Back Buttons Published on ONJava.com ( See this if you're having trouble printing code examples by Brad Neuberg 10/26/2005 This article presents an open source JavaScript library that finally brings bookmarking and back button support to AJAX applications. By the end of this tutorial, developers will have a solution to an AJAX problem that not even Google Maps or Gmail possesses: robust, usable bookmarking and back and forward behavior that works exactly like the rest of the Web. "AJAX: How to Handle Bookmarks and Back Buttons" explains the significant issues that AJAX applications currently face with bookmarks and the back button; presents the Really Simple History library, an open source framework that solves these problems; and provides several working examples. The principal discoveries of the framework presented in this article are twofold. The Problem Bookmarks and the back button work great for traditional, multi-page web applications. The Solution Example Conclusion
HTML5 Drag and Drop Avatar Changer with Resizing and Cropping Posted at CSS Tricks by Chris Coyier In any app that has user avatars, users should be able to change those avatars. Anything to make that easier is desirable. The Workhorse of Drag and Drop Perhaps the most important bit we'll deal with is the drop event. Interestingly enough, as written, the above won't work. And of course remove that UI change if the user doesn't perform the drop: Handling the Dropped File Drag and drop can do multiple files. Perhaps if you were really nice, you'd loop over all the files and find the first image rather than rejecting based on the first file. Resizing the Avatar There are server side ways to resize images, but that requires a round trip (slow) and the transfer of potentially enormous files (slow). You can do this by creating a <canvas>, drawing the image to the canvas, then exporting the canvas as a Data URI. Squaring Avatars In our example, all our avatars are squares. Crop / Resize In Action Uploading and Saving Avatar Relevant CSS Bits Not Quite Done
How to Capture CSS3 Animation Events in JavaScript Posted at Sitepoint by Craig Buckler CSS3 animations are smooth and quick to implement but, unlike JavaScript, you don’t have frame-by-frame control. Fortunately, you can apply event handlers to any element to determine the animation state. This permits fine-grained control such as playing different animations in sequence. When the enable class is applied to the element with ID anim, the animation named flash is run three times. Three types of event are fired when the animation occurs: animationstart The animationstart event is fired when the animation starts for the first time. animationiteration The animationiteration event is fired at the start of every new animation iteration, i.e. every iteration except the first. animationend The animationend event is fired when the animation ends. Browser Compatibility At the time of writing, Firefox, Chrome, Safari, Opera and IE10 support CSS3 animation and the associated event handlers. The event object The demonstration page displays a button.
Javascript Full Screen API Posted at Paulund The full screen API is an easy way to get the full web content to be displayed on the page. It's very similar to pressing F11 on your keyboard but this can be done at the developers choice. This is a great feature to use for things on slideshows, you can make the browser go into full screen on a click of an image. The best thing about this feature is that it doesn't have to be the entire page, you can make any HTML element go full screen. This mean instead of always making the entire page go full screen, just assign the full screen API to an image and on the click of the image you can just focus on the image in full screen. Full Screen API support Unfortunately not all browsers support this feature so you need to make sure that your visitors browser supports this feature before you try to use it. According to the website Can I Use the full screen API is currently supported on Firefox, Chrome/Safari and Opera. Check if the browser supports Full Screen API Exit the full screen
IE CSS Bugs IE 6 actually had the best CSS support of any browser when it first came out... SEVEN YEARS AGO. The little bugs in it's CSS support still haunt us to this day. I still get comments from people who roundly reject any technique that doesn't work in IE 6. The Box Model This is perhaps the most common and frustrating bug of all in IE 6 and below. IE 6 will calculate the width of the box to be 100px. This kind of discrepancy can cause HUGE layout problems. I generally work around this issue by just not using padding on boxes I am using for layout. The Double Margin Bug Using our box example from above, let's say we need that floated to the right: IE 6 will double the 20px to 40px. I also like to side-step this bug whenever possible. No Min Widths / Min Height Setting min-width and min-height on elements is such a natural and logical thing that it makes me tear up sometimes thinking I can't count on them. Stepdown No Hover States No Alpha Transparent PNG Support So... Share On