Saturday, 18 July 2020

What is Image Stabilization? OIS and EIS explained.

Hi Guys,
Today I'm going to talk about image stabilization, what are OIS and EIS? How these works and What are the advantages of having it? So read the blog till the end.

What is Image Stabilization in smartphones?


If we go with the Wikipedia definition, the image stabilization is the family of techniques which reduces the blurring associated with the motion of the camera or other imaging device during exposure.

Got It ??? NAH !!!

Let me explain. Suppose you have to build a very basic camera from scratch. I know, I know you can't, that's why I said SUPPOSE😜. Now when you have built it, you wanted to capture some photos from it, right? After clicking some photos you'll definitely see the captured images are not good. These came out to be blurry. So, how does this happen? This happens because of the slightest movement of the camera.
The Camera captures the images when it is exposed to light. So, with the slightest movement of your camera, its exposure to light varies and the consequence will result in smear images. 
Without stabilization, your snaps and selfies can come out a blurred mess and videos looks like they have been shot for an 80s B-movies. This is something that today's generation doesn't want it to happen 😁.



That's why image stabilization is increasingly one of the fundamental building blocks of a great smartphone camera.

Now let's understand what is OIS?


OIS stands for Optical Image Stabilization, its a hardware solution that uses a micro-electromechanical system gyroscope to detect movement and adjust camera system. For example if you are holding a smartphone and your hand move slightly to the left, OIS will pick up on this and shifts the camera slightly to right. This is to counteract the movement.

Here is the example of tiny OIS element of a phone camera module. See how the top portion of the lens assemble can move independently of the image sensor.



Being a hardware solution it doesn't require any cropping of image, meaning the phone uses a full sensor readout to capture the photos. Constructing good OIS hardware isn't cheap. This will add more bills to the material cost and ultimately means you will pay more for your OIS equipped smartphone. 

OIS can be very useful when taking a video or still in low light. It particularly adepts in low light where the camera shutter can be open for longer duration. Without OIS, the results can be blurry.
OIS makes far more natural videos, as you are not applying any effects to the video.

Now let's understand what is EIS?


EIS stands for Electronic Image stabilization, this is an attempt to achieve the do's of OIS but with the help of software modification. This works by utilizing your smartphone's accelerometer to detect small movement. Now one question would have probably popped up on your mind is How does this EIS actually work?

So when you are using EIS, your camera zooms in and then it uses the extra room it now has around the edges to try and match every frame of the video with the frame before it. So EIS creates the illusion that the camera is staying still even if its actually moving. Its kind of cheat slightly.



With EIS enabled you no longer see the full sensor in the output. The edges of the sensor are moved like a buffer zone.


Nowadays smartphones are coming with HIS means Hybrid Image Stabilization. It is a combination of OIS and EIS. So you will get the best of both worlds.

But if you had a choice to pick between OIS and EIS, pick a phone which offers hardware-based solution i.e you should pick OIS equipped phones. As it will make your videos to look less artificial and far more effective for still images.


Thank you for Reading,
Swetabh

Friday, 17 July 2020

World's First Rotating camera Smartphone | Vivo X50 PRO

Hi Guys,
Today I am going to talk about the world's first rotating camera smartphone i.e non-other than Vivo X50 Pro.

                                              
Generally in the smartphone market, there are two kinds of companies. One, which waits for the other to introduce new and cool features before putting them into their smartphone and there is a second kind who always tries to be the first.

And we can firmly say that Vivo falls into the latter category. They were the first who introduces completely fullscreen phones. The first to use an In-display fingerprint scanner, the first to bring the motorized pop-up camera. Now here they are claiming the next big thing yet again for the smartphone.

Now if someone asks me how the 2020 flagship smartphone should look like, I 'll probably show them this pic.


It got a superb 6.56'' inch, 1080p Super AMOLED display, a fluid 90Hz refresh rate, curved display edges, and a little hole punch camera in the corner. The display is bright and has even smaller bezel than OnePlus 8.



