Android camera-smoothzoom

Source: Internet
Author: User

Recently, many Android Developers are busy with camera in projects. Because most Android Developers are eager to communicate with each other, they are developing on simulators and working on hardware-related practices, (For example, I will record the zoom problem of camera at the moment). There is really little information available on the Internet. However, the debugging process of specific hardware information in the project cannot be made public. I will not write details. Let's talk about the ideas.

My camera zoom problem is as follows:

 

The zoom value is within the range [0, 28]. The average smooth zoom effect is doubled to 8 times.

I dragged smoothzoom from * 1 to * 8 log:

 

V/camera (30714): Zoom changed: value = 1. Stopped = true
D/camera (30714): pai_^ zoom_stopping
V/camera (30714): Zoom changed: value = 2. Stopped = true
D/camera (30714): pai_^ zoom_stopping
V/camera (30714): Zoom changed: value = 3. Stopped = true
D/camera (30714): pai_^ zoom_stopping
V/camera (30714): Zoom changed: value = 4. Stopped = true
D/camera (30714): pai_^ zoom_stopping
V/camera (30714): Zoom changed: value = 5. Stopped = true
D/camera (30714): pai_^ zoom_stopping
V/camera (30714): Zoom changed: value = 7. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 8. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 10. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 12. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 15. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 18. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 21. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 24. Stopped = false
D/camera (30714): ^_^ zoom_start
V/camera (30714): Zoom changed: value = 28. Stopped = true
D/camera (30714): ^_^ zoom_start

(Note: value = 28 does not mean 28 times, but 8 times)

 

According to the log analysis above, the logic is very disordered. When the stopped parameter is true, Zoom is stopped. I am puzzled by the true value of value 1-5. The actual effect on the real machine is that the scenario is doubled in the image, but the photo is indeed B times the effect ......

 

 

 

 

 

What's even more frightening is that after the zoom n rounds are automatically tested, the camera is restarted again. The I2C error on the full screen tells me that the camera has crashed ...... If no problem is found, I will also be suspended ......

 

Camera has a large number of files and many files with the same name. You have to sort out the files and clarify your ideas.

 

 

 

 

 

I did not write the path of camera. cpp for a reason.

For upper-layer applications, camera. CPP is the most direct function call and implementation. For more information, see framework/base/libs/camera. CPP, but when the hardware device is determined, it is integrated into a path in the actual project according to the hardware function. Traditionally, it is placed under hardware, as for how to compile the content, that is another aspect.

 

Start camera and initialize zoom first. If the hardware does not support zoom, return directly.

Yes. Set msmoothzoomsupported to true.

  Private void initializezoom () {</P> <p> If (! Mparameters. iszoomsupported () return; </P> <p> // maximum zoom value may change after preview size is set. get the </P> <p> // latest parameters here. </P> <p> mparameters = mcameradevice. getparameters (); </P> <p> mzoommax = mparameters. getmaxzoom (); </P> <p> msmoothzoomsupported = mparameters. issmoothzoomsupported (); </P> <p> mgesturedetector = new gesturedetector (this, new zoomgesturelistener (); </P> <p> mcameradevice. setzoomchangelistener (mzoomlistener); </P> <p >}< br/>  Listen to the zoom status by classZoomListener

  implements android.hardware.Camera.OnZoomChangeListener {
In different zoom statuses, Peugeot also transmits values to the underlying layer. Private void onzoomvaluechanged (INT index) {</P> <p> If (msmoothzoomsupported) {</P> <p> If (mtargetzoomvalue! = Index & mzoomstate! = Zoom_stopped) {</P> <p> mtargetzoomvalue = index; </P> <p> If (mzoomstate = zoom_start) {</P> <p> mzoomstate = zoom_stopping; </P> <p> mcameradevice. stopsmoothzoom (); </P> <p >}</P> <p >}else if (mzoomstate = zoom_stopped & mzoomvalue! = Index) {</P> <p> mtargetzoomvalue = index; </P> <p> mcameradevice. startsmoothzoom (INDEX); </P> <p> mzoomstate = zoom_start; </P> <p >}</P> <p >}else {</P> <p> mzoomvalue = index; </P> <p> setcameraparameterswhenidle (update_param_zoom); </P> <p >}</P> <p>

 

 

When receiving a zoom change signal

Case camera_msg_zoom: </P> <p> If (mzoomlistener! = NULL) {</P> <p> mzoomlistener. onzoomchange (msg. arg1, MSG. arg2! = 0, mcamera); </P> <p >}</P> <p> return; <br/>

 

 

In fact, aside from the I2C problem, just clarifying these operations is enough to solve the problem. Today, I am so tired that I can write it next time-_-|

You are welcome to learn more about the camera I2C experience.

 

 

Author: yiyaaixuexi published on 17:04:00 Original article link reading: 507 comments: 14 views comments

Related Article

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.