Hi,
This is a dev thread about the fight for the camera in ICS on the HTC Chacha.
I'm trying to load the libcamera.so and liboemcamera.so from a STock Sense Chacha rom (Gingerbread).
This afternoon I managed to fix the linker errors so camera.chacha.so loads libcamera.so.
I/CameraHAL( 98): camera_get_camera_info: id:0 faceing:0 orientation: 90
I/CameraHAL( 98): camera_get_camera_info: id:1 faceing:1 orientation: 270
V/CameraHolder( 1213): open camera 0
I/CameraHAL( 98): camera_get_camera_info: id:0 faceing:0 orientation: 90
I/CameraService( 98): Opening camera 0
I/CameraHAL( 98): camera_device open+++
I/CameraHAL( 98): Switching to HTC Camera: 0
I/QualcommCameraHardware( 98): openCameraHardware: call createInstance
D/QualcommCameraHardware( 98): createInstance: E
D/QualcommCameraHardware( 98): Storing the current target type as 3
D/QualcommCameraHardware( 98): constructor EX
D/QualcommCameraHardware( 98): startCamera E
E/QualcommCameraHardware( 98): Unable to determine the target type. Camera will not work
E/QualcommCameraHardware( 98): createInstance: startCamera failed!
D/QualcommCameraHardware( 98): ~QualcommCameraHardware E
Now the problem is that it gives an error in QualcommCameraHardware::startCamera: "Unable to determine the target type":silly:
I believe I know why though... I'll test another day.
Here it is:
In libcamera.so:
Failed to set default parameters?!
initDefaultParameters X
ro.board.platform
Storing the current target type as %d
persist.debug.camera.showfps
constructor EX
...
msm7k
qsd8k
msm7x30
...
I believe it uses the parameter ro.board.platform, which is ro.board.platform=msm7x27 in our CM9 to set the target, and that the allowed values are: msm7k, qsd8k and msm7x30.
I'll test altering the build.prop just to confirm it. If that is true, I'll have to find a way to fix that...
Anyway, I'm pretty happy about that, it's a step!
Yes!! I have managed to work around the target error!
DEBUG/QualcommCameraHardware(98): Storing the current target type as 0
Here is a logcat: http://logcat.miui.us/907002
The camera app still crashes... Idk what is the relevant error. I see no preview.
Maybe:
167: 07-11 01:54:31.381: ERROR/mm-camera 7x-vfe(98): Received VFE start ACK!!! This is a user preview start.
Thanks for working on this problem!
I use CM7 and the camera really costs me nerves there. With Pro Paint Camera I found an app that does not crash soo often, but still it is not 100% perfect (as images are 90° rotated and you can't make videos).
So any improvement on that camera issue is good news!
Note to self:
DEBUG/Camera(828): app passed NULL surface
ERROR/mm-camera 7x-vfe(98): Received VFE start ACK!!! This is a user preview start.
Those same messages are shown in with CM9 + Aria's libs (which works OK) and in CM9 + stock libs (which doesnt work), so I guess they are irrelevant.
Logcats of opening the camera:
Chacha CM9 Cam w/ Stock Libs: http://logcat.miui.us/907002 (Preview fails)
Chacha CM9 Cam w/ Aria Libs: http://pastebin.com/sFBWVc8g (Preview ok, pictures OK)
Chacha Stock GB w/ Stock Libs: http://pastebin.com/0A6BmtxQ (Everything works)
DEBUG/CameraSettings(828): Parameters:
Chacha CM9 Cam w/ Stock Libs, Params: http://pastebin.com/uyuKxjds
Chacha CM9 Cam w/ Aria Libs, Params: http://pastebin.com/CXemXgdt
Diff Aria params vs Stock: http://pastebin.com/GbcJB0Qf
All I can see from that are the memory leaks starting @ 0x3b2f0.
http://logcat.miui.us/907002 shows:
Code:
Code:
2047 private void setPreviewDisplay(SurfaceHolder holder) {
2048 try {
2049 mCameraDevice.setPreviewDisplay(holder);
2050 } catch (Throwable ex) {
2051 closeCamera();
2052 throw new RuntimeException("setPreviewDisplay failed", ex); // <------
2053 }
2054 }
Code:
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Make sure we have a surface in the holder before proceeding.
if (holder.getSurface() == null) {
Log.d(TAG, "holder.getSurface() == null");
return;
}
Log.v(TAG, "surfaceChanged. w=" + w + ". h=" + h);
// We need to save the holder for later use, even when the mCameraDevice
// is null. This could happen if onResume() is invoked after this
// function.
mSurfaceHolder = holder;
Code:
VERBOSE/camera(832): surfaceChanged. w=320. h=427
118: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): requested preview size 480 x 320
119: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): requested picture size 2560 x 1920
120: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): requested Fps Range min: 9000 x max: 30000
121: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): setGpsLocation: E
122: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): not defined touch-focus yet, or AP without touch-focus function
123: 07-11 01:54:31.151: INFO/QualcommCameraHardware(98): Before Setting coordinate x:240 y:160
124: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): setThumbnailSize w=640 h=480
125: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): virtual android::status_t android::QualcommCameraHardware::setParameters(const android::CameraParameters&), final_rc=0
126: 07-11 01:54:31.181: VERBOSE/camera(832): Preview size is 480x320
Vs w/ Aria libs: VERBOSE/camera(828): Preview size is 384x288 <-- smaller!! (would fit in the surface 427x320!)
preview-size-values=800x480,720x480,768x432,640x480,640x384,576x432,480x320,240x160
preview-size=480x320
./frameworks/base/libs/camera/CameraParameters.cpp :
Code:
597 void CameraParameters::setPreviewSize(int width, int height)
598 {
599 char str[32];
600 snprintf(str, sizeof(str), "%dx%d", width, height);
601 set(KEY_PREVIEW_SIZE, str);
602 }
603
604 void CameraParameters::getPreviewSize(int *width, int *height) const
605 {
606 *width = *height = -1;
607 // Get the current string, if it doesn't exist, leave the -1x-1
608 const char *p = get(KEY_PREVIEW_SIZE);
609 if (p == 0) return;
610 parse_pair(p, width, height, 'x');
611 }
./src/com/android/camera/Camera.java :
Code:
2200 // Set a preview size that is closest to the viewfinder height and has
2201 // the right aspect ratio.
2202 List<Size> sizes = mParameters.getSupportedPreviewSizes();
2203 Size optimalSize = Util.getOptimalPreviewSize(this,
2204 sizes, (double) size.width / size.height);
2205 Size original = mParameters.getPreviewSize();
2206 if (!original.equals(optimalSize)) {
2207 mParameters.setPreviewSize(optimalSize.width, optimalSize.height);
2208
2209 // If preview is running, stop preview and let startPreview call
2210 // this function again because we cannot change size on the fly
2211 if (mCameraState != PREVIEW_STOPPED) {
2212 stopPreview();
2213 startPreview();
2214 return;
2215 }
2216
2217 // Zoom related settings will be changed for different preview
2218 // sizes, so set and read the parameters to get lastest values
2219 mCameraDevice.setParameters(mParameters);
2220 mParameters = mCameraDevice.getParameters();
2221 }
2222 Log.v(TAG, "Preview size is " + optimalSize.width + "x" + optimalSize.height);
--> in the Logcat I see this line, from Camera.java:2222 :
07-11 01:54:31.181: VERBOSE/camera(832): Preview size is 480x320
Looking at Util.getOptimalPreviewSize --> maybe it tried to fit with a 90º rotation...
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** display.getHeight=480, display.getWidth=320
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=480, size.width=800
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=480, size.width=720
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=432, size.width=768
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=480, size.width=640
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=384, size.width=640
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=432, size.width=576
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=320, size.width=480
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** size.height=160, size.width=240
07-12 19:41:17.495: DEBUG/Util(810): ***ALEX*** optimalSize.height=320, optimalSize.width=480
07-12 19:45:14.977: INFO/power(169): *** set_screen_state 0
Where display is the screen (seen by the camera app) --> rotated 90º (but it's normal, as the App is launched rotated :-/ ).
All the preview sizes from the preview-size-values list are correct (landscape orientation).
Wondering if Change I7c0a2976: msm7x30: Camera HAL for HTC Sense devices (3/2) could have anything to do with the issue...
Tried either pref_camera_force_preview_default on and off, the same error.
I have also build and tested https://github.com/commonsguy/cw-advandroid/tree/master/Camera/Preview fails , and it fails too, so the issue is maybe not in the Camera app... (unless it is in the preview part of it)?
On the requested preview size, we get:
118: 07-11 01:54:31.151: DEBUG/QualcommCameraHardware(98): requested preview size 480 x 320
And the Aria libs are clearly substracting from both x and y to take into account the viewport is not as big as the whole screen, as we have to leave some margins to the UI and such, right? Maybe the trick is to adjust this in line 2205 and 2207 in Camera.java via a wrapper function, depending on the optimalSize() returned...
I wish I could set up a working compiling environment to help you, maybe once I'm back from holidays...
Keep it up and thanks for your hard work! Cheers!
Related
Hi All,
I am using DirectShow API for fetching camera contents on T-Mobile Shadow phone (manufacturer is HTC). I am having problem with the default Camera Zoom factor on this phone (when opened using DirectShow). I am trying to control the Zoom factor using IAMCameraControl interface. But I don't get any valid pointer for IAMCameraControl Inteface by using following code =>
$$$$$$$$$$$$$$$$$$$$$$$$$$$
long camera_flags = 0;
long zoom_val = 0;
IAMCameraControl* pCameraControl = NULL;
pVideoCaptureFilter->QueryInterface(IID_IAMCameraControl,(void**)&pCameraControl);
if(NULL == pCameraControl)
{
result = E_NOTIMPL;
goto error_handler;
}
$$$$$$$$$$$$$$$$$$$$$$$$$$$
Looks like IAMCameraControl has not been implemented on this particular phone. Is there any other way to change default Camera Zoom factor on HTC phones?
I came to know about HTC Camera DLL using this forum. How should I go about getting the Camera DLL and the documentation?
Thanks,
Shashi
I am working on a project on Augmented Reality with Android. The code captures the camera video, finds the marker and displays a cube on top of it. After this a motion vector (in the form of pixels moved in the x and y direction) is found. What I need to do is read the pixels from the GL layer and draw them again after moving them by the distance specified by the motion vector.
The GL layer is specified using the GLSurfaceView class which is a transparent layer. The problem I am facing is that when I use glReadPixels() to read the pixels and convert it into a 480x800 array (nexus one screen resolution), I get 3 different portions of the cube instead of one.
I intend to move the pixels by the motion vector after this and use glDrawPixels() to put the pixels back into the frame buffer
Please help me with the interpretation of the same. Is there something I am missing while using glReadPixels and also if there is some other function that will help me achieve the same. I was thinking of using glBlitFrameBuffer() but this is not supported by the android GL10 class.
I have attached the part of the code where I am reading the pixels and changing them to a 2D matrix along with the image of the pixels I reconstructed using MatLab.
Any help will be greatly appreciated.
Code:
gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1);
IntBuffer pixels = IntBuffer.allocate(384000);
gl.glReadPixels(0, 0, 800, 480, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE ,pixels);
File f = new File ("./mnt/sdcard/Sahiba_PixelData_" + flag + ".txt");
if(!f.exists())
f.createNewFile();
FileWriter fw = new FileWriter(f);
int pixelsArr [][] = new int [480][800];
//int temp[] = pixels.array();
int n=0;
for(int i=0; i<480; i++){
for(int j=0; j<800; j++){
pixelsArr[i][j] = pixels.get(n);
//temp[n + pixels.arrayOffset()];
fw.write(pixelsArr[i][j] + " ");
//fw.write(pixels.get(n) + " ");
n++;
}
//fw.write("\n");
}
Log.i("GLLayer", "Pixels reading and storing finished !!!");
}catch(Exception e){
Log.i("GLLayer","Exception = " +e);
}
The following code, is a simple example of programmatically "WITHOUT XML" translate animation, that works perfect on all versión bellow Android 4.4.2, but does nothing on Android 4.4.2. It's really making me crazy!
Any ideas why?
Tested and working OK on: EMULATOR AVD with 4.1.2 (API 16), EMULATOR AVD with 4.2.2 (API 17), EMULATOR AVD with 4.3.1 (API 18), Galaxy Tab 3 (4.1.2), Surprice, surprice.....works on my Galaxy NOTE with Omnirom 4.4.4
Not Working on: EMULATOR AVD with 4.4.2 (API 19), Galaxy S4 (4.4.2), Galaxy Note 3 (4.4.2)
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int myWidth = 1280;
int myHeight = 800;
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
int frameBufferWidth = isPortrait ? myHeight : myWidth;
int frameBufferHeight = isPortrait ? myWidth : myHeight;
Bitmap frameBuffer = Bitmap.createBitmap(frameBufferWidth, frameBufferHeight, Config.RGB_565);
graphics = new AndroidGraphics(getAssets(), frameBuffer);
fl = new FrameLayout(this);
ImageView mons= new ImageView(this);
mons.setImageBitmap(graphics.newImage("mons/mons01.png", ImageFormat.ARGB8888).getBitmap());
mons.setX(400);
mons.setY(200);
TranslateAnimation aniTrans = new TranslateAnimation(0, 0, 0, -200);
aniTrans.setDuration(5000);
mons.setAnimation(aniTrans);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
fl.addView(mons, params);
FrameLayout.LayoutParams flp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
this.setContentView(fl, flp);
mons.startAnimation(aniTrans);
aniTrans.startNow();
}
Issue Found!
HAVE FOUND THE PROBLEM, but NEED HELP TO SOLVED IT!
(NOTE: This only occurs in full java code. It doesn’t happened using XML file, what is not the case)
Now I should call this topic like:
ANDROID 4.4.2 CREATES A BLACK MASK OUTSIDE VIEW OBJECT BOUNDARY, ONLY DURING FULL JAVA CODE ANIMATIONS?
Why?:
Take a look to this new example code:
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
common = new Common(this, this);
FrameLayout.LayoutParams framelayoutparameter = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
/* I think that this is the line code (imageviewparamenter) were Android 4.4.2 FAILS during animation.*/
LayoutParams imageviewparamenter = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
/* No matter the size of the screen, Android 4.4.2 creates a black hole outside the image size,
* just during animation (see attached picture). Thats why animation dont show up, if the
* initial position (setX or setY) of the image, is outside the image boundary.*/
fl = new FrameLayout(this);
ImageView iv = new ImageView(this);
/* Image is located in the ASSET and is 100x100 pixels (non dpi dependable)
* "common" method use AssetManager to read the image file */
iv.setImageBitmap(common.newImage("iv_image.png", ImageFormat.RGB565).getBitmap());
iv.setX(50); // position show in the example
iv.setY(0);
fl.addView(iv, imageviewparamenter);
this.setContentView(fl, framelayoutparameter);
AlphaAnimation animation = new AlphaAnimation(0,1);
animation.setDuration(5000);
animation.setAnimationListener(this);
/* Also, "setAnimation(animation)" must be present, in order that
* Android 4.4.2 animates without skipping frames*/
iv.setAnimation(animation);
iv.startAnimation(animation);
}
Create a frame layout with a ImageView and alpha animation using pure java code. During animation, Android 4.4.2 (API19) is creating a black mask outside the ImageView size boundary, starting at x/y coordinates (0 + imageWidth / 0 + imageHeight), so if you initially place the image outside that coordinate, you don’t see any animation, just the original image at the end of the animation....
To recreate the issue, i have place the image in x = 50 . You would see that the half right side of the image is BLACK during Android 4.4.2 animation. You can recreate using emulator with any size of screen setup that you prefer. Using API 16,17,18, have no problem, but using API19, the black mask will make you crazy!
NOW, ANY IDEAS? or is a big bug on Android 4.4.2? or I just don’t see it?
Anyone?
SOLVED
! SOLVED !
For some reason, API19 programmatically pure java animations doesnt play very well with absolut settings, like setX() or setY(). Experts may take a look on this. API19 preffers to work with margins on the layout parameter side.
The following procedure, apply's to android 4.4.2. Of cource, it works on the others versions down and up, but you must change your way of thinking. You must place a imagen programmatically using layout parameters, so change:
Code:
iv.setX(50);
iv.setY(0);
to
Code:
lparam.setMargins(50, 0, 0, 0);
iv.setLayoutParams(lparam);
iv.requestLayout();
You must call "requestLayout()" to ensure that the new changes on the layout, will be commited when adding the view to the parent (fl).
Finnally, by mistake, I use "LayoutParams" instead of "FrameLayout.LayoutParams". This nothing have to do with the issue and was not affecting it, but is the correct way to define it, so change:
Code:
LayoutParams lparam = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
to
Code:
FrameLayout.LayoutParams lparam = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
The complete working code for any API is:
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Common common = new Common(this, this);
FrameLayout fl = new FrameLayout(this);
ImageView iv = new ImageView(this);
FrameLayout.LayoutParams flparam = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
FrameLayout.LayoutParams lparam = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
iv.setImageBitmap(common.newImage("100x100.png", ImageFormat.RGB565).getBitmap());
lparam.setMargins(50, 0, 0, 0);
iv.setLayoutParams(lparam);
iv.requestLayout();
fl.addView(iv);
this.setContentView(fl, flparam);
AlphaAnimation animation = new AlphaAnimation(0, 1);
animation.setDuration(3000);
iv.setAnimation(animation);
iv.startAnimation(animation);
}
On my Digma Plane 7594 3G tablet I have a problem with stretched (or compressed, depending on screen orientation) image.
"dumpsys display | grep DisplayInfo" (adb) output:
Code:
mDisplayInfos=
PhysicalDisplayInfo{600 x 1024, 60.0024 fps, density 1.33125, 426.386 x 149.411 dpi, secure true, appVsyncOffset 1000000, bufferDeadline 16666000}
mBaseDisplayInfo=DisplayInfo{"Встроенный экран", uniqueId "local:0", app 600 x 1024, real 600 x 1024, largest app 600 x 1024, smallest app 600 x 1024, mode 1, defaultMode 1, modes [{id=1, width=600, height=1024, fps=60.0024}], colorMode 0, supportedColorModes [], hdrCapabilities [email protected], rotation 0, density 213 (426.386 x 149.411) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666000, type BUILT_IN, state OFF, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}
mOverrideDisplayInfo=DisplayInfo{"Встроенный экран", uniqueId "local:0", app 600 x 960, real 600 x 1024, largest app 960 x 928, smallest app 600 x 568, mode 1, defaultMode 1, modes [{id=1, width=600, height=1024, fps=60.0024}], colorMode 0, supportedColorModes [], hdrCapabilities [email protected], rotation 0, density 213 (426.386 x 149.411) dpi, layerStack 0, appVsyncOff 1000000, presDeadline 16666000, type BUILT_IN, state ON, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS, removeMode 0}
I guess there is a problem with "app 600 x 960, real 600 x 1024" (in mOverrideDisplayInfo).
Is it possible to change "app" values to math "real" values (if that's the problem)?
I am using a bitmap to draw more than one drawing on the same canvas. Say, I am drawing lines, circles with different radii to the same canvas. My requirement is to add 2000 such canvas to my MapView. The image looks pixelated if I use 256x256 as bitmap resolution.
So I am using 1024x1024 as bitmap resolution for better quality. Now when I run this on Android devices with low memory, my app freezes and crashes.
Problem statement :
1. Bitmap size - 1024*1024 = works fine in devices having more memory like one plus devices but freezes on the low storage[less than 4 GB]
2. Bitmap size - 256 * 256 = works fine in both Android devices.
Here is the code Snippet Currently using to draw on canvas by using a bitmap.
Bitmap bitmap = Bitmap.createBitmap(1024, 1024, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// drawing circle
canvas.drawCircle(width/2, height/2, 2, paint);
// drawing line
canvas.drawLine(cx, cy, x2, y2, paint);
// Same canvas with different radius
canvas.drawArc(endgunRect, startAngle - 90, endSweep, false, paint);
Solution expected :
I need to load around 2000 devices on the map view of the app in all types of Android devices irrespective of devices storage capacity?
Could anyone advise is there any other approach we have than Bitmap on the canvas?