Tuesday, January 28, 2014

android camera development setParameters failed error


            
Recently wrote a custom camera, Sky, motorcycles do the above tests are no problem, but to the htc to die at setParameters failed error, I do not know how else? Her brother help? Thank you, ah
Reply:
No detailed error information it?
Reply:
I found the main phone system that does not match, and when I set the image size, so the resulting
Reply:
I am also, how did you solve it? I was on htc g12 testing, qq: 1030103135, thanks
Reply:
Set the preview window size and image size and system support is not the same cause,
Reply:
Give solution ah ...... I also met this problem
Reply:
You have to get the system to support the camera preview size and image size. Then set
Reply:
Specifically how to set ah, masters teach me! ! ! Thanks ah

Reply:
/ / Select the appropriate size
previewList sizeList = parameters.getSupportedPreviewSizes ();

/ / If sizeList only one we do not need to do anything, because then he has no choice
aif (sizeList.size ()> 1) {
Iterator itor = sizeList.iterator ();
while (itor.hasNext ()) {
Camera.Size cur = itor.next ();
if (cur.width> = PreviewWidth
&& Cur.height> = PreviewHeight) {
PreviewWidth = cur.width;
PreviewHeight = cur.height;
break;
}
}
}

/ / Set Preview (preview) dimensions
parameters.setPreviewSize (PreviewWidth, PreviewHeight);

/ / Set the picture size
parameters.setPictureSize (Picwidth, Picheight);

Reply:
I was given .... I rely on
Reply:
try {
int PreviewWidth = 0;
int PreviewHeight = 0;
WindowManager wm = (WindowManager) getSystemService (Context.WINDOW_SERVICE) ;/ / get the window manager
Display display = wm.getDefaultDisplay () ;/ / get the window inside the screen
Camera.Parameters parameters = mCamera.getParameters ();
/ / Select the appropriate size
previewList sizeList = parameters.getSupportedPreviewSizes ();

/ / If sizeList only one we do not need to do anything, because then he has no choice
aif (sizeList.size ()> 1) {
Iterator itor = sizeList.iterator ();
while (itor.hasNext ()) {
Camera.Size cur = itor.next ();
if (cur.width> = PreviewWidth
&& Cur.height> = PreviewHeight) {
PreviewWidth = cur.width;
PreviewHeight = cur.height;
break;
}
}
}
parameters.setPreviewSize (PreviewWidth, PreviewHeight); / / get the size of the imaging area
parameters.setPreviewFrameRate (3) ;/ / 3 frames per second to get 3 pictures from the camera inside
parameters.setPictureFormat (PixelFormat.JPEG) ;/ / set the output format
photosparameters.set ("jpeg-quality", 85) ;/ / set the photo quality
parameters.setPictureSize (PreviewWidth, PreviewHeight) ;/ / set shot out of the screen size
/ /
mCamera.setParameters (parameters) ;/ / the above settings assigned to the camera
mCamera.setPreviewDisplay (mySurfaceView.getHolder ()) ;/ / get the camera screen display controls inside
in SurfaceViewmCamera.startPreview () ;/ / start preview
mPreviewRunning = true;
} Catch (IOException e) {
Log.e (TAG, e.toString ());
}
}
Reply:
After how I tried this method, when the preview screen has been flashing green preview does not see anything but it will also issue a set attribute failed. Reply
10th floor lxp5201314 of references:
try {
int PreviewWidth = 0;
int PreviewHeight = 0;
WindowManager wm = (WindowManager) getSystemService (Context.WINDOW_SERVICE) ;/ / get the window manager
Display display = wm.getDefaultDisplay () ;/ / get the window inside the screen
Cam ......

Reply:
reference to the 8th floor haojunming reply:
/ / Select the appropriate size
previewList sizeList = parameters.getSupportedPreviewSizes ();

/ / If sizeList only one we do not need to do anything, because then he has no choice
aif (sizeList.size ()> 1) {
Iterator itor = sizeList.iterator ();
while (itor.hasNext ()) {
Camera.Size cur = itor.next ();
if (cur.width> = PreviewWidth
&& Cur.height> = PreviewHeight) {
PreviewWidth = cur.width;
PreviewHeight = cur.height;
break;
}
}
}

/ / Set Preview (preview) dimensions
parameters.setPreviewSize (PreviewWidth, PreviewHeight);

/ / Set the picture size
parameters.setPictureSize (Picwidth, Picheight);

I was being given. Give me a Demo Why? Extremely grateful.
yali1014@163.com
Reply:
Why is not my resolve. .
Reply:
reference to the 12th floor xyl1014 reply:
Quote: references to the 8th floor haojunming reply:

/ / Select the appropriate size
previewList sizeList = parameters.getSupportedPreviewSizes ();

/ / If sizeList only one we do not need to do anything, because then he has no choice
aif (sizeList.size ()> 1) {
Iterator itor = sizeList.iterator ();
while (itor.hasNext ()) {
Camera.Size cur = itor.next ();
if (cur.width> = PreviewWidth
&& Cur.height> = PreviewHeight) {
PreviewWidth = cur.width;
PreviewHeight = cur.height;
break;
}
}
}

/ / Set Preview (preview) dimensions
parameters.setPreviewSize (PreviewWidth, PreviewHeight);

/ / Set the picture size
parameters.setPictureSize (Picwidth, Picheight);

I was being given. Give me a Demo Why? Extremely grateful.
yali1014@163.com



Remove the break
Reply:
Because some phones are put in ascending order of size, some descending, descending, whether large or small to arrange when you are only executed once, descending is no problem, but encountered phone is in ascending order, then it is easy to just get the smallest problem, you can print out the data the whole look, multiple phone comparison
Reply:
You can get to the data

No comments:

Post a Comment