background preloader

Automatic Face Detection in Photos with PHP

Automatic Face Detection in Photos with PHP
I have always wondered how to detect faces automatically with php script. I have seen in many photo sharing and social network sites automatically detect a face and tag a name after being uploaded. In this article, i will explain how possible this task can be achieved with simplicity with OpenCV and PHP Facedetect extension. Both are free to download and opensource. Goal To auto detect faces in a photo and draw pink box around the faces with a php script running a linux centos server. Requirements - Linux server running Centos with SSH access - PHP/Apache - GD Library - OpenCV [Download] - PHP Facedetect extension [Download] PHP facedetect extension is very simple. Installation We install opencv and then we compile the php facedetect extension with php. How to Install OpenCV If you are running centos then one single line will install opencv. yum install opencv OpenCV may also need the following depencies to work properly and you will need to install them as well. How to test run OpenCV . run . then

How to Create an Infinite Scrolling Web Gallery When working my way through a web gallery, I find it annoying when I must change pages; so in today's tutorial, we will learn how to create an auto-generating, one-page, infinite scrolling gallery with PHP and AJAX. Let's get started! Step 1: Project Outline We'll begin with a normal gallery page that has a container for our images, and we'll monitor the scroll position by calling a JavaScript function at a quick interval. Each time the scroll bar is near the bottom, we'll make an AJAX request to an external PHP file, which returns a list of image names. Step 2: HTML Markup We'll work with a very basic setup: a header and the container for our images. Step 3: CSS The CSS is also quite basic. Step 4 Then, for the container and images, I used a bit of CSS3 to add round corners and shadows. Step 5: PHP Script This is going to be very short. We define a variable for the directory we want to get the image names from, test if it exists, and if we can open it, read all the file names from it.

'MySQLi' for Beginners Introduction Nearly every site that you visit nowadays has some sort of database storage in place, many sites opt to use MySQL databases when using PHP. However, many people haven't yet taken the step to interacting with databases properly in PHP. The Wrong Way If you're using a function called mysql_connect() or mysql_query() you really need to take note and change what you're doing. Any of the functions that are prefixed with mysql_ are now being discouraged by PHP themselves as visible on this doc page, instead you should look to use one of the following: Each has its advantages, PDO for example will work with various different database systems, where as MySQLi will only work with MySQL databases. PHP MySQLi Here we'll mostly be looking at the object oriented implementation, however, there is no reason you can't use this in a procedural format, but again no reason you shouldn't use the OO implementation. Connecting Obviously, the database name is optional and can be omitted. Querying <? <?

PHP: Hypertext Preprocessor How to Upload files with PHP » Martin Gardner.co.uk In this Tutorial I’m going to outline the process of how you can use a simple PHP script to upload files directly to your server, re-naming them and storing them in a chosen location, all from a very simple form which you can style and place anywhere on your webpages… things to keep in mind for this script to function properly you will require the following: Web hostingPHP 5 or above installedWrite access to a directory on your web serversome PHP knowledge ( to allow for your own customization)basic CSS & Colour values to style your form Before we get to any code you’re going to need a HTML form, in order to pass information to the script, like the name of the file, size, file extension etc… but for this script we will only have to deal with the name of the file. below is an html form with some basic CSS styles applied purely for aesthetic reasons of my own. The PHP The CSS The First part of the code initialises the first two variables and assigns them with no value.

How to create chained select with PHP and jQuery? In this article we’ll talk about the chaining of select also called select cascade. It is a procedure that we often find on the web and it consists in giving the user the possibility to find a specific data through a few passages: practically choosing a category in the first select, the second one will be populated with the results related with the category selected. We imagine, for example, a first select where it is possible to choose between motorcycles and cars; once we selected the car category , the second select will be populated with the brands of the cars available. Then selecting a brand, the third select will be populated with the models available of this brand. You can examine what we will create in this page of example. As you can see, the example is very minimalist. Create the structure of the database So we are going to create a table called categories with the fields id_catname And another table called type with the following fields id_typeid_catname So here the whole class:

Qcodo Development Framework - Home Build seven good object-oriented habits in PHP Make your PHP applications better with object orientation Nathan GoodPublished on October 28, 2008 In the early days of PHP programming, PHP code was limited to being procedural in nature. However, without object-oriented language constructs, a programmer can still introduce OO characteristics into PHP code. While purely procedural designs without much modularity run just fine, the advantages of OO design show up in the maintenance. Modularity— one of the key characteristics of good OO design — helps with this maintenance. While there are more than seven habits to building OO software overall, the seven habits here are what you need to make your code fit basic OO design criteria. The seven good PHP OO habits are: Be modest.Be a good neighbor.Avoid looking at Medusa.Embrace the weakest link.You're rubber; I'm glue.Keep it in the family.Think in patterns. Be modest To be modest is to avoid exposing yourself in your implementations of classes and functions. Bad habit: Expose public fields