When you look at this phone from the backside, it completely looks alien as it is from another planet.This is because of its stunning camera setup. It has 48MP main big camera, 2X Zoom camera for taking a portrait, an 8MP UltraWide camera, and a 5MP optical zoom camera at the bottom. All these 3 secondary cameras are fairly ordinary-sized, but this Main Camera is just enormous. You could probable live in there 😁.

They call this THE GIMBAL CAMERA. And when I say GIMBAL you would probably immediately think of a smartphone stabilizer. The objective of stabilization is to make sure the camera itself is moving as little as possible. So to achieve this stabilization, there are two existing ways the company uses it. 


The first is the Electronic image stabilization and the second is the Optical image stabilization.
We will talk about these two stabilization techniques in a separate blog later now let's continue to concentrate on this GIMBAL part. So what exactly Vivo did to its camera. They have taken OIS (Optical Image Stabilization) to a completely new level. So first of all the camera doesn't just shift around in a flat plane UP and DOWN, LEFT and RIGHT. The Camera actually rotates. So when we actually move or shake our phone, its camera has the ability to correct itself. This ability enhances its OIS to 3 times. This is the first of its kind.


There is another perk to this GIMBAL system when you take photos on low light conditions. Most of the phones will fall apart, they will struggle to piece together the frames needed for stabilization. But because Vivo's got this GIMBAL fall on it, it doesn't need that EIS (Electronic Image Stabilization) that much. It enhances the stability and clarity of the night scene photos by extending the exposure time through F1.6 Aperture and leveraging the AI noise cancellation algorithm at the low level.



The Vivo X50 also comes with some pretty cool features, such as style mode when you are taking pictures in night mode. You can pick between four different modes and each mode produces its own distinct takes on the same scene. It has a rainbow mode and it also has something interesting which Vivo called it Movie Camera. It locks onto the subject and keeps it in a frame at all times.

With all the great and innovative features, there are few cons of this product as well. Like we don't get the IP rating, we don't get the wireless charging and we don't get the latest snapdragon 865 chipset.
Yeah, It doesn't have the so-popular snapdragon 865, but it uses Qualcomm's Snapdragon 765 chipset instead. But don't worry Snapdragon 765 is not that slow what you are thinking. This phone comes with 5G connectivity and super-fast 33W charging. Vivo has managed to fit not only 4315mA battery but also the entire GIMBAL system into the phone that's 8mm thick.

I don't know whether or not it turns out into a huge success, but I do know that it has started a new trend that's going to benefits all smartphones.

Let me know your thoughts in the comment section.


Thanks for reading,
Swetabh

Thursday, 16 July 2020

What happens to running AsyncTask when Activity Changes ?

Hi Guys,
Today I am going to discuss the topic of what will happen to the on-going/ running async task when the activity changes.

AsyncTask is used to perform intensive tasks off the UI thread. It is defined by a computation that runs on a background thread and publishes the result in Main Thread or UI Thread.

If you start an AsyncTask inside an Activity and you rotate the device, the Activity will be destroyed and a new instance will be created.

Similarly, if user navigates to another activity, current activity will be destroyed or go in background activity stack and new activity would be in the foreground.

But the AsyncTask will not die. It will go on living until it completes. And when it completes, the AsyncTask won't update the UI of the new Activity. Indeed it updates the former instance of the activity that is not displayed anymore. This can lead to an Exception of the type

java.lang.IllegalArgumentException: View not attached to window manager if you use, for instance, findViewById to retrieve a view inside the Activity.

To resolve this problem, one option is to use IntentService along with a BroadcastReceiver to deliver result.

Another option is to run AsyncTask into worker fragment, as fragment is the cleanest way to handle configuration changes because fragment has the ability to retain their instances simply by calling setRetainInstance(true) in one of its lifecycle methods.


