Vishwam Camera module for angular project
npm install vishwam-camera-lib-angular
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import {VishwamModule} from 'vishwam-camera-lib-angular';
@NgModule({
declarations: [
AppComponent,
HomeComponent
],
imports: [
BrowserModule,
AppRoutingModule,
VishwamModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
<lib-vishwam></lib-vishwam>
Import Vishwam Service and use the startCamera() method, It will return a JSON response.
The method startCamera() accepts two parameters
1. domain:
Vishwam backend domain URL - string
2. referenceId:
Reference Id of the transaction - string
The method makeRequest accepts four parameters
1. imageData:
Base64 encoded image data - string
2. contentType:
MimeType of the image
ex: "image/png" or "image/jpeg", ("image/png" is preferred)
3. domain:
Vishwam backend domain URL - string
4. referenceId:
Reference Id of the transaction - string
Example:
import { Component, OnInit } from '@angular/core';
import { VishwamService } from 'vishwam-camera-lib-angular';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor(private vishwam: VishwamService) { }
ngOnInit() {
}
// To Open camera, capture image, and make request
async openCamera() {
const response = await this.vishwam.startCamera("https://test-domain.example.com", "test26739994");
}
// To make request to vishwam using image
async makeRequestToVishwam() {
const response = await this.vishwam.makeRequest(imageData, contentType, "https://test-domain.example.com", "test27781763");
}
}