45+ Best free PHP classes and libraries for Faster Development PHP: Hypertext Preprocessor (the name is a recursive acronym) is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. And, as a feature-rich language, it is possible to accomplish many tasks by default from handling e-mails to images, PDFs to database connections, etc. You may be interested in the following modern trends related articles as well. What is PHP? PHP stands for PHP: Hypertext PreprocessorPHP is a server-side scripting language, like ASPPHP scripts are executed on the serverPHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)PHP is an open source softwarePHP is free to download and use However, there are Best free PHP classes and libraries which helps you get more like: good looking chartsform validationparsing feedsbetter image or database handlingand more. Content BackPress PHP User Class phpSEO PHP Typography Tag Cloud Handling Documents PHPExcel PHPPowerpoint

10 Advanced PHP Tips Revisited Advertisement Here, on the Smashing Editorial team, we always try to meet the expectations of our readers. We do our best to avoid misunderstandings, and we try to spread knowedge and present only the best design practices and development techniques. However, sometimes we do make mistakes. And when we do, we apologize and do our best to correct what we’ve done. In November 2008 we published the article 10 Advanced PHP Tips To Improve Your Programming21. 10 Useful PHP Tips Revisited by Chris Shiflett and Sean Coates This article is a rebuttal to 10 Advanced PHP Tips To Improve Your Programming21 — henceforth referred to as the previous article — published last November here on Smashing Magazine. Listed below are 10 excellent techniques that PHP developers should learn and use every time they program. Unfortunately, the intrigue devolves into disappointment. 1. This particular tip is just a link to a useful resource with no discussion on how to use it. <? 2. 3. This brings us to our tip. 4. <?

oop - OO or procedural PHP for website 37 Tested PHP, Perl, and JavaScript Regular Expressions inShare22 A regular expression, also called regex or regexp for short, is simply a piece of code that matches a pattern. Mastering regular expressions can be a difficult chore, and if you don't need them all of the time, the syntax is tricky enough to make the task frustrating or slow as you will constantly need to use a reference sheet. In order to save you time, I've compiled a list of PHP, Perl, and JavaScript regular expressions for common use cases that have been tested and are ready to go. If you're looking for regex tutorials or regex resources, you can find them at the end of the page as well as some additional regex resources. Perl and PHP Regular Expressions PHP regexes are based on the PCRE (Perl-Compatible Regular Expressions), so any regexp that works for one should be compatible with the other or any other language that makes use of the PCRE format. All Major Credit Cards Alpha-Numeric Characters Test for alpha-numeric characters with this regexp. Alphabetic Characters Digits URLs

PHP snippets to interact with Twitter Get number of Twitter followers Have you seen my blog sidebar? I display the number of followers I have in full text. This is actually pretty easy to do. The first thing you need is this function: Once you have the function, you can call it as shown below: $nb = get_followers('phpsnippets'); echo "PHP Snippets already have ". » Credit: Get latest Twitter status Using PHP and cURL, it is pretty easy to get the status of a specific user. The function is extremely easy to use: echo get_status('catswhocode'); » Link to update status, without encoding problems Many websites and blogs show you how to create a link to Twitter that will update your status. <a href=" So, where’s the change? A working example can be seen on my company website: Get number of retweets for a specific page Using the function is easy, as you can expect:

Object Oriented PHP Tutorial for Beginners Preamble The hardest thing to learn (and teach btw,) in object oriented PHP is the basics. But once you understand them, the rest will come much, much easier. But don't be discouraged! You just found the easiest to understand tutorial out there on OOP and PHP. … Or so I've been told. About This Tutorial This tutorial is designed to teach total beginners object oriented PHP. This is not a long-winded theoretical blathering that you see all too often; instead, we actually start writing OO code very quickly. So before you begin, get out your favorite PHP code editor and be ready to write and run some object oriented PHP code. PS: scroll to the bottom of the page for the supporting videos. Thanks for reading,Stefan Mischook Introduction With the release of php5 in 2004, php programmers finally had the power to code with the 'big boys'. In this tutorial, you will be guided (step-by-step) through the process of building and working with objects using php's built-in OOP capabilities. OOP Videos

Deciphering Magic Methods in PHP PHP provides a number of 'magic' methods that allow you to do some pretty neat tricks in object oriented programming. These methods, identified by a two underscore prefix (__), function as interceptors that are automatically called when certain conditions are met. Magic methods provide some extremely useful functionality, and this tutorial will demonstrate each method's use. Before We Begin In order to fully understand magic methods, it's helpful to see them in action. So let's start with a base set of very simple classes. If words like "method" and "property" sound alien to you, you might want to read up on this first. Device objects will hold a name, a Battery object, an array of data, and a handle to some external resource. This tutorial assumes you have a basic understanding of object oriented programming. These classes are pretty useless, but they make a good example for each of the magic methods. Constructors & Destructors __construct() Let's say we forget to pass a name. __destruct()

Related: