DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • 5 Ways Azure AI Search Enhances Enterprise RAG Architectures
  • Supercharge AI Workflows on Azure: Remote MCP Tool Triggers + Your First TypeScript MCP Server
  • Blueprint for Agentic AI: Azure AI Foundry, AutoGen, and Beyond
  • Azure AI and GPT-4: Real-World Applications and Best Practices

Trending

  • Integrating AI-Driven Decision-Making in Agile Frameworks: A Deep Dive into Real-World Applications and Challenges
  • A Scalable Framework for Enterprise Salesforce Optimization: Turning Outcomes Into an Operating System
  • Bringing Intelligence Closer to the Source: Why Real-Time Processing is the Heart of Edge AI
  • Observability in Spring Boot 4
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Exploration on Azure Computer Vision Model To Build AI-Ready Web Applications

Exploration on Azure Computer Vision Model To Build AI-Ready Web Applications

This article explains how to integrate computer vision SDK with JavaScript to develop custom models or use pre-built models to build intelligent web applications.

By 
Naga Santhosh Reddy Vootukuri user avatar
Naga Santhosh Reddy Vootukuri
DZone Core CORE ·
May. 15, 24 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
1.1K Views

Join the DZone community and get the full member experience.

Join For Free

The Azure Computer Vision model is a powerful tool for building AI-ready web applications. This model enables developers to extract insights and meaning from visual data and can be used to build a wide range of applications, from image classification and object detection to facial recognition and natural language processing. In this article, we will explore the capabilities of the Azure Computer Vision model and how it can be used to build AI-ready web applications. We will also discuss the benefits of using this model and provide a step-by-step guide on how to get started.

Capabilities of Azure Computer Vision Model

The Azure Computer Vision model is a cloud-based API that enables developers to analyze and understand visual data. This model can be used to:

1. Classify Images Into Different Categories

Azure Computer Vision can classify images into different categories such as objects, scenes, and actions. 

Ex: for the below picture, it will classify into the category Animal_dog Image from Google

Image from Google

2. Detect Objects Within Images

Azure Computer Vision can detect objects within images, including people, animals, and objects.

Ex: The below picture will detect the object apple and provide the response in the JSON as shown below. 

Image from Google

Image from Google

JSON
 
