Get started

This API is designed for the automatic detection and rating of construction defects, particularly in roads and highways. It processes images or video frames to identify defects like corrosion, cracks, abnormal spacing, functional disorder of bearings, and spalling/exposed rebar, along with their associated ratings. The goal is to assist engineers, inspectors, and organizations in assessing and monitoring the condition of infrastructure.


The API is customizable to adapt to various use cases and can be fine-tuned for different types of construction defects or specific classification needs. Whether it's for large-scale projects or smaller infrastructure assessments, the API's flexibility allows developers to modify and integrate it into their own workflows easily.


To use this API, you need both an API key and an API password.

You can sign up for your API credentials on our API platform.
Note: There are usage limits on the default API account. To extend your API usage, please contact us for assistance.


Try It Now

Examples:

Disclaimer: This system detects defects on roads and highways. Filtered images may not show correct results, but direct API usage works for all elements.


Drag image file here or

Stylized mountain icon

Installation

To install the API client, you can use pip (Python's package manager). Ensure you have Python installed on your system. Run the following command in your terminal or command prompt:


This package requires Python 3.7 or higher and will automatically install all required dependencies.

                
                    pip install smretrofit
                
            

After installation, you can import the API client into your Python scripts and start making requests. Ensure that you have the correct authentication credentials (API key and password) to interact with the API successfully.


Parameters

To detect construction defects and ratings, make a POST request to the following URL:
https://api.somikoron.ai/api



CLASS PARAMETERS

Following Paramiters are for API Class

Field Type Default Min/Max Description
url String https://api.somikoron.ai/api/ NA The API endpoint URL.
auth_key String NA NA Your API key for authentication.
auth_pass String NA NA Your API password for authentication.
font_size Integer 7 0 - 15 (optional) The size of the font used for labels.
font_thickness Integer 3 0 - 10 (optional) The thickness of the font used for labels.
line_space Integer 10 0 - 50 (optional) The space between lines of text in the output.
detect_mode String "all" "all", "defect", "rating" The detect_mode for displaying selected bounding box in the output. Parameters are: "all", "defect", and "rating".
label_mode String "all" "all", "defect", "rating" The label_mode for displaying selected labels in the output. Parameters are: "all", "defect", and "rating".

IMAGE FUNCTION PARAMETERS

Following Paramiters are for image_data function

Field Type Default Min/Max Description
file_path String NA NA The path of the input video or image file to be processed.
save Boolean False True - False Indicates whether the rendered image will be saved.
output String "output/" NA The path of the output directory where the processed images or videos will be saved.

VIDEO FUNCTION PARAMETERS

Following Paramiters are for video_data function

Field Type Default Min/Max Description
file_path String NA NA The path of the input video or image file to be processed.
save Boolean False True - False Indicates whether the rendered image will be saved or not (True : False).
output String "output/" NA The path of the output directory where the processed images or videos will be saved.
temp String "temp/" NA The path of the temporary directory used for frame extraction during video processing.

VIDEO SAMPLE FUNCTION PARAMETERS

Following Paramiters are for video_data function

Field Type Default Min/Max Description
file_path String NA NA The path of the input video or image file to be processed.
save Boolean "False" True - False Indicates whether the rendered image will be saved or not (True : False).
sample Integer 3 1 - 100 Total number of frames to be processed as images from the video as demonstrates.
output String "output/" NA The path of the output directory where the processed images or videos will be saved.
temp String "temp/" NA The path of the temporary directory used for frame extraction during video processing.

Code Example

A basic code example is provided below to help you get started with using the API. This example demonstrates how to make a request to the API and process the results. You can customize it based on your specific needs.


import smretrofit as api
# Import smretrofit as 'api'
url = "https://api.somikoron.ai/api/"
# This is the API endpoint URL for sending requests
auth_key="your_api_key"
# Replace 'your_api_key' with the actual API key provided for authentication.
auth_pass="your_api_password"
# Replace 'your_api_password' with the actual API password provided for authentication.
api = api.Retrofit(url, auth_key, auth_pass)
# Initialize the API client with the URL, authentication key, and password
if __name__ == "__main__":
# Standard Python entry point, ensuring code runs only when the script is executed directly.
    file_path = "your_file"
# Path to your input file (image or video) that will be processed by the API.
    data = api.get_image_data(file_path, save=True)
# Processes the file and saves the output if save=True.
    print(data)
# Print the JSON data

Returned Data Example

The API will return a JSON object containing the detected class names and the result data for each processed frame. If the save parameter is set to true, the response will also include the rendered image data in base64 format.

                
                    [
     {'cls':
        {'0': 'defect_class_name', '1': 'defect_class_name', '2': 'defect_class_name', '3': 'defect_class_name', ...},
     'data': [
            {'box_xyxy': [x, y, x, y],
             'box_cls': 2,
             'box_conf': 0.851271390914917}
             ]
     },
     {'cls':
        {'0': 'rating_class_name', '1': 'rating_class_name', '2': 'rating_class_name', '3': 'rating_class_name', ...},
     'data': [
            {'box_xyxy': [x, y, x, y],
             'box_cls': 2,
             'box_conf': 0.851271390914917}
             ]
     },
]

As for the video, the JSON data will be structured as a list, where each item in the list represents a frame's data, ordered serially by frame.

Errors

The Construction Defect and Rating Detection API uses the following error codes:

Error Code Meaning
E000 Missing required parameters. This error occurs when one or more mandatory parameters are not provided in the request.
E001 Invalid or unknown auth_key. This error indicates that the provided API key is invalid or expired.
E002 Invalid auth_key for this domain. This error occurs when an API key that is not authorized for the current domain is used.
E003 Invalid or unknown auth_pass. This error occurs when the provided API password is incorrect or expired.
E004 Unsupported file type. This error appears when the uploaded file is not a valid video or image format.
E005 Processing error. This error occurs when the API encounters an issue while processing the file, such as format incompatibility or server issues.