Tagged: google

0

Setting up MLKIT Firebase on Android

  Google launched MLKIT in it Google I/O 2018, this is one big step for any of the tech giant to make the trained model available for developers. Google went one step ahead and made it available on a mobile device that run locally and most f the without an internet connection. Although Amazon Web Services ( AWS ) also provide similar services through it Machine Leaning, Rekognition and other service but all of them require an internet connection and setting it up to work in real-time is a big pain.   There are few important points that Google’s ML took care of: Offline Real-time Accurate Platform Independent ( Android / IOS ) The above points will give MLKIT  worldwide acceptance. For a developer its a nightmare to train model, collect data sample and then make those trained available for use. After Tensors flow, this is the next big step of the company toward contributing to the community.   So what all MLKIT offers: For starting there are few ready-made models available for beginners:   Text recognition Face detection Barcode scanning Image labeling Landmark recognition However, you can also use your own Tensor Flows Lite models for taking care of custom scenarios.   In this blog, we will set up a sample app and configure it to use MLKIT and setup Face tracking. The Facetracking Model can detect the following things: Happiness  ( Range 0 – 1 ) Left & Right Eye closing ( Range 0 – 1 ) So in order to start, clone the following Repo:   https://github.com/ankitjamuar/android-firebase-mlkit.git , everything is working on it, you might have to setup google-services.json file.   Now open the project in Android studio, and connect your mobile and install the APK . The first screen will have a start button, press the start button and it will open an activity with camera preview. if you put a human face in front of camera you will be able to see MLKIT in action., it will show a bounding box around the face and values of Happiness, left & right eye open status. How to download google-services.json file. Go to Firebase console, create a project and select Android Project on the next page, next page will ask for package name and other optional detail. fill those detail and in next step, it will ask to download the google-services.json file. Put the file in “app” directory and sync it.        

Document Viewer 2

Embed Google Doc Viewer in your website

  Many a time you feel a need to show user-uploaded content on your website, but un-luckily browsers only support few document types, viz pdf & images. What if your user uploads documents ( doc, docx, xls, xlsx, ppt, pptx , psd, ai  and many more ). It will very good user experience if your website shows user content right on the user’s page without moving them away to any third party. Google Doc Viewer to rescue Google offer a free tool, that let you embed a pretty looking doc viewer that can serve all the file types mentioned above. You just need to add a single iframe and you are done. <iframe src=”http://meshcookie.com/wp-content/uploads/2017/08/file.docx&embedded=true” style=”width:1024px; height:700px;” frameborder=”0″></iframe> Note:  https://yourwebsite.com/file.docx, is the file being viewed. Just place this iframe on your website and the docx file will be viewable right on the page.   Few take aways CORS if you add iframe to your website and the URL of the iframe is a domain which is not part parent domain, then the browser will generate an error and you won’t be able to view file. In order to sort this issue make sure you add the param  <pre>embedded=true</pre>, so if you are embedding the viewer in your website then make sure you add this param. <iframe src=”https://docs.google.com/gview?url=https://yourwebsite.com/file.docx&embedded=true” style=”width:1024px; height:700px;” frameborder=”0″></iframe> URL Encoding   if the file that you want to show requires some added param for some version or maybe passing auth params, it is required to use URL encoding. var url = “https://yourwebsite.com/file.docx”; var accessibleUrl = encodeURIComponent(url);   People Using it There are a lot of people using it for there benefit, few include: Trello Eazespot