Are you searching for a fast, efficient, and powerful way to integrate world-class image recognition capabilities into your software projects? Do you want to leverage the power of deep learning but find yourself daunted by model deployment, performance optimization, and complex programming interfaces? We are proud to introduce ShiTuApi—a powerful C API library designed for developers, built upon Baidu's PaddlePaddle vision suite.
1. What is ShiTuApi? — A Bridge Connecting AI and Reality
ShiTuApi is a C API dynamic-link library (DLL) that has been deeply refactored and re-engineered based on Baidu's PaddleClas vision foundation model library. We have preserved its world-class core algorithms for image recognition (feature extraction) and object detection, while wrapping them in a comprehensive, engineering-focused package. Our goal is to solve the common problem of "difficult implementation" for AI models in real-world projects.
Our objective is crystal clear: To enable every developer, regardless of their AI background, to integrate top-tier AI vision capabilities into their applications as easily as calling a regular function.
Core Tech Stack:
- AI Core: Baidu PaddleClas Recognition Suite
- Inference Engine: Paddle Inference (v3.0.0-beta1)
- Core Language: High-performance modern C++ (17/20)
- Interface Language: Standard, cross-platform, cross-language C API
- Core Dependencies: paddle_inference library, OpenCV (for image processing), yaml-cpp (for configuration parsing), FAISS (for vector retrieval)
Important Note: The current public release of ShiTuApi is focused on maximum optimization and stable operation in CPU environments. If you require support for NVIDIA GPUs, domestic NPUs, or other AI chips, we offer professional commercial customization services.
2. What Pain Points Do We Solve? — More Than Just Improving Accuracy
Traditional AI project development often gets stuck in a "vicious cycle of chasing accuracy," where engineers spend vast amounts of time on data collection, annotation, model training, and tuning, while neglecting the engineering challenges of applying the model in the real world. ShiTuApi was born to solve these pain points!
| Pain Point | Traditional Development Method | ShiTuApi's Solution |
|---|---|---|
| Complex Deployment & Dependency Hell | Requires manual configuration of Python/Conda environments and installation of numerous libraries (PyTorch/TensorFlow, OpenCV, etc.). | Zero-Dependency, Green Deployment. Simply use a few DLLs and model folders to call the API directly from any language supporting a C interface (C#, C++, Java, Python, etc.), with no need to configure a complex AI environment. |
| The Challenge of Recognizing Massive Numbers of Small Objects/SKUs | Training a huge classification model for thousands of products is not only costly, but adding a new category requires complete retraining. | Image Search (Vector Retrieval). You only need one image per product to build an index, enabling precise recognition. Adding new categories is as simple as adding new images to the index, with no model retraining required. |
| High Barrier to Performance Optimization | Requires in-depth knowledge of CUDA programming, TensorRT optimization, and MKL-DNN instruction sets to maximize hardware performance. | Out-of-the-Box High Performance. ShiTuApi has deep, built-in optimizations for CPU environments. Just set enable_mkldnn: true in config.yaml to enjoy blazing-fast inference speeds. |
| Unfriendly API & Lack of Engineering-focused Encapsulation | Directly using inference framework APIs requires writing extensive C++ or Python code for image preprocessing, post-processing, and thread management. | Minimalist Functional Calls. A single function like ShiTuApi_SearchByPath() handles the entire process, from loading an image to returning recognition results. All complexity is hidden within the API. |
| Poor Support for Multithreading & High Concurrency | Developers must handle thread locks and the thread-safety of model instances themselves, which is extremely error-prone. | Built-in Thread-Safety Mechanisms. Each API instance (Handle) is protected by an internal mutex, allowing you to safely call it from multiple threads and easily build high-concurrency services. |
Advantage Comparison:
In scenarios with an ever-increasing number of categories, the development and maintenance costs of a traditional "end-to-end" classification model grow exponentially. In contrast, the "Detect (Optional) + Recognize + Retrieve" paradigm adopted by ShiTuApi demonstrates excellent scalability and low-cost maintenance advantages.
3. Application Scenarios — Your Imagination is the Only Limit
With its powerful "Recognize-Everything" capability, ShiTuApi can be widely applied across various industries:
- Smart Retail & Supermarkets: Automated product recognition, shelf inventory, self-checkout, competitive analysis.
- Industrial Manufacturing & Quality Inspection: Production line part identification, defect detection, material tracking.
- Warehousing & Logistics: Parcel/container recognition, rapid sorting, inbound/outbound management.
- Mobile Apps & Mini-Programs: Photo-based object recognition, ID/card recognition, logo identification, landmark recognition.
- Security & Surveillance: Searching for and tracking specific targets (e.g., specific vehicles, clothing).
4. Key Technical Highlights
- Pimpl Idiom: Completely hides C++ implementation details, ensuring binary interface stability (ABI-safe). Your code does not need to be recompiled when we upgrade the library internally.
- Configuration-Driven: Flexibly configure all parameters, including models, hardware, preprocessing, and post-processing, through a single, easy-to-read
config.yamlfile. - High-Performance Vector Retrieval: Integrates Facebook AI's FAISS library to achieve millisecond-level similarity searches, even in an index with millions of entries.
- Built-in NMS Algorithm: Intelligently merges overlapping recognition results to output a clean and accurate list of targets.
- Thread-Safe Design: Isolates instances using handles and locks all operations on each instance, ensuring stability in high-concurrency environments.
5. Quick Start — In Just Five Steps
Using ShiTuApi is as simple as calling a utility function:
- Create a handle:
ShiTuApi_Create(out handle) - Initialize the API:
ShiTuApi_InitializeWithLicense(handle, "config.yaml") - Build the index:
ShiTuApi_BuildIndexFromFile(handle, "image_list.txt", ...) - Perform a search:
ShiTuApi_SearchByPath(handle, "query.jpg", ..., out results, out num) - Destroy the handle:
ShiTuApi_Destroy(ref handle)
6. ShiTuApiTestApp Guide: Your Personal AI Vision Lab
Welcome to ShiTuApiTestApp! It's more than just a simple demo; it's a powerful, WYSIWYG development and debugging tool. Follow this guide to master ShiTuApi and kickstart your AI vision project.
For the ShiTuApiTestApp source code, please visit our *GitHub Project Homepage*.
6.1 Step 1: Environment Setup & Project Execution ("Getting it to Run")
Before writing any code, let's get the test application running successfully.
Prerequisites:
- A 64-bit Windows operating system.
- Visual Studio 2022 (recommended) with the .NET desktop development workload installed.
Deployment Process:
Project Setup:
- Create a new C# WinForms project in Visual Studio (targeting .NET 8 or newer).
- Add the provided source files (
Form1.cs,Form1.Designer.cs,ShiTuCApi.cs, etc.) to your project. - Using the NuGet Package Manager, search for and install
YamlDotNet, which is required for parsing the configuration file.
Core File Deployment (Crucial Step):
- shitu\_c\_api.dll: This is the core dynamic-link library of the API. Make sure you are using the version compiled in Release mode. Copy it to your C# project's final output directory, typically
[Project_Folder]/bin/x64/Release/net8.0-windows/. - Model Folders: You can use the models we provide, or visit the official Baidu PaddleClas website to download more inference/training models, or even use your own trained models. Copy the model folder (e.g.,
models) to the same output directory. - Configuration File: Place the
config.yamlfile in the same directory. - Font File (Optional but Recommended): If you need to recognize and display labels with non-English characters like Chinese, copy a Chinese font file (e.g.,
msyh.ttf- Microsoft YaHei) to the directory and configure its path correctly inconfig.yaml.
- shitu\_c\_api.dll: This is the core dynamic-link library of the API. Make sure you are using the version compiled in Release mode. Copy it to your C# project's final output directory, typically
Compile and Run:
- At the top of Visual Studio, set the Solution Platform to x64 (because the DLL is 64-bit).
- Set the Solution Configuration to Release.
- Click on the "Build" menu -> "Rebuild Solution". This step ensures all code is recompiled.
- Click the green "Start" button. If everything is set up correctly, the
ShiTuApiTestAppmain window will appear!
6.2 Step 2: Understanding config.yaml - The API's "Remote Control"
config.yaml is your "remote control" for interacting with ShiTuApi. Any changes you make to this text file will directly alter the API's internal behavior the next time it's initialized.
For more detailed parameters and advanced usage, please refer to the complete documentation on our GitHub Project Homepage.
Global Block: Global Settings
This section defines the basic environment and core model parameters for the API.
enable_mkldnn: true- Meaning: Whether to enable Intel's MKL-DNN acceleration library in CPU mode.
- Usage: If you are using an Intel CPU, it is highly recommended to keep this
trueas it can significantly boost CPU inference speed.
det_inference_model_dir&rec_inference_model_dir:- Meaning: The paths to the object detection model and the recognition model. The recognition model is required; the detection model is optional.
- Model Source: You can download the latest inference models from the Baidu PaddleClas GitHub repository or its official website, or use models you've trained yourself with PaddleClas. ShiTuApi is compatible with them.
feature_dim: 512- Meaning: The dimension of the feature vector. This is extremely important and must exactly match the output dimension of the recognition model you are using. The default is 512.
threshold: 0.6- Meaning: Detection confidence threshold. This is the first gate an object must pass to be "seen".
- Debugging Tip: If you have missed detections, lower this value (e.g.,
0.5); if there are too many false positives, raise this value (e.g.,0.7).
About GPU Parameters: You might see parameters likeuse_gpu,gpu_id, etc., inconfig.yaml. In the current CPU-only release, these are placeholders for future use, and changing them will have no effect. For a GPU version, please contact us for commercial customization.
IndexProcess Block: Index and Recognition Behavior
This section controls how your "image brain" is built and how it works.
index_dir: "./product_index/all_products": Index path. The program will generate.indexand.labelfiles here.metric_type: "IP": Similarity metric.IP(Inner Product) is suitable for normalized features.L2(Euclidean Distance) is an alternative.threshold: 0.6: Recognition score threshold. This is the "acceptance score" for a recognition result and is a key parameter for ensuring accuracy.- Debugging Tip: If you have too many incorrect recognitions, raise this value (e.g.,
0.75); if you want to recall more potential matches, lower this value (e.g.,0.55).
- Debugging Tip: If you have too many incorrect recognitions, raise this value (e.g.,
use_detBuild: false: Indexing mode.falseenables whole-image indexing (suitable for icons, logos);trueenables post-detection indexing (suitable for products with complex backgrounds), which requires you to train your own model based on project-specific detection accuracy needs.
Visualization Configuration (under Global): The "Eyes" for Debugging
visualize_search_results: true/visualize_detection_results: true: Control the display logic for result images.search_resultscontrols whether to show green boxes for successful recognitions, whiledetection_resultscontrols whether to show yellow boxes for pure detections.visualization_output_dir: "./output_vis": All visualized result images will be saved in this folder.freetype_font_path: "./msyh.ttf": To correctly display Chinese labels, you must provide a valid path to a Chinese font file.
7. Commercial Use & Regulations
- License: ShiTuApi is licensed under a commercial agreement. On first run, it will automatically enter a fully-functional trial mode. You can obtain your unique "Machine ID" from the test application's interface and send it to us to receive a formal license key. Activation is completed via the "Activate" function, granting you unlimited access to the official service.
- Data Privacy: ShiTuApi is a purely local API library. All image processing and recognition are performed on your own device. It does not upload any of your image data to the cloud or any third-party servers, fully protecting your data sovereignty, security, and privacy.
- Legal Disclaimer: Users of this API must comply with all relevant laws and regulations in their country and region. It must not be used for any purpose that infringes upon the privacy, intellectual property, or other rights of others, or for any illegal activities.
8. Conclusion
ShiTuApi is more than just a code library; it's a complete, field-proven AI vision engineering solution. We handle all the thorny low-level issues for you—from model deployment and hardware acceleration to thread safety—so you can focus on your business logic and product innovation.
Visit our GitHub Project Homepage now to download the latest release and experience unprecedented AI development efficiency!
Links for sample program, models, and DLL files:
- https://pan.baidu.com/s/1JAtsiL5Zh6RSxRrxcp9qAw?pwd=5574 (Access Code: 5574)
- https://secure.ue.internxt.com/d/sh/file/9e59d447-e1b5-4e5d-87fb-c3ccd8dca37b/fb906ac390b384e4fe90c84ee14e06f7deaf33c0e84e80507d03cd7b95846716
- https://u.pcloud.link/publink/show?code=XZH9Mu5ZwUlEasu9TcpaaAD3cp0CwmObVjoX
- https://www.dropbox.com/scl/fi/os3e7da5g5iog66300pyf/DLL.zip?rlkey=60uyyyvicww3cfa3mzz79de0n&st=m3g4p5dv&dl=0
For inquiries, please contact: cfliyi@outlook.com