Dynamic parking using Intel MKL library and Intel movidius neural compute stick.

kiran kumar
5 min readAug 2, 2023

--

Dynamic parking assistance is a system that uses sensors and software to help drivers park their cars in tight spaces. It can be used to maximize the number of cars that can be parked in a given area.

Intel MKL library is a high-performance computing library that can be used to accelerate the processing of sensor data. It can be used to improve the speed and accuracy of dynamic parking assistance systems.

import numpy as np
from scipy.optimize import minimize
from scipy.spatial.distance import cdist
import cv2
from openvino.inference_engine import IECore

# Simulated parking lot layout (0: empty, 1: occupied)
parking_lot = np.array([
[0, 0, 0, 0, 0],
[0, 0, 1, 1, 0],
[1, 1, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0]
])

# Simulated vehicle sizes (length, width)
vehicle_sizes = np.array([
[4.5, 2.0],
[4.5, 2.0],
[4.5, 2.0],
[4.5, 2.0],
[4.5, 2.0]
])

# Simulated parking space sizes (length, width)
space_sizes = np.array([
[5.0, 2.5],
[5.0, 2.5],
[5.0, 2.5],
[5.0, 2.5],
[5.0, 2.5]
])

def objective(x):
# Objective function to minimize the distance between vehicles
return np.sum(cdist(x, x, metric=’euclidean’))

def constraint1(x):
# Constraint function to ensure vehicles don’t overlap with occupied spaces
for i, space in enumerate(parking_lot):
if np.any(space == 1):
min_dist = np.min(cdist([x[i]], x[space == 1], metric=’euclidean’))
if min_dist < 0.5: # Minimum separation distance
return min_dist — 0.5
return 0

# Initial guess for vehicle positions
initial_positions = np.array([
[1.0, 0.0],
[1.0, 3.0],
[2.5, 0.0],
[2.5, 3.0],
[4.0, 0.0]
])

# Optimization using the SciPy library
constraints = [{‘type’: ‘ineq’, ‘fun’: constraint1}]
solution = minimize(objective, initial_positions, constraints=constraints)

optimized_positions = solution.x

print(“Optimized Vehicle Positions:”)
print(optimized_positions)

# Additional steps are required to interface with Intel MKL, Movidius Neural Compute Stick,
# and RealSense camera. This example focuses only on the optimization aspect.

import cv2
from openvino.inference_engine import IECore

# Load the OpenVINO model
model_xml = ‘path/to/your/model.xml’
model_bin = ‘path/to/your/model.bin’
ie = IECore()
net = ie.read_network(model=model_xml, weights=model_bin)
exec_net = ie.load_network(network=net, device_name=’MYRIAD’)

# Initialize RealSense camera
pipeline = cv2.VideoCapture(cv2.CAP_INTELPERC)
while True:
ret, frame = pipeline.read()
if not ret:
break

# Preprocess the frame
input_blob = next(iter(net.input_info))
n, c, h, w = net.input_info[input_blob].input_data.shape
resized_frame = cv2.resize(frame, (w, h))
input_frame = resized_frame.transpose((2, 0, 1)).reshape((n, c, h, w))

# Perform inference
result = exec_net.infer(inputs={input_blob: input_frame})

# Process the result for object detection/segmentation
# … (post-processing code)

# Display the processed frame
cv2.imshow(‘Parking Assistance’, frame)
if cv2.waitKey(1) & 0xFF == ord(‘q’):
break

cv2.destroyAllWindows()
pipeline.release()

For the optimization and decision-making step, you might use a library like scipy for optimization. Here's a simplified example:

from scipy.optimize import minimize

def objective_function(params):
# Calculate the objective function based on parking space arrangement
# ... (your code here)
# Initial guess for optimization parameters
initial_params = [0.0, 0.0, ...]
# Perform optimization
result = minimize(objective_function, initial_params, method='COBYLA')
optimized_params = result.x

Intel Movidius neural compute stick is a small, low-power AI accelerator that can be used to run machine learning models on edge devices. It can be used to process the data from the RealSense camera and make predictions about the availability of parking spaces.

Large bandwidth being required to do more computation on the cloud. 2) No fixed Algorithm to maximize the number of Cars in particular lot. 3) No centralized and real-time information for the parking area. 4) Lack of proper data like the number of particular cars in a colony and pollution checked vehicles etc.

Implementation

1) A camera at parking space will take images after a regular interval. 2) Feed those images to a deep learning architecture XNOR-NET built-in C++ to detect available parking spots on edge. Our XNOR-NET architecture can even run on as simple chips of $5 itself. 3) Data from all such parking spaces in the city will be parsed to the centralized server database. 4) Initially, the whole area is divided into two sections i.e. big and small car area. 5) On-demand the partition area is changed dynamically through our Algorithm so that maximum cars can be assigned. 6) The driver can select parking spot to view details, available slots and book them.

The combination of Intel MKL library, Intel Movidius neural compute stick, and RealSense camera can be used to create a dynamic parking assistance system that is both accurate and efficient.

Here is a possible system architecture:

  • The RealSense camera would be used to capture images of the parking lot.
  • The images would be processed by the Intel Movidius neural compute stick to detect parking spaces.
  • The Intel MKL library would be used to calculate the optimal parking path for the car.
  • The results would be displayed to the driver on a dashboard display.

This system would allow drivers to park their cars in tight spaces more easily and efficiently. It would also help to maximize the number of cars that can be parked in a given area.

Here are some of the benefits of using this system:

  • Increased parking efficiency: The system can help to maximize the number of cars that can be parked in a given area.
  • Reduced driver stress: The system can help to reduce driver stress by making it easier to park in tight spaces.
  • Increased safety: The system can help to reduce the risk of accidents by providing drivers with more information about the availability of parking spaces.

The diagram shows the following components:

  • RealSense camera: This is the sensor that captures images of the parking lot.
  • Intel Movidius neural compute stick: This is the AI accelerator that processes the images from the RealSense camera.
  • Intel MKL library: This is the high-performance computing library that calculates the optimal parking path for the car.
  • Dashboard display: This is the device that displays the results of the system to the driver.
  • Parking lot server: This is the server that stores information about the availability of parking spaces.
  • Network: This is the network that connects the different components of the system.
Dynamic parking Using Intel MKLibrary and Intel Movidius

The arrows in the diagram show the flow of data through the system. The data starts with the RealSense camera, which captures images of the parking lot. The images are then processed by the Intel Movidius neural compute stick, which detects parking spaces. The results of the detection are then passed to the Intel MKL library, which calculates the optimal parking path for the car. The results of the calculation are then sent to the parking lot server, which updates its database of available parking spaces. The updated database is then sent back to the Intel Movidius neural compute stick, which displays the results to the driver on the dashboard display.

This is just one possible architecture for a dynamic parking assistance system that uses Intel MKL and Intel Movidius. There are other possible architectures that could be used. The specific architecture that is used will depend on the specific requirements of the system.

--

--

kiran kumar
kiran kumar

No responses yet