Thank you for Reading,
Swetabh


Wednesday, 15 July 2020

What happens when you press power button of your Android phone? | How Android boots up?

Hi Guys, 
In this blog, I am going to talk about, how your android phone starts when you press the power button.
Or in short I can say that how Android boots up.

Lets get started.


So what exactly is the boot-up process?


In Computer terminology booting up is a process of starting of computer till it can be used. It can be initiated by hardware such as button press or by software command.


As you can see from the diagram, the android boot-up process consists of 5 main stages:
  1. Boot ROM and Bootloader
  2. Kernel
  3. Init process
  4. System Server and Managers
  5. Launcher
1. Boot ROM and Bootloader
    When we press the power button the BOOT ROM starts executing from a predefined location which is hardwired into the ROM. It loads the Bootloader into the RAM and starts executing.
The bootloader is a small program that does hardware initialization, reading Linux kernel and loading it to the RAM. It setups the initial register and the command line arguments for Linux kernel and jumps to the kernel.
The bootloader can be found at :

<android source>/bootable/bootloader/legacy/usbloader

Bootloader executes in two stages :
  • -> It detects external RAM and loads a program that will help in the second stage.
  • -> The bootloader set up the network, memory, etc which require to run the kernel. 

2. Kernel :
    The bootloader loads kernel binary onto memory and then it executes it. The first hardware-independent piece of code that runs in the kernel is start_kernel(). As the kernel launches, it starts to set up cache, protected memory, scheduling and loading drivers, starts kernel daemons, mount root file system, initializing I/O, starts interrupts and initializes process table. When the kernel finishes the system setup, it looks for "init" in the system files and launch the root process of the System.

3. Init Process: 
    The third stage is the init process. It is the very first process or root process or we can say it is the grandfather process of all processes. It has two main responsibilities.
  1. Mount directories like /sys, /dev , /proc.
  2. Runs init.rc script that resides at <android source>/system/core/rootdir/
The rc file is written in init's own language. Init parse this rc file and launch the Zygote process. Many Linux daemons are started by init such as usbd , installed, adbd, etc. At this stage, you can finally see the Android logo on the screen.

4. Zygote :
    If init is called as the grandfather of all processes, then Zygote is the father of all processes. In Java separate virtual machine(VM) will popup for each separate app. But in the case of Android, VM should run as quick as possible. Now here one question comes in our mind that, for several apps, several instances of a virtual machine would be launched? This would consume a lot of memory. So to overcome this problem Android OS has a system called zygote. It enables code sharing across Dalvik Virtual Machine, thus achieving a lower memory footprint and minimal startup time. Zygote is a daemon started by init process. 
Role of Zygote process :
  1. registerZygoteSocket() : It register a server socket for zygote command connection.
    It keeps polling a socket /dev/socket/zygote. When you launch an Application, the request to create a new process comes from system_server to zygote on this socket.
  2. preloadClasses() : It is a simple text file that contains a list of classes that need to be preloaded.
  3. preloadResources() : Everything that is included in the android.R file will be included with this method.
5. System Server and Managers :  
    After zygote preloads all the classes and resources, the Zygote forks a new process to launch system server. The system server is the core of the Android system. The main entry point from Zygote is new SystemServer().run(). The first thing that happen is the SystemServer will load a native library called android_server, that provides interfaces to native functionality. After setting up the native services it creates a server thread. This thread will start the remaining services like bootstrap services, core services, and other services. Each service is running in a separate Dalvik thread in SystemServer. Once the system services are up and running in memory, Android has completed the boot process. At this time standard "ACTION_BOOT_COMPLETED" broadcast will be fired.


Thanks for reading,
Swetabh

Tuesday, 14 July 2020

Introduction | Getting and leaving my first job | Currently where I am.

