Tuesday, December 31, 2013

No library found for this namespace error in PrimeFaces

This silly error message usually occurs if you are using a PrimeFaces 3.0 version onward. With older version of PrimeFaces (less than 3.0) we used to make the following declaration:
xmlns:p="http://primefaces.prime.com.tr/ui"
However from 3.0 the following declaration need to be used instead:
xmlns:p="http://primefaces.org/ui"
So far so good, hopeful the road block is lifted .
Enjoy it.

Saturday, December 28, 2013

Morphological filters in opencv: erosin , dilation, opening and closing.

While reading through this famous book for getting started with opencv  I came across this simple explanation of morphological filters. In fact erosion and dilation are the most fundamental morphological operators. The fundamental instrument in mathematical morphology is the structuring element. A structuring element is simply defined as a configuration of pixels (a shape) on which an origin is defined (also called anchor point). Applying a morphological filter consists of probing each
pixel of the image using this structuring element.
The two filters of this recipe operate on the set of pixels (or neighborhood) around each pixel.
  • Erosion: replaces the current pixel with the minimum pixel value found in the defined pixel set.
  • Dilation: is the complementary operator, and it replaces the current pixel with the maximum pixel value found in the defined pixel set.
 If the input binary image contains only black (0) and white (255) pixels, each pixel is replaced by either a white or black pixel. In the opening and closing filters are simply defined in terms of the basic erosion and dilation operations:
  •  Closing: is defined as the erosion of the dilation of an image.
  •  Opening: is defined as the dilation of the erosion of an image.



Sunday, December 22, 2013

HSV a preferred color model in Computer Vision ?

           From my sincere personal view understanding different color models and their differences can be of tremendous importance when dealing with digital image processing and computer vision. Many new comers in the field usually try do everything with the most common color model : the RGB, but are quickly disappointed with the result they obtain. The objective of this post is not to explain in detail color models nor the HSV, rather to raise awareness about the issue.
   According  to wikipedia a color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components (e.g. RGB and CMYK are color models). There are five major models, that sub-divide into others, which are: CIE, RGB, YUV, HSL/HSV, and CMYK.
  What about the HSL/HSV ?






The above picture depicting the Ostwald diagram is briefly explained in this article as follow:
  • The hue (H) of a color refers to which pure color it resembles. All tints, tones and shades of red have the same hue.
    Hues are described by a number that specifies the position of the corresponding pure color on the color wheel, as a fraction between 0 and 1. Value 0 refers to red; 1/6 is yellow; 1/3 is green; and so forth around the color wheel.
  • The saturation (S) of a color describes how white the color is. A pure red is fully saturated, with a saturation of 1; tints of red have saturations less than 1; and white has a saturation of 0.
  • The value (V) of a color, also called its lightness, describes how dark the color is. A value of 0 is black, with increasing lightness moving away from black.
  • The outer edge of the top of the cone is the color wheel, with all the pure colors. The H parameter describes the angle around the wheel.
  • The S (saturation) is zero for any color on the axis of the cone; the center of the top circle is white. An increase in the value of S corresponds to a movement away from the axis.
  • The V (value or lightness) is zero for black. An increase in the value of V corresponds to a movement away from black and toward the top of the cone.
Another important explanation is from stackoverflow with the following key statement:

Unlike RGB, HSV separates luma, or the image intensity, from chroma or the color information. If you want to do histogram equalization of a color image, you probably want to do that only on the intensity component, and leave the color components alone. HSV is often used simply because the code for converting between RGB and HSV is widely available and can also be easily implemented.

 Using only the Hue component makes the algorithm less sensitive (if not invariant) to lighting variations. Like our hand has many parts palm, back palm, and below that. we can see different color variation in these areas, but the hue for all these regions don't vary much, so hue value can be useful in hand segmentation.

Finally I can say that  RGB is the way computers treats color, and HSV try to capture the components of the way we humans perceive color. Opening a view for machine color perception (RGB) vs human color perception (HSV). I am not an expert in computer vision nor in image processing  but a knowledge seeker trying to explore these fields. Any constructive comment shading more light on this issue is warmly welcome.

Sunday, December 15, 2013

cv prefix of class and function in opencv like CvMat and Mat

Hi, if you are exploring the opencv library with cpp for the first time you may have noticed that certain function or classes start with Cv and some note. In fact opencv has two interfaces C and C++ therefore those classes of C interface start with Cv in opposite to the C++ interface.
e.g:

IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey(0);


vs

 image = imread("test.jpg");
 namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
 imshow( "Display Image", image );

 waitKey(0);


