Back to articles
AI & Cloud

Build an AI Agent for Automated Warehouse Management with Barcode Recognition and NocoDB Updates Using Qwen VL on VPS

Detailed guide to building an AI agent that automatically recognizes barcodes and updates inventory data into NocoDB using Qwen VL on a VPS.

DPTCloud Engineering4 min read
Build an AI Agent for Automated Warehouse Management with Barcode Recognition and NocoDB Updates Using Qwen VL on VPS

Image credit: 2857440 · Pixabay Content License

Build an AI Agent for Automated Warehouse Management with Barcode Recognition

In the digital age, effective and automated warehouse management is a key factor in helping businesses reduce costs, speed up processing, and minimize errors. An AI agent combined with a barcode recognition model like Qwen VL (from Alibaba Cloud) can automatically scan, analyze, and update inventory data into management systems such as NocoDB. This guide will walk you through building this system on a VPS with high RAM, suitable for self-hosting AI models.

Requirements and Environment Setup

To deploy the system, you need:

Install Required Tools

Run the following commands on the VPS to set up the environment:

# Update the system
sudo apt update && sudo apt upgrade -y

# Install Python and pip
sudo apt install python3 python3-pip python3-venv -y

# Create a virtual environment
python3 -m venv ai_stock_env
source ai_stock_env/bin/activate

# Install necessary libraries
pip install opencv-python numpy requests pillow qwen-vl

Set Up NocoDB and API

NocoDB is a self-hosted data management platform similar to Airtable. You can install it on your VPS or use the hosted version at nocodb.com.

Create Database Table in NocoDB

Set up a new table with the following columns:

Column NameTypeNotes
Product CodeTextProduct code
Product NameTextProduct name
QuantityNumberQuantity
Barcode ImageFileBarcode image
Last UpdatedDateUpdate time

Configure NocoDB API

Access the API Key in NocoDB and save it. Use this API to update data from the AI agent.

import requests
import json

# NocoDB configuration
BASE_URL = "https://your-nocodb-url.com/api/v1"
TABLE_ID = "your-table-id"
API_KEY = "your-api-key"

def update_nocodb(product_code, product_name, quantity):
    headers = {
        "xc-token": API_KEY,
        "Content-Type": "application/json"
    }
    data = {
        "Product Code": product_code,
        "Product Name": product_name,
        "Quantity": quantity,
        "Last Updated": "now"
    }
    response = requests.post(f"{BASE_URL}/tables/{TABLE_ID}/records", headers=headers, data=json.dumps(data))
    return response.status_code

Perform Barcode Recognition with Qwen VL

Qwen VL is a multimodal model that supports image recognition, including barcodes. Here’s an example of processing images from a camera and extracting barcodes:

from qwen_vl import QwenVL
import cv2
import numpy as np

# Initialize the model
model = QwenVL(model_name="qwen-vl")

# Capture image from camera
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
cv2.imwrite("barcode.jpg", frame)
cap.release()

# Recognize barcode
result = model.ocr("barcode.jpg", task="barcode")
if result:
    barcode = result[0]["text"]
    print(f"Detected barcode: {barcode}")
else:
    print("No barcode detected.")

Run the AI Agent Automatically

Run a script that automatically scans, recognizes, and updates data:

import time
import os
from datetime import datetime

# Main script
while True:
    # Capture image
    os.system("fswebcam -r 1280x720 --no-banner barcode.jpg")

    # Recognize barcode
    result = model.ocr("barcode.jpg", task="barcode")
    if result:
        barcode = result[0]["text"]
        # Assume product lookup logic
        product_name = "Product A"
        quantity = 100

        # Update NocoDB
        status = update_nocodb(barcode, product_name, quantity)
        print(f"Updated NocoDB: {status}")
    else:
        print("No barcode found.")

    # Wait 5 seconds
    time.sleep(5)

Testing and Troubleshooting

  • Barcode not recognized: Check lighting, image clarity, and barcode position.
  • NocoDB API errors: Verify API Key, URL, and table access permissions.
  • AI agent not running: Check logs, RAM usage, and service status.

References

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478