Hi Guys,
I am Swetabh Suman. I am from Dhanbad Jharkhand. I have completed my B.Tech from Gandhi Institute of Engineering and Technology (GIET, Gunupur) in 2015 from Computer Sc. department.
After completing my Engineering degree I came to Bangalore in a hope that I 'll get a decent job.
Till this, you come to know that I was basically an unemployed Graduate.

For a fresher getting a job in IT is much more difficult. You should have good knowledge over your domain, your aptitude and English should be strong, you should have good knowledge of any of the programming languages and last but not the least you should have at least 2-3 years of working experience 😜(just kidding). Then only there will be a chance that you 'll get a job. 

Oh! and I almost forgot one thing, you have to compete with thousands of candidates for a few of the vacant positions. So you need luck as well as hard work. Or I can say 80% of luck and 20% hard work 😅.

Anyways I was lucky enough to get a job within 40 days of my search. But this "lucky job" didn't last long, and I was out from it after 5 months of my working 😔. The reason for leaving was, that company had a bond of 3 years in which they will keep all your original certificates so that you cannot leave them just random. Also, they were not paying me properly meaning to say that they have shown me a dream that I 'll get 12 lacs by the end of 3rd year. Moreover, they were paying the amount in hand to hand cash.

Let's see how they have shown me this dream. For the 1st Year, I 'll have a package of 3 LPA. From 2nd year onwards I'll get a hike and my package will become 4 LPA and finally, after next hike, I'll have the package of 5 LPA. So, in total, I'll be having 12 Lacs by the end of 3 years(3 + 4 + 5 = 12). This seems really good on paper but in actual it is completely different. For the first 3 months, you'll be paid 10k after 3 months this income will increase to 15k. Now you might think that having 3 LPA package how the company will pay the only 15k. It should be 25k or 21k (after deduction). But here's the trick, they will keep that 10k in the form of variable pay. This variable pay is something that you will get only when you are in a client place. Other than that forget about that money.

After that, I joined a different company and started my work from there.
5 years have been passed. Now I am Sr. Software Engineer working in Bangalore location. My work includes AOSP framework customization, developing Android applications, and many more things.

What is Ashmem?

ashmem (Anonymous shared memory subsystem) is a concept which is similar to POSIX SHM (Shared Memory). The difference is, ashmem claims that it overcomes the problem of memory leaks. ashmem is not available for Android applications, but they are used by the low-level system software/processes. The components of System Server like SurfaceFlinger, AudioFlinger, etc use ashmem for IPC. ashmem is fast. Another example where ashmem is used is, the Virtual Machine. When .oat code is provided to the VM using ashmem. When a process wants to communicate with another process, the process creates a shared memory region, and then shares the file descriptor of that memory region with the other process with which it wants to communicate. This file descriptor is sent to other process via Binder. The system processes rely ashmem through IMemory interface, which is not available or not exposed to the app developers.

ashmem also does memory management, by shrinking or expanding the memory area as needed. When the system needs more memory, it shrinks its area and releases memory for the system. If a shared memory area is marked as pinned, then that area can't be released at any circumstance. ashmem uses reference counting to destroy memory regions, when the processes referring to them have exited.

Basically, ashmem is a way used by the system level processes, not by application processes for IPC.

Ashmem supports a number of ioctl calls such as ASHMEM_SET_NAME, ASHMEM_GET_NAME, ASHMEM_SET_SIZE, ASHMEM_GET_SIZE, ASHMEM_SET_PROT_MASK, ASHMEM_GET_PROT_MASK, ASHMEM_PIN, ASHMEM_UNPIN, ASHMEM_GET_PIN_STATUS, ASHMEM_PURGE_ALL_CACHES

Kernal can discard unused shared block of memory when under pressure. Its implementation can be found at mm/ashmem.c with include at include/linux/ashmem.h

What is Image Stabilization? OIS and EIS explained.

Hi Guys, Today I'm going to talk about image stabilization, what are OIS and EIS? How these works and What are the advantages of having ...