[Huawei Developers] Freemind R:
More information like this, you can visit HUAWEI Developer Forum​

Introduction:

HMS ML Kit features image super-resolution service which provides 1x super-resolution capability. This feature removes the compression noise of images to obtain clear images.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925075422.28808049217110858005519046846519:50511013022122:2800:CC68988BDC0C1384DC5D040C19BF3AF7533C2291C455E5943F9FDF02B351E79A.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925075422.28808049217110858005519046846519:50511013022122:2800:CC68988BDC0C1384DC5D040C19BF3AF7533C2291C455E5943F9FDF02B351E79A.png[/IMG]

Precautions:

1. Prior to the image super-resolution service, it is necessary to convert images into bitmaps in ARGB format. After

the service processes, the image output are bitmaps in ARGB format.

2. Maximum size of an input image is 1024 x 768 px or 768 x 1024 px. The minimum size is 64 x 64 px.

Integration:

1. Create a project in android studio and Huawei AGC.

2. Provide the SHA-256 Key in App Information Section.

3. Download the agconnect-services.json from AGCand save into app directory.

4. In root build.gradle

Navigate to allprojects > repositories and buildscript > repositories and add the below line.

maven { url 'http://developer.huawei.com/repo/' }

5. In app build.gradle

Configure the Maven dependency

implementation 'com.huawei.hms:ml-computer-vision-imageSuperResolution:2.0.2.300'
implementation 'com.huawei.hms:ml-computer-vision-imageSuperResolution-model:2.0.2.300'

Apply plugin

apply plugin: 'com.huawei.agconnect'

6. Permissions in Manifest

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Code Implementation:

Here is an image convertor application that uses HMS image super-resolution service. This application can select image from gallery and also can capture image. Follow the steps

1. Create an image super-resolution analyzer.

private void createAnalyzer() {
MLImageSuperResolutionAnalyzerSetting settings = new MLImageSuperResolutionAnalyzerSetting.Factory()
// Set the scale of image super resolution to 1x.
.setScale(MLImageSuperResolutionAnalyzerSetting.ISR_SCALE_1X)
.create();
analyzer = MLImageSuperResolutionAnalyzerFactory.getInstance().getImageSuperResolutionAnalyzer(settings);
}

2. Create an MLFrame object by using android.graphics.Bitmap.

MLFrame mlFrame = new MLFrame.Creator().setBitmap(srcBitmap).create();

3. Perform super-resolution processing on the image.

Task<MLImageSuperResolutionResult> task = analyzer.asyncAnalyseFrame(mlFrame);
task.addOnSuccessListener(new OnSuccessListener<MLImageSuperResolutionResult>() {
public void onSuccess(MLImageSuperResolutionResult result) {
// Recognition success.
Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show();
setImage(result.getBitmap());
}
}).addOnFailureListener(new OnFailureListener() {
public void onFailure(Exception e) {
// Recognition failure.
Toast.makeText(getApplicationContext(), "Failed：" + e.getMessage(), Toast.LENGTH_SHORT).show();
}
});

4. After the recognition is complete, stop the analyzer to release recognition resources.

private void release() {
if (analyzer == null) {
return;
}
analyzer.stop();
}

5. Capture picture from camera.

private void capturePictureFromCamera(){

if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
{
requestPermissions(new String[]{Manifest.permission.CAMERA}, MY_CAMERA_PERMISSION_CODE);
}
else
{
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}

}

6. Acceessing image from Gallery.

private void getImageFromGallery(){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, GALLERY_REQUEST);
}

Screen Shots:

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925092214.79725092748983717522280875936430:50511013022122:2800:31DDDEAB44A7B272B6EFCCDBDA8FA3894A8A4244C636A727E786F6A64F18AEA4.jpg"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925092214.79725092748983717522280875936430:50511013022122:2800:31DDDEAB44A7B272B6EFCCDBDA8FA3894A8A4244C636A727E786F6A64F18AEA4.jpg[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925091901.45998336270466183558283694877691:50511013022122:2800:48DF8C3187342B479DEFCCB8F7BF86B1E749C4B0A1BE964E27523CC90BA73392.jpg"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925091901.45998336270466183558283694877691:50511013022122:2800:48DF8C3187342B479DEFCCB8F7BF86B1E749C4B0A1BE964E27523CC90BA73392.jpg[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925092139.52325919590507638458782008055393:50511013022122:2800:94AD688DCF14949ACC5B9B6C18A9307C20CD91866A111200F7E948503F107E3D.jpg"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/745/226/2640091000001745226.20200925092139.52325919590507638458782008055393:50511013022122:2800:94AD688DCF14949ACC5B9B6C18A9307C20CD91866A111200F7E948503F107E3D.jpg[/IMG]

Conclusion:

Image super-resolution service is widely used in day to day life and supports in common scenarios like improving low-quality images on the network, obtaining clear images while reading news, improving image clarity of Identification Card etc.This service intelligently reduces the image noise and provides clear image without changing resolution.

Reference:

HMSCore-Guides