stuck with taking images in camera can someone help?
| Mon, 2007-10-01 13:00 | |
|
Hi, Now I am stuck after the CCamer::PowerOnComplete().Dont know what to do next Here is the code void CXXXX::PowerOnComplete(TInt aError) void CXXXX::ViewFinderDirectScreenAccessL() iCamera->StartViewFinderDirectL(CCoeEnv::Static()->WsSession(),*CCoeEnv::Static()->ScreenDevice(),*iAppView->DrawableWindow(), aScreenRect); void CXXXX::ViewFinderBitmapsL() |
|






Forum posts: 85
What to do next?????????
Forum posts: 85
am i doing it right way????????
Forum posts: 1134
I think you need to be a bit more specific in what your problem is, for anyone to be able to help you.
I have never used the camera api, and don't have time to read up on it just to proof read every line of your code to know if you "do it right" so far...
But if you had any more information on where you get stuck, what doesn't work as you intend, or what exactly it is that confuse you, maybe I or someone else with good general symbian knowledge could give you more pointers to what to do.
As the question is asked now, I think most people just click away. Most people don't have time to read long source dumps just to understand what you are asking about...
Forum posts: 85
yes I am confused but
find it difficult to explain what my confusion is.........
It may take time......
trying hard....
Thanx Mr.Allh
for ur precious advice...
Forum posts: 24
I dont know what is ur exact problem but i can give u a general idea about how to work with camera api's
first u should reserve the camera hardware which can be done by calling the api
CCamera::Reserve ()
it is a async request so once it completes it ll call the observer method(u need to implement MCameraObserver interface)ReserveComplete with the error code
if there is no error
call poweron
void CCameracallback:: ReserveComplete(TInt aError)
{
if( KErrNone == aError )
{
// As there are no erros, its safe to power on the Camera Device.
iCamera->PowerOn();
}
else
{
// Oops... Some thing wrong happened and it could not reserve the camera.
// So release the camera and report the error.
iCamera->Release();
}
}
once the power on is complete it ll call the observer method(u need to implement MCameraObserver interface)PowerOnComplete with the error code
if there is no error
Now there are two thing that u can do
1) Start the view finder and then take the image
2) Take the picture directly
First one can be done by calling the camera startviewfinder api in PowerOnComplete method in the following way
void CCameraCallback:: PowerOnComplete(TInt aError)
{
if( KErrNone == aError )
{
// Everything is going fine. Now we can start the ViewFinder operation.
TSize size(200,200);
//Request largest image
iCamera->PrepareImageCaptureL(CCamera::EFormatFbsBitmapColor16M, 0 );
// Start the view finding, and transfer the view finder data.
// Bitmaps are returned by MCameraObserver::ViewFinderFrameReady().
iCamera->StartViewFinderBitmapsL(size);
}
}
Now the camera class ll call the Observer method with the bitmap now call the takepicture method after stoping the view finder
void CCameraCallback::ViewFinderFrameReady( CFbsBitmap& aFrame)
{
iCamera->StopViewFinder();
iCamera->CaptureImage();
}
Now the camera class ll call the Observer method ImageReady()
void CCameraServiceProvider::ImageReady( CFbsBitmap* aBitmap,HBufC8* , TInt aError )
{
//Now u ve got the captured Bitmap aBitmap
// u need to use the image converting library to save it in any of the supported formats
//see CImageEncoder class for more info
}
2) for direct caputre after PowerOnComplete
void CCameraCallback:: PowerOnComplete(TInt aError)
{
if( KErrNone == aError )
{
//Request largest image
iCamera->PrepareImageCaptureL(CCamera::EFormatFbsBitmapColor16M, 0 );
iCamera->CaptureImage();
}
}
this ll call the same CCameraServiceProvider::ImageReady( CFbsBitmap* aBitmap,HBufC8* , TInt aError ) method with the captured bitmap and u can use imageconversion library
I hope this is clear
Forum posts: 85
thanx,
Your reply has made me somewhat clear.......
1>>>>My main confusion was regarding viewfinder...why viewfinder?is it only to show images on the mobile screen
I think I have got the answer from ur lines
Now there are two thing that u can do
1) Start the view finder and then take the image
2) Take the picture directly
It is only to display images on mobile screen......
2>>>>>>>>>Something that is not yet clear->
There are 2 types of viewfinders-------StartViewFinderBitmapsL and StartViewFinderDirectL
using StartViewFinderBitmapsL ,The Observer method that gets called is ViewFinderFrameReady
which Observer Method is called using StartViewFinderDirectL??????
options:-
a.same ViewFinderFrameReady
b. Any other observer method
c.No Observer method is called...
3>>>>was suspicious about the "position of PrepareImageCaptureL()", Now I think I can place it anywhere before CaptureImage() and after PowerOnComplete().
But I am still not sure.Require confirmation....
4>>>>>>>>In the method ImageReady( CFbsBitmap* aBitmap,HBufC8* , TInt aError ),when is the Image stored in CFbsBitmap* and when in HBufC*?????????Need explanation.It depends on the formats specified in call to PrepareImage()..
Which format is required for HBufC*
and
which for CFbsBitmap* ?????
5>>>>>>.In the SDK documentation, I read that "you should not forget to save the captured Image"
This means that the image that is obtained(in CFbsBitmap* or in HBufC8* ) needs to be saved somewhere.But how??????
6>>Before Streaming on socket Do I need to convert the image ??
As you wrote that I have to use image conversion Library, now I am sure that I have to do the conversion......
Then should I use "CImageDecoder" or "CImage Encoder"....I feel I have to use "CImageDecoder".But not sure.
Forum posts: 1134
Thats to be expected in programming.
Specially when using symbian I have noticed...
1) and 2)
"viewfinder" is, in general, the name for what you look at to aim your camera, also in an old analog camera.
In digital fotography it is typically lower resolution then the real image. (to be able to handle quicker)
When you use ViewFinderDirect, the camera api will use direct screen access to put the bitmap on the screen for you, when using ViewFinderBitmaps, you will get the viewfinder as a stream of bitmaps that you can do whatever you want with.
So the answer is most probably c)
3)
No idea.
4)
CFbsBitmaps are not compressed, therefore, they are not suitable when taking very high resolution images, because they would need too much memory bandwith to transfer from the camera hardware to your app.
Therefore, you can only get the highest resolution when choosing the "exif" format, which will tell the camera to output a jpg compressed image.
Since jpg compression is not compatible with CFbsBitmaps, you will then get the data as a HBufC8*.
So.. as long as the requested format is compatible with CFbsBitmaps, you will get those, otherwise HBufC8
5)
However you want... what they mean is that the data pointed to will be overwritten on the next image capture, so if you need the image later, you have to copy the data in some way. How depends on what you want to do with it.
6)
Depends... some compression is probably a good idea, since it will reduce bandwith and make your app quicker. Though it also has to be weighted agains the time it take to compress.
Exif data is already compressed jpeg data so doesn't need more compression.
Probably this is the quickest if you want to stream, since the camera hardware does the compression for you.
Decode is what you use when you want to convert from a compressed format to a CFbsBitmap, and Encode is the other way around.
Forum posts: 24
HI,
Regarding ur confusions
2) StartViewFinderBitmapsL:- should be used when u want to get the Bitmap data and u r going to render the bitmaps onto the screen.(UI should be handled by u)
StartViewFinderDirectL :- This takes ur window screen and window session as argument and the bitmaps are rendered directly to the given screen(see documentation for more info)
3) As i said after poweroncomplete u can start viewfinder or take picture directly u r right regarding this point.
4) You r right here too, for formats see these enumerations CCamera::TFormat
5) For saving part of the image i can give u a rough code but just read the class CImageEncoder
// Look into the CImageEncoder::FileNewL there are many versions u can try the one which u feel easy to use

// This api opens the file with the specified file name and in the specified format of the image
CImageEncoder* encoder = CImageEncoder::FileNewL( iFsSession, iNewFileName, CImageEncoder::EOptionNone, iImageType );
// This api converts the image to the specified format (in the above api) and returns the status in the iStatus variable
encoder->Convert( &iStatus, *iBitmapSave );
I f u ve doubt about iStatus u need to study active objects first.
6)Regarding streaming to a socket u can use CImageEncoder itself to encode the data. For this u can use DataNewL()
api instead of FileNewL read the documentation for more info
I hope this clears all u confusion.
Forum posts: 85
Thanks prajwal for spending your precious time.