Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi :
I use ICamera interface in brew,and not i can enter preview mode,but i don't know how to take a snapshort with coding,

Actually, when i want to take a snapshort ,is it write to just call
ICAMERA_Stop when i press key and then do some processing in callback function?
any one can give me some examples?
Best thanks!

Hi,
In Notification function for the value CAM_STATUS_DONE of nStatus use ICAMERA_RecordSnapshot(...).
Look at the following code snippet.
case CAM_STATUS_DONE:
if ( pn->nCmd == CAM_CMD_START ){
int nErr;
if ( pn->nSubCmd == CAM_MODE_PREVIEW ){
nErr=ICAMERA_SetMediaData(pMe->pICamera, &pMe->md, MT_PNG);
DBGPRINTF("media data %d",nErr);
if(nErr != SUCCESS)
DBGPRINTF("#### MediaData Error [%d]\n", nErr);
ICAMERA_SetVideoEncode(pMe->pICamera,AEECLSID_PNG,0);
nErr = ICAMERA_RecordSnapshot(pMe->pICamera);
if(nErr==SUCCESS){
nErr=CP_CopyImageFromAppsToShareDir("image.png","fs:/shared/picture/clickpos.png");
if(nErr==SUCCESS)
DBGPRINTF("image written in shared dir...");
else if(nErr==ENOMEMORY)
DBGPRINTF("Memory problem...");
else if(nErr==EFILEEXISTS)
DBGPRINTF("File not exists..");
else if(nErr==EFAILED)
DBGPRINTF("Dest File can't created");
else
DBGPRINTF("File not written...");
}
}
DBGPRINTF("takes snap successfully !");
}
break;

Hi,
In Notification function for the value CAM_STATUS_DONE of nStatus use ICAMERA_RecordSnapshot(...).
Look at the following code snippet.
case CAM_STATUS_DONE:
if ( pn->nCmd == CAM_CMD_START ){
int nErr;
if ( pn->nSubCmd == CAM_MODE_PREVIEW ){
nErr=ICAMERA_SetMediaData(pMe->pICamera, &pMe->md, MT_PNG);
DBGPRINTF("media data %d",nErr);
if(nErr != SUCCESS)
DBGPRINTF("#### MediaData Error [%d]\n", nErr);
ICAMERA_SetVideoEncode(pMe->pICamera,AEECLSID_PNG,0);
nErr = ICAMERA_RecordSnapshot(pMe->pICamera);
if(nErr==SUCCESS){
nErr=CP_CopyImageFromAppsToShareDir("image.png","fs:/shared/picture/clickpos.png");
if(nErr==SUCCESS)
DBGPRINTF("image written in shared dir...");
else if(nErr==ENOMEMORY)
DBGPRINTF("Memory problem...");
else if(nErr==EFILEEXISTS)
DBGPRINTF("File not exists..");
else if(nErr==EFAILED)
DBGPRINTF("Dest File can't created");
else
DBGPRINTF("File not written...");
}
}
DBGPRINTF("takes snap successfully !");
}
break;

Thanks Prayag for the code snippet, took me long time to figure out! thanks again! :)
I was missing on following code:
if ( pn->nCmd == CAM_CMD_START )
{
if ( pn->nSubCmd == CAM_MODE_PREVIEW ){
ICAMERA_SetMediaData()------->
ICAMERA_SetVideoEncode()---->
ICAMERA_SetSize()------->
[Optional]ICAMERA_SetQuality()------>
ICAMERA_RecordSnapshot()--> to do Immediate Encoding,
}

Thanks again!

Thanks Prayag for the code snippet, took me long time to figure out! thanks again! :)
I was missing on following code:
if ( pn->nCmd == CAM_CMD_START )
{
if ( pn->nSubCmd == CAM_MODE_PREVIEW ){
ICAMERA_SetMediaData()------->
ICAMERA_SetVideoEncode()---->
ICAMERA_SetSize()------->
[Optional]ICAMERA_SetQuality()------>
ICAMERA_RecordSnapshot()--> to do Immediate Encoding,
}

Thanks again!

I see the camera inverted in preview mode. I tried using as follows:
ISHELL_CreateInstance(m_pApp->m_pIShell, AEECLSID_CAMERA,
(void **)&m_pCamera);
ICAMERA_SetDisplaySize(m_pCamera, &m_sizePreview);
ICAMERA_SetParm(m_pCamera,CAM_PARM_ROTATE_ENCODE,180,0);
//returns SUCCESS
ICAMERA_Preview(m_pCamera);
and in cameraNotify,
static void CApp_CameraNotify(void * pUser, AEECameraNotify * pn)
{
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi;
if (SUCCESS != ICAMERA_GetFrame(pCamera->m_pCamera, &pFrame))
return;
// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
IDISPLAY_BitBlt(pme->m_pIDisplay, 0, 0, bi.cx, bi.cy, pFrame,
0, 0, AEE_RO_COPY);
IDISPLAY_Update(pme->m_pIDisplay);
IBITMAP_Release(pFrame);
break;
}

I tried
nErr = ICAMERA_SetParm(m_pCamera,CAM_PARM_ROTATE_PREVIEW,90,0);
//returns EBADPARM
any suggestion?

I see the camera inverted in preview mode. I tried using as follows:
ISHELL_CreateInstance(m_pApp->m_pIShell, AEECLSID_CAMERA,
(void **)&m_pCamera);
ICAMERA_SetDisplaySize(m_pCamera, &m_sizePreview);
ICAMERA_SetParm(m_pCamera,CAM_PARM_ROTATE_ENCODE,180,0);
//returns SUCCESS
ICAMERA_Preview(m_pCamera);
and in cameraNotify,
static void CApp_CameraNotify(void * pUser, AEECameraNotify * pn)
{
case CAM_STATUS_FRAME:
{
IBitmap * pFrame;
AEEBitmapInfo bi;
if (SUCCESS != ICAMERA_GetFrame(pCamera->m_pCamera, &pFrame))
return;
// Get the bitmap info...this can be saved in app global structure.
IBITMAP_GetInfo(pFrame, &bi, sizeof(bi));
IDISPLAY_BitBlt(pme->m_pIDisplay, 0, 0, bi.cx, bi.cy, pFrame,
0, 0, AEE_RO_COPY);
IDISPLAY_Update(pme->m_pIDisplay);
IBITMAP_Release(pFrame);
break;
}

I tried
nErr = ICAMERA_SetParm(m_pCamera,CAM_PARM_ROTATE_PREVIEW,90,0);
//returns EBADPARM
any suggestion?

CAM_PARM_ROTATE_PREVIEW mostly supports 0 & 180 degree.
EBADPARM is returned if rotation value is not supported.

CAM_PARM_ROTATE_PREVIEW mostly supports 0 & 180 degree.
EBADPARM is returned if rotation value is not supported.