{
   "objects":[
      {
         "rectangle":{
            "x":730,
            "y":66,
            "w":135,
            "h":85
         },
         "object":"Apple",
         "confidence":0.98
      }
}


3. Recognize Faces and Extract Facial Features

Azure Computer Vision can recognize faces and extract facial features such as age, gender, and emotions.

Image from Microsoft

Image from Microsoft

JSON
 
{
    "faces": [
        {
            "age": 11,
            "gender": "Male",
            "faceRectangle": {
                "top": 62,
                "left": 22,
                "width": 45,
                "height": 45
            }
        },
        {
            "age": 11,
            "gender": "Female",
            "faceRectangle": {
                "top": 127,
                "left": 240,
                "width": 42,
                "height": 42
            }
        },
        {
            "age": 37,
            "gender": "Female",
            "faceRectangle": {
                "top": 55,
                "left": 200,
                "width": 41,
                "height": 41
            }
        },
        {
            "age": 41,
            "gender": "Male",
            "faceRectangle": {
                "top": 45,
                "left": 103,
                "width": 39,
                "height": 39
            }
        }
    ],
    "requestId": "3a383cbe-1a05-4104-9ce7-1b5cf352b239",
    "metadata": {
        "height": 230,
        "width": 300,
        "format": "Png"
    }
}


4. Extract Text From Images

Azure Computer Vision can extract text from images, including handwritten and printed text.

5. Generate Image Descriptions

Azure Computer Vision can generate image descriptions, including captions and tags.

Benefits of Using Azure Computer Vision Model

Using the Azure Computer Vision model can bring numerous benefits to your web application, including:

  • Improved user experience: By analyzing visual data, you can provide users with a more personalized and engaging experience.
  • Increased efficiency: Automating image analysis can save time and reduce manual effort.
  • Enhanced security: Facial recognition and object detection can be used to enhance security and prevent fraud.
  • Better decision-making: Extracting insights from visual data can help businesses make informed decisions.

You can explore and play with Azure custom vision models by navigating to the Azure AI | Vision Studio.

Step-By-Step Guide To Building AI-Ready Web Applications With Azure Computer Vision Model

Here's a step-by-step guide to building AI-ready web applications with the Azure Computer Vision model:

  1. Sign up for Azure: Create an Azure account and subscribe to the Computer Vision service by navigating to the AI Vision studio link. Copy Key and Endpoint which is used later in code to call computer vision client SDK.
  2. Choose a programming language: Choose a programming language such as Python, Java, or C# to build your application. I have used NodeJS for the code example below.
  3. Install the Azure Computer Vision SDK: Install the Azure Computer Vision SDK for your chosen programming language.
  4. Upload images: Upload images to your Azure storage account which you can use in your code to analyze it
  5. Analyze images: Use the Azure Computer Vision API to analyze images and extract insights.
  6. Integrate with your web application: Integrate the extracted insights with your web application to provide a more personalized and engaging experience 

The code below is written using NodeJS where I have used the computer vision client SDK to analyze an image that contains fruits and vegetables and provide output about detected objects and the response. 

JavaScript
 
'use strict';
var http = require('http');
var port = process.env.PORT || 1337;

const { ComputerVisionClient } = require("@azure/cognitiveservices-computervision");
const { ApiKeyCredentials } = require("@azure/ms-rest-js");

const key = '<subscription Key>';
const endpoint = '<computervision endpoint>';

const credentials = new ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': key } });
const client = new ComputerVisionClient(credentials, endpoint);

http.createServer(async function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    //res.end('Hello World\n');

    // Define the URL of the image  uploaded to storage account which you want to analyze
    const imageUrl = '<imageUrl>';

    // Call the function to analyze the image
    const result = await analyzeImage(imageUrl, { visualFeatures: ['Objects'] });

    // Assuming 'result' is the response from the analyzeImage call
    if (result.objects && result.objects.length > 0) {
        const fruitsAndVeggies = result.objects.filter(obj => obj.object.toLowerCase().includes('fruit') || obj.object.toLowerCase().includes('vegetable'));
        console.log("Detected fruits and vegetables:", fruitsAndVeggies);
    } else {
        console.log("No fruits or vegetables detected.");
    }

    // Send the analysis result as the response
    res.end(`Image Analysis Result:\n${JSON.stringify(result, null, 2)}`);
}).listen(port);

async function analyzeImage(url) {
    try {
        const result = await client.analyzeImage(url, { visualFeatures: ['Categories', 'Description', 'Objects'] });
        console.log("Image analysis result:", result);
        return result;
    } catch (error) {
        console.error("An error occurred while analyzing the image:", error);
        return error;
    }
}


Conclusion

The Azure Computer Vision model is a powerful tool for building AI-ready web applications. By leveraging this model, developers can extract insights and meaning from visual data and provide users with a more personalized and engaging experience. With vast areas, numerous benefits, and ease of use, the Azure Computer Vision model is an ideal choice for businesses looking to build intelligent AI-ready web applications.

Visit here for more details about learning Azure Computer Vision.

Happy coding !!!

AI azure

Opinions expressed by DZone contributors are their own.

Related

  • 5 Ways Azure AI Search Enhances Enterprise RAG Architectures
  • Supercharge AI Workflows on Azure: Remote MCP Tool Triggers + Your First TypeScript MCP Server
  • Blueprint for Agentic AI: Azure AI Foundry, AutoGen, and Beyond
  • Azure AI and GPT-4: Real-World Applications and Best Practices

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook