[Solved] How to measure height and width of object using camera?


I am answering this in context of:

I want to make this type of application not exactly same but quite same but for my requirement I want to measure my image height and width using camera.

You can get height and width of ImageView by using getWidth() and getHeight() through while this will not give you the exact width and height of the image, for getting the Image width height first you need to get the drawable as background then convert drawable to BitmapDrawable to get the image as Bitmap from that you can get the width and height like here

Bitmap b = ((BitmapDrawable)imageView.getBackground()).getBitmap();
int w = b.getWidth();
int h = b.getHeight();

or do like here

imageView.setDrawingCacheEnabled(true);
Bitmap b = imageView.getDrawingCache();
int w = b.getWidth();
int h = b.getHeight();

the above code will give you current imageview sized bitmap like screen shot of device

for only ImageView size

imageView.getWidth(); 
imageView.getHeight(); 

If you have drawable image and you want that size you can get like this way

Drawable d = getResources().getDrawable(R.drawable.yourimage);
int h = d.getIntrinsicHeight(); 
int w = d.getIntrinsicWidth();      

╔═══════════════════════════════╗   ^
║ ImageView    ╔══════════════╗ ║   |
║              ║              ║ ║   |
║              ║ Actual image ║ ║   |
║              ║              ║ ║   |60px height of ImageView
║              ║              ║ ║   |
║              ║              ║ ║   |
║              ╚══════════════╝ ║   |
╚═══════════════════════════════╝   v
<------------------------------->
                   90px width of ImageView

3

solved How to measure height and width of object using camera?