I am working on a project of using a camera to take a picture for detecting the available parking space in the carpark.
I am going to use image subtraction for comparing the empty and occupied situation in the carpark.
These are the two picture for comparison
This is the resulting image:
Can anyone tell me how to
recognize and put a rectangle outside the vehicle
output the number of the car for my further usage?
Here is the code:
// Test.cpp
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
using namespace std;
using namespace cv;
Mat bg_frame;
Mat cam_frame;
Mat diff_frame;
char charCheckForEscKey = 0;
int main() {
while (charCheckForEscKey != 27 /*&& capWebcam.isOpened()*/) {
bg_frame = imread("Picture1.jpg",0);
cam_frame = imread("Picture4.jpg",0);
resize(cam_frame, cam_frame, bg_frame.size());
imshow("test1", bg_frame);
imshow("test2", cam_frame);
absdiff(bg_frame, cam_frame, diff_frame);
threshold(diff_frame, diff_frame, 80, 255, THRESH_BINARY);
//erode(diff_frame, diff_frame, getStructuringElement(MORPH_RECT, Size(1, 1)));
dilate(diff_frame, diff_frame, Mat(), Point(-1, -1));
//Canny(diff_frame, diff_frame, 30, 70);
imshow("test3", diff_frame);
charCheckForEscKey = cv::waitKey(1); // delay (in ms) and get key press, if any
}
return(0);
}

