Writing a trigger to generate uuid in a table

If you never had a field containing uuid before in MySQL table, now you can add a new field default is null. Then create a trigger so that every time there’s a new record inserted, the uuid will be automatically generated for that row. Here’s how you write a trigger to add uuid to a field “user_api_key” in the table “api_users” If you run into this error, make sure you don’t duplicate the trigger. This version of MySQL doesn’t yet support ‘multiple triggers with the…

Continue reading »

Color Detection Programming

Today we’re going to use NodeJS to write a program that can detect colors from an image. User uploads an image, NodeJS will process the image on the Server side and response with a list of color RGB values. It will return predictions about the dominant colors in an image. We test with a US flag PNG image using NodeJS And the response from server is: Swatch { _rgb: [220, 4, 4], _population: 324, _hsl: [0, 0.9642857142857144, 0.4392156862745098] }, LightVibrant: Swatch { _rgb: [228, 70,…

Continue reading »

Calculating Bounding box for a face on an image

This time we’re using the Bounding box returned by Clarifai’s Face Model API . Google Vision and Amazon Face Detection Rekognition APIs are returning different type of data (x,y,width, height). Amazon Rekognition: left = image.width*BoundingBox.Left top = image.height*BoundingBox.Top   Based on the description Face Detection Model’s response on this page https://www.clarifai.com/models/face-detection-image-recognition-model/a403429f2ddf4b49b307e318f00e528b#documentation, we’ll calculate the top-left corner and bottom-right corner. given original image size 500 width x 333 height, the top-left coordinate of the image is (0.0, 0.0), and the bottom-right of the image is (1.0,…

Continue reading »

Face Detection Programming

Face Detector API and its docs are ready for deployment on github (master and dev-binh branches). The API is written in NodeJS. It’s been tested. Clients must pass a Base64 of a photo URL encoded. This API will return how many faces on a photos and bounding boxes of face areas. FaceDetector-rest Express Nodejs App Dependencies ========== “express”: “~4.14.1” “clarify”: “^2.2.0” “body-parser”: “~1.16.0” “jade”: “~1.11.0” ENVIRONMENT Variables Settings in .env CLARIFAI_API_KEY=ADD-YOUR-CLARIFAI-API-KEY-HERE (see Instruction below *) PORT = 8081 (or default 8080 if not set in…

Continue reading »

How to build a Chrome extension, Part 1: Loading a form in a popup window

Step 1: Get your URL ready make sure that you’ll be able to prove ownership of the site that hosts your web app. bookmark this page: https://chrome.google.com/webstore/developer/dashboard Step 2: Create a manifest.json file create a new directory on your local computer, create a text file named manifest.json and copy the following code into it, changing the italicized text to reflect your app feature. Step 3: Create images Your app requires icon 128px x 128px and tiny icon of 19px x 19px Step 4: Get the…

Continue reading »