Definitely the following ultimate question will come which one to choose ? or at least which interface will make your miserable life easier given that either C or Cpp is already a problem compared to Java, Python, etc ... My sincere advice is that unless you have some requirement obligation (embedded system interfacing ...)it is better to use the C++ interface, given different flexibilities that it provides you in term of automatic memory allocation and even more ...


Friday, December 13, 2013

Difference between versions of Eclipse : Europa, Helios, Galileo ,etc

Bingo ! here we are. Why am I even blogging about Eclipse today ? The truth is that Eclipse sucks and I don't have any better option.  I am sure most of you guyz out there hate eclipse for so many reasons. Me particularly when its come to choose an IDE I always choose Netbeans before even thinking about Visual studio (PROGRAM NOT RESPONDING ....no comment) or Eclipse. But the reality is that in many software companies Eclipse is being used. 
  Any way two days back I fell on OpenCV, after being amazed by its applications on computer vision, smart phones and robotics I decided to put matlab beside and explore these still unknown libraries. As you all all know the defacto and prime IDE for developing Android today is Eclipse. Same as opencv, many documentations and demo projects out there are on eclipse and C++.
  When it comes to different naming used by Eclipse, at first glance it is confusing. Are you going to use helios , juno, galileo or Europa ?  What is even the difference ?
 In fact Eclipse has it own way of versioning. Instead of using numbers say Eclipse 3.1 , Eclipse 3.2 , Eclipse 4.0 and etc it gives instead name to a particular version.

As you can see from the above table from Wikipedia these code names although appearing alphabetically as time goes on have no particular meaning.
 What I have observed is that these names are just simple version names. But feel free to drop a comment to add something or share your eclipse experience with us. A plus!!!

insert into table from another table

Along the way, we want to select some data from one table A and insert into another table B. Directly we can simply fire the following query to get our desired data in the right place.

sql> insert into B (field_1_B, field_2_B, field_3_B)  select field_1_A, field_2_A, field_3_A from A;

Suppose now that these tables are from different databases inside mysql.

A is inside database DB1  and B inside databae DB2, then

sql> insert into DB2.B (field_1_B, field_2_B, field_3_B)  select field_1_A, field_2_A, field_3_A from DB1. A;

and so is it.

Concat multiple columns and string in Mysql

Yep, here come another simple trick found along the way. How to concat multiple columns and string together in mysql ? Suppose that you want to display the following output:

code         subcode     keycode    name
 5                 1            5-1             dummy 1
 5                  2           5-3             dummy 2
 3                  1           3-1             dummy 3

Our table columns:
 -code
 -subcode
 -name

but keycode does not exist in the table and should be formed from code and subcode.
keycode =  code , '-', subcode

So our query should be:

select code , subcode, concat(code,'-',subcode), name from ourTable;

In fact concat is a mysql built-in function returning a string from its concatenating arguments. Concat may take one, two or more arguments. You may also look into concat_ws() and for more info see http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat

Tuesday, December 3, 2013

What is JSF ?

JSF stands for Java Server Faces and blah blah blaah. Among these multiple definitions of JSF I come to keep one that says almost everything in few words and leave the task to anyone to dilute. JSF is a component oriented and event driven web framework to build up web applications. JSF after all is a standard and has many implementations Oracle ADF, Apache MyFaces, IBM and last the one so dear to me is the Sun reference implementation.
 As an event driven and component oriented framework, jsf nice integrate all the members of the MVC:
  •  Model: managed beans
  • View: components
  • Controller: faces servlet
So this is in short how you may look at JSF...

Monday, December 2, 2013

Should the human race be worried by the rise of robots?

I come to simply answer this question with this famous quotes from Francois Rabelais stating that

“Science without conscience is the soul's perdition.” 

 and therefore to conclude by saying that it is not the robots we need to worry about , but rather the people who programme. Knowledge itself has never been a crime, we may decide to use it for the good or the bad. Injecting little ethical values in anything we do or create will definitely put an end to such doubt and pave a way for a better world. This world of peace and love, of fraternity and tolerance, of justice and democracy among people without any discrimination based on gender, race, faith, social status...

Sunday, December 1, 2013

Robotics from a software perspective : Humanoid robot Vs Android robot

According to wikipedia : A humanoid robot is a robot with its body shape built to resemble that of the human body. A humanoid design might be for functional purposes, such as interacting with human tools and environments, for experimental purposes, such as the study of bipedal locomotion, or for other purposes. In general, humanoid robots have a torso, a head, two arms, and two legs, though some forms of humanoid robots may model only part of the body, for example, from the waist up. Some humanoid robots may also have heads designed to replicate human facial features such as eyes and mouths. Androids are humanoid robots built to aesthetically resemble humans.