简体   繁体   English

奇怪的三星Galaxy S相机预览

[英]Weird Samsung Galaxy S camera preview

I am using pretty much the same code as the Camera app code from Google but am getting really weird results. 我使用的代码与Google的Camera应用程序代码几乎相同,但是得到的结果却很奇怪。 Inside my application and the Camera app from Google the preview gets stuck or is overlid with weird lines. 在我的应用程序和Google的“相机”应用程序内部,预览卡住或被怪异的线条覆盖。 The preview is usually the last thing which I see in the phone's own Camera app. 预览通常是我在手机自己的相机应用程序中看到的最后一件事。

The Samsung model is I9003. 三星型号为I9003。 The same code ran fine on I9000 which Samsung just discontinued. 相同的代码在三星刚刚停产的I9000上运行良好。 The code also works fine on an HTC Wildfire. 该代码在HTC Wildfire上也可以正常工作。

Any resolution for this? 有什么解决办法吗?


Just noticed that after taking a photo inside my application the camera preview becomes normal. 只是注意到在我的应用程序中拍照后,相机预览变得正常了。 Same thing is happening in the Google camera application. Google相机应用程序中也发生了同样的事情。

Couldn't post the answer earlier. 无法提前发布答案。 Wasn't sure if it was the right thing to do, but now with the app running properly on around 150 devices I guess this works. 不确定这是否正确,但是现在该应用程序可以在大约150个设备上正常运行,我猜这可以正常工作。

So the Android camera app in its onCreate function had the following code: 因此,Android相机应用程序的onCreate函数具有以下代码:

         /*
         * To reduce startup time, we start the preview in another thread.
         * We make sure the preview is started at the end of onCreate.
         */
        Thread startPreviewThread = new Thread(new Runnable() {
            public void run() {
                try {
                    mStartPreviewFail = false;
                    startPreview();
                } catch (CameraHardwareException e) {
                    // In eng build, we throw the exception so that test tool
                    // can detect it and report it
                    if ("eng".equals(Build.TYPE)) {
                        throw new RuntimeException(e);
                    }
                    mStartPreviewFail = true;
                }
            }
        });
        startPreviewThread.start();

For some reason this did not work on GT-I9003. 由于某些原因,这在GT-I9003上不起作用。 What I noticed was that after taking a photo the preview would come properly so there was nothing wrong with the hardware as such. 我注意到的是,在拍照之后,预览将正常进行,因此硬件本身没有任何问题。 I tried to retrace what was happening after a photo was taken and then compare it with the code with which the camera was first initialized. 我试图追溯照片拍摄后发生的情况,然后将其与首次初始化相机的代码进行比较。 I commented out this code from onCreate. 我从onCreate注释掉了这段代码。 The onResume from the camera app looked like this: 相机应用程序的onResume看起来像这样:

if (mSurfaceHolder != null) {
   // If first time initialization is not finished, put it in the
   // message queue.
   if (!mFirstTimeInitialized) {
      mHandler.sendEmptyMessage(FIRST_TIME_INIT);
   } else {
      initializeSecondTime();
   }
}

I changed this to: 我将其更改为:

        if (!mFirstTimeInitialized) {
            initializeFirstTime();
        } else {
            initializeSecondTime();
        }

There were some other changes too, will put it up on GitHub as a separate app soon. 还有其他一些更改,很快将作为单独的应用程序将其发布在GitHub上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM