Discover the power of our advanced vehicle recognition API, designed for developers and tech enthusiasts looking to integrate cutting-edge features into their applications.
Vehicle Lens Api Access
Unlock the full potential of vehicle recognition with our API available on RapidAPI! With endpoints designed for advanced users, you can effortlessly extract plate information from photos, apply blur effects to protect privacy, and draw bounding boxes around license plates in images. Experience seamless integration and enhance your applications by harnessing the power of our sophisticated vehicle identification technology. Don’t miss out—explore our API today and take your projects to the next level!
Shortly some clients will be available for you to download till then check some examples.
Examples of use of vehicle lens api
let's say you have a picture of a car in your current folder called mycarimage.jpeg...
Replace your API_KEY accordingly getting one at RapidApi's hub
Processing a car plate via curl
We are calling a endpoint to get the license plates in the image as a JSON response
curl --request POST \
--url https://matocr.p.rapidapi.com/find_plates \
--header 'Content-Type: multipart/form-data' \
--header 'x-rapidapi-host: matocr.p.rapidapi.com' \
--header 'x-rapidapi-key: API_KEY' \
--form [email protected]
If you want the response saved to a file just use the -o parameter of curl specifying the output file path, it can be handy in another endpoints like the "/find_and_draw_plates" and the "/blur_plates". This way you can save the image returned by us to you disk.
Processing a car plate via php
<?php
class VehicleLensApiCall
{
public function blurThePlate(): string
{
$url = 'https://matocr.p.rapidapi.com/find_and_draw_plates';
$client = new \GuzzleHttp\Client();
$rawResponse = $client->post($url, [
'headers' => [
'x-rapidapi-key' => 'API_KEY',
'x-rapidapi-host' => 'matocr.p.rapidapi.com'
],
'multipart' => [
[
'name' => 'file',
'contents' => file_get_contents('path/to/image.jpg'),
'filename' => basename('image.jpg'),
],
],
]);
$processedImagePath = 'path/to/processed_image.jpg';
// The plate info is still returned as a http header if you need it feel free to use it
$plateInfo = json_decode($rawResponse->getHeaderLine('plate-data'), true);
//Save the file wherever you want
file_put_contents($processedImagePath, $rawResponse->getBody());
return $processedImagePath;
}
}
Blurring plates with python
In this example we'll go a little bit further with python getting all the images of vehicles in a folder and blurring their license plates. Sequentially we are saving all the processed images in another folder.
import os
import glob
import requests
API_KEY = 'API_KEY' # Replace with your actual API key
API_HOST = 'matocr.p.rapidapi.com'
URL = f'https://{API_HOST}/blur_plates'
def blur_license_plates_in_folder(image_path, output_folder):
with open(image_path, 'rb') as image_file:
response = requests.post(URL,
headers={
'x-rapidapi-key': API_KEY,
'x-rapidapi-host': API_HOST
},
files={
'file': (os.path.basename(image_path), image_file)
})
processed_image_path = os.path.join(output_folder, os.path.basename(image_path))
with open(processed_image_path, 'wb') as f:
f.write(response.content)
print(f'Processed {image_path}, saved as {processed_image_path}')
def process_images_in_folder(folder_path, output_folder):
os.makedirs(output_folder, exist_ok=True)
images = glob.glob(f'{folder_path}/*.jpg') # Adjust the extension if needed
for image in images:
blur_license_plates_in_folder(image, output_folder)
# Usage
process_images_in_folder('path/to/your/folder', 'path/to/output/folder')
Using this one you will have in output folder all images of vehicles with their license plate blurred so you can use it or post it anywhere safely. 🤗
One more, axios and Javascript
import axios from 'axios';
import fs from 'fs';
import path from 'path';
export default async function handler(req, res) {
const imagePath = path.resolve('public/images', 'image.jpg'); // Adjust to the correct path
const processedImagePath = path.resolve('public/processed', 'processed_image.jpg');
try {
const formData = new FormData();
formData.append('file', fs.createReadStream(imagePath));
const response = await axios.post('https://matocr.p.rapidapi.com/find_and_draw_plates', formData, {
headers: {
'x-rapidapi-key': 'API_KEY',
'x-rapidapi-host': 'matocr.p.rapidapi.com',
...formData.getHeaders()
}
});
// Save the processed image
fs.writeFileSync(processedImagePath, response.data);
res.status(200).json({ message: 'Image processed successfully', filePath: processedImagePath });
} catch (error) {
console.error(error);
res.status(500).json({ message: 'Error processing image' });
}
}
Bonus tip: you can use this one as a next js API route 😉
And that's all folks
Here we demonstrated how to integrate the Vehicle Lens API for processing license plates across multiple languages and platforms. We explored how to make API calls using Python, PHP, JavaScript (Node.js), and directly from the shell with cURL. These examples show the versatility of the API, allowing developers to easily integrate vehicle plate recognition and blur functionality into their projects regardless of the technology stack they are using. Thank you for reading. Any question? just contact us!
Want to check out how it performs? Try out our Automatic License Plate Recognizer or our License Plate Blur Tool at www.vehiclelens.com first.
Our powerful vehicle recognition API is now available on RapidAPI, making it easy for developers to integrate advanced features into their applications. Explore the capabilities of our API, including license plate information extraction, blurring, and bounding box drawing, by visiting our Vehicle image processing api at RapidAPI