Camera-oriented development

Source: Internet
Author: User

This section mainly describes the application development for mobile cameras. Icamera enables applications to access camera sensors on mobile phones, configure camera snapshot and video modes, and provide a variety of recording and encoding methods (Figure 14-9 ).

Figure 14-9: icamera Architecture

 

The Application of icamera can be used to obtain scenes, encode and store photos in JPEG format, encode and store videos in MPEG4 format, and contrast, zoom, and focus on cameras, white Balance and other attributes are set to listen for and process various camera-related asynchronous events. The state machine is shown in 14-10.

Figure 14-10: State Machine of icamera

When using icamera, you first create an interface through aeeclsid_camera:

Ishell_createinstance (PME-> A. m_pishell, aeeclsid_camera, (void **) & PME-> m_picamera );

Then register the callback function to receive camera events,

Icamera_registerpolicy (PME-> picamera, capp_cameranotify, PME );

Next, set the framing mode and display area:

Icamera_setparm (PME-> picamera, cam_parm_preview_type, cam_preview_snapshot, 0 );

Icamera_setdisplaysize (PME-> m_picamera, & PME-> m_sizedisplay );

Icamera_setsize (PME-> m_picamera, & PME-> m_sizeframe );

For the encoding method, you can specify the JPEG mode during photography and the MPEG4 and AAC audio encoding during video recording.

Icamera_setvideoencode (PME-> m_picamera, aeeclsid_jpeg, 0 );

Icamera_setvideoencode (PME-> m_picamera, aeeclsid_mpeg4, 0 );

Icamera_setaudioencode (PME-> m_picamera, aeeclsid_aac, 0 );

You can call icamera_preview () and icamera_stop () to start and stop scene retrieval. asynchronous events in photography and video recording are mainly included in the aeecameranotify data structure:

Typedef struct aeecameranotify

{

Icamera * pcam;

Int16 ncmd;

Int16 nsubcmd;

Int16 nstatus;

Int16 nreserved;

Void * pdata;

Uint32 dwsize;

} Aeecameranotify;

Nstatus defines the status code similar to cam_status_xxx, ncmd defines the command code (for example, cam_cmd_start), and nsubcmd contains the code of sub-commands (for example, cam_cmd_start, the sub-instruction code contains information similar to the cam_mode_xxx mode. pdata contains event-related data. dwsize refers to the length of the data. Table 14-3 describes some event interpretations related to the scenario.

Event combination
Event Interpretation
 
{Cam_cmd_start, cam_mode_preview, cam_status_start}
The icamera interface object is converted from ready to preview.
 
{Cam_pai_start, cam_mode_preview,

Cam_status_frame}
Icamera_getframe () can obtain the current image of this frame.
 
{Cam_pai_start, cam_mode_preview,

Cam_status_done}
After the scene is retrieved, the icamera interface object is converted from preview to status ready.
 
{Cam_pai_start, cam_mode_preview,

Cam_status_abort, cam_exxx _}
Exit unexpectedly During scenario fetch
 

Table 14-3: Events in camera scene Capture Mode

The status transition sequence of icamera interface objects in the scenario is 14-11.

Figure 14-11: Status transition sequence of icamera

 

The following is an example of processing frame events in video mode using icamera:

Static void myapp_cameranotify (MyApp * PME, aeecameranotify * PN ){

Switch (PN-> nstatus ){

Case cam_status_start:

// Preview has begun...

Break;

Case cam_status_frame:

{

Ibitmap * pframe;

Aeebitmapinfo Bi;

// Get the frame.

Icamera_getframe (PME-> m_picamera, & pframe ));

// Get the bitmap info.

Ibitmap_getinfo (pframe, & BI, sizeof (BI ));

// Display the frame at (0, 0) location of the screen

Idisplay_bitblt (PME, 0, 0, Bi. CX, Bi. Cy, pframe, 0, 0, aee_ro_copy );

Ibitmap_release (pframe );

Break;

}

Case cam_status_done:

// Icamera_stop () stopprf preview Operation stopped.

Break;

Case cam_status_abort:

// Preview got aborted.

Break;

}

}

To complete a photo operation, you must first set the storage location of the photo and then perform the photo operation.

Icamera_setmediadata (PME-> m_picamera, & MD );

Icamera_recordsnapshot (PME-> m_picamera );

The original image is saved in JPEG format. The status transition sequence of the icamera interface object is 14-12.

 

Figure 14-12: status transfer sequence of icamera photography operations

During video recording, the icamera interface object will capture the original image frames and related audio data, and then send frame-related events to brew applications, both frame and audio data are encoded in MPEG4/AAc format. When using the video, you must specify the storage location of the video, and then perform the video operation. When the video is complete, the video operation is terminated.

Icamera_setmediadata (PME-> m_picamera, & MD );

Icamera_recordmovie (PME-> m_picamera );

Icamera_stop (PME-> m_picamera );

The status transition time series of icamera object recording is 14-13.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/wireless_com/archive/2010/08/26/5839613.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.