Skip to content

andrewabela/Image-Area-Calculator

Repository files navigation

API Documentation:

http://####:8080/calc-aria

Purpose:

This API endpoint is designed to calculate the area of items on a flat plane surface. It uses a combination of image processing techniques to identify regions of interest and adjust for the camera's angle in order to provide accurate area measurements.

Request Body:

The API expects a JSON body with the following fields:

cropping_points:

x1, y1: Coordinates of the top-left point of the desired image region.

x2, y2: Coordinates of the top-right point.

x3, y3: Coordinates of the bottom-right point.

x4, y4: Coordinates of the bottom-left point.

These points define a quadrilateral region that will be extracted from the input image.

aspect_ratio:

width: Desired width of the output image.

height: Desired height of the output image.

This specifies the aspect ratio of the output image after warping.

threshold:

A numerical value used to segment the image into foreground and background regions. Pixels with intensity values above the threshold are considered foreground.  

area_multiplier:

A multiplier used to adjust the calculated area of the identified regions. This can be helpful to calibrate the results to a specific unit of measurement (e.g., square meters).

return_image:

A boolean flag indicating whether to return the processed image along with the aria calculations.

base64_png or base64_jpeg:

A base64-encoded string representing the input image. Response:

Response:

The API returns a JSON object with the following fields:

detection_count:

Total number of distinct pixels detected in the post-processed image.

detection_percentage:

Percentage of the total image area covered by detected region in the post-processed image.

covered_area:

Actual area of detected regions, calculated using the provided area_multiplier.

masked_jpeg (Optional):

Base64-encoded JPEG image showing the region.

Example Request:

{
    "cropping_points": {
        "x1": 275,
        "y1": 1078,
        "x2": 2014,
        "y2": 642,
        "x3": 4177,
        "y3": 1304,
        "x4": 2096,
        "y4": 2084
    },
    "aspect_ratio": {
        "width": 4,
        "height": 5
    },
    "threshold": 45000,
    "area_multiplier": 0.02,
    "return_image": false,
    "base64_png": "hWbyKpB..."
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages