Inspecting Wall Cracks: A Developer's Guide to Cognitive Actions

22 Apr 2025
Inspecting Wall Cracks: A Developer's Guide to Cognitive Actions

In the world of construction and maintenance, identifying and assessing wall cracks is crucial for safety and structural integrity. The stphtan94117/wall_crack_inspection API integrates advanced image analysis capabilities to efficiently inspect wall cracks in images and videos. By leveraging pre-built Cognitive Actions, developers can enhance their applications with powerful inspection features, saving time and resources while improving accuracy.

Prerequisites

Before you start using the Cognitive Actions for wall crack inspection, ensure you have the following:

  • API Key: Sign up for the Cognitive Actions platform and obtain your API key to authenticate your requests.
  • Setup: Familiarize yourself with basic API request structures, as you'll be using HTTP requests to communicate with the actions.

Authentication typically involves including the API key in the request headers, ensuring that your application can securely access the Cognitive Actions services.

Cognitive Actions Overview

Inspect Wall Cracks

The Inspect Wall Cracks action performs an analysis of wall cracks present in images or videos, providing insights based on size, confidence thresholds, and various configurable parameters.

  • Category: Image Analysis

Input

The input schema for the Inspect Wall Cracks action requires the following fields:

  • file (required): A valid URI pointing to the image or video to be analyzed.
  • size (optional): The inference size can be set to "640", "720", or "1280". Default is "640".
  • hideLabels (optional): Set to true to hide labels in the output. Default is false.
  • iouThreshold (optional): The Intersection over Union (IoU) threshold for Non-Maximum Suppression. Must be between 0 and 1 (default: 0.45).
  • lineThickness (optional): Thickness of polygons in pixels (1-10, default: 3).
  • hideConfidence (optional): Set to true to hide confidence scores in the output. Default is false.
  • confidenceThreshold (optional): Minimum confidence score for detections (0-1, default: 0.25).

Example Input:

{
  "file": "https://replicate.delivery/pbxt/JoHUpLB5lMldAbLkPgWKEu40CNMiJ6YB30o04lZLbqvCDdp1/IMG_0537.MOV",
  "size": "720",
  "hideLabels": false,
  "iouThreshold": 0.45,
  "lineThickness": 3,
  "hideConfidence": false,
  "confidenceThreshold": 0.25
}

Output

The output will typically return a link to the processed video or image with annotations showing the detected cracks based on the configured parameters.

Example Output:

https://assets.cognitiveactions.com/invocations/1c12ab8c-7619-4498-8c1a-73804ec613c1/d1af0b3e-8e17-4913-bd97-b6a85aa076a9.mp4

Conceptual Usage Example (Python)

Here’s how you might implement a call to the Inspect Wall Cracks action using Python:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "0737392b-ae34-44f5-bc26-66570235e3c0" # Action ID for Inspect Wall Cracks

# Construct the input payload based on the action's requirements
payload = {
    "file": "https://replicate.delivery/pbxt/JoHUpLB5lMldAbLkPgWKEu40CNMiJ6YB30o04lZLbqvCDdp1/IMG_0537.MOV",
    "size": "720",
    "hideLabels": false,
    "iouThreshold": 0.45,
    "lineThickness": 3,
    "hideConfidence": false,
    "confidenceThreshold": 0.25
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this code snippet, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The payload should match the example input structure provided for the Inspect Wall Cracks action.

Conclusion

The Inspect Wall Cracks Cognitive Action offers developers a straightforward way to integrate advanced wall crack inspection capabilities into their applications. By utilizing this action, you can enhance your app's functionality, streamline inspection processes, and ensure safety in structural assessments. Consider exploring additional use cases where image analysis can provide value, and start building smarter applications today!