Showing posts with label msdn. Show all posts
Showing posts with label msdn. Show all posts

Thursday, 24 July 2014

How to Capture “Friendly Name” from a Camera

Hi, Today am back with a mindblowing,method to tell you how you can capture or get a Friendly name of a camera.

What is a Friendly Name??
Any devices, will have some kind of ID for identification, some of them are
Device ID:
Vendor ID: etc...
Since all these are numbers, it is hard to be remembered by the user, so therefore a short name to recognize the type of camera , is called the friendly name.

Ex:USB 2.0

Things Required:
1.Visual Studio
2.Platform SDK
3.A Camera
So lets get started,into our journey of capturing Friendly names of a camera

STEP 1:
Install,the platform SDK,properly.You can have a look into my previous chapters where I would have discussed that.

STEP 2:
Open Visual Studio 2005, and then open a new Win32 Project,hope you are familiar with building Win32 Apps.For those who are not, dont worry, in a week or so I will post tutorials on win32 programming

STEP 3:
Just make a simple dialog box with an button,add a list box for viewing the enumerated Device. Just see the screen shot  below.
                                
STEP 4:
This is a crucial step as I am going do  a brief explanation of some of the concepts. I have commented my program ,to an extend where you can easily understand.

Here We are going to use a concept called COM(Component Object Model) which is a binary interface standard for software modules. It’s an interface between two program modules, one of them is an OS or a library.

System Device Enumerator
It returns a collection of device Monikers, selected by a device category.It enumerates Filters and hardware installed on the system.

Monikers
It contains information that uniquely identifies a component object model.
There is two important properties of it
1. Can be saved and later retrieved.
2. Support an operation called binding, which is a process of locating object named by a Moniker, activating and loading it, if it is not already active.

Iproperty Bag
This is a kind of variable ,or you can assume it as a bag as the name suggests, from which we can read the values. The Imonikers saves the object properties on it.
  Just see the program ,try building it and running it and then explore your own ideas with it.

If all step is  properly done then you can see an  window , as shown below


And here we come to the end of this tutorial ,hope you liked it.
Author
Vivek Gr
Embedded Project Engineeer




Saturday, 12 July 2014

CAN A FUNCTION RETURN MORE THAN ONE VALUE?

FUNCTION RETURNING MORE THAN ONE VARIABLE


Yes, it can. Actually it’s not a concept in any of the programming languages like c,c++. It is a method of using the pointers in different way. it is only applicable for the programming languages which has the pointer concepts. To understand this method you have to know about pointers first.

To use this method first you have define a function which can be a any of the return type with necessary parameters.

e.g.  int add(int a,int b)

but unfortunately this function can return only one value. But you need two value to be return from the function.

Say for example there is function which have to return both the number of digits and sum of the digits from a number. First keep any of the return value as main return value of the function.

Int sum_count_of_digit(int number)
{
Return sum;
}

This function can only return the sum. To get the count of the digits first you have to declare a variable before the function call. It can be either a global variable or a local variable.

Int count=0;
Int sum=Sum_count_of_digit(number);
Function:
Int sum_count_of_digit(int number)
{
Return sum;
}

Then u have to pass the variable as parameter to function but not as normal parameter. As an address to the function.

Int count=0;

Int sum=Sum_count_of_digit(number,&count);
But in function declaration you have to declare the parameter as pointer. The declaration of the function is given below.

Int sum_count_of_digit(int number,int * count);

In the function if you increment the count value the main value which is outside of the function is incremented. At the end of the function the sum of the digits is returned. So obviously you can get the both values from the function.

Int count=0,number=158;
Int sum=Sum_count_of_digit(number,&count);
Function:
Int sum_count_of_digit(int number,int *count)
{
For()
{
*count++;           //loop for counting the digit
}
Return sum;       //returns the sum of the digits
}


I hope you clearly understood the method... if you have any doubt and questions comment below. In my next post I will tell more about images and creating a image viewer on your own.


Author
Saravanakumar S
Embedded Project Engineer