I have developed a C++ application integrating facial recognition with a blockchain-based voting system, utilizing OpenCV for real-time face detection and recognition. The program allows users to register their details, including name, age, CNIC, and political party, which are securely encrypted and stored. It employs a custom SimpleEncryption class for data encryption and blockchain technology to create tamper-proof logs of user interactions. Users are prompted to enter their details interactively, and the application saves captured images and encrypted data in specified paths. This system ensures data privacy, transparency, and security, making it a robust solution for secure voting and user verification. Contributions to enhance its features and functionality are welcome.
Note: The camera resolution is not optimal.
This C++ program, designed and developed by Syed Muhammad Minhal Rizvi, enhances efficiency by providing quick access to frequently used applications and websites through facial recognition, encryption, and blockchain concepts using OpenCV. The program captures live video, detects faces, and allows users to input details for each detected face, which are then encrypted and saved. It employs XOR-based encryption for user data, decrypts it for display, and logs entries with block numbers, hashes, and timestamps. While efforts have been made to ensure reliability and security, users are advised to use the program responsibly and acknowledge its provided as-is without guarantees. The program operates based on user commands, automating tasks to optimize time, though effectiveness may vary based on system configurations and external factors.
Our project "E-LOCKS: A Blockchain Based Voting System" includes features such as:
- Facial recognition for user identification
- Encryption of user data using a simple XOR encryption algorithm
- Decryption of user data and saving decrypted data to a specified path
- Capturing and storing images of detected faces
- Managing user details including name, age, CNIC, and political party affiliation
- Storing encrypted user data in a database
- Displaying block details including block hash and timestamp
- Real-time video capture and face detection using OpenCV
- Providing an interactive console for user input and data entry
- Implementing a blockchain mechanism for voting integrity
1. Clone the repository
git clone https://github.com/Minhal128/E-locks-A-blockchain-based-voting-system.git
2. Set the path in Visual studio for OpenCV
here is the way that how I setup the OpenCV in visual studio- Add OpenCV include and library paths in project properties.
- Include opencv_world470d.lib for debug and opencv_world470.lib for release.
- Add lib and bin paths to system environment variables for OpenCV.
- Name the main source file and copy test code to set up the project.
- Modify the image path, then restart Visual Studio to ensure code recognition and execution.
- Build the solution to execute the OpenCV project in Visual Studio 2022.
2. Install & Run OpenCV and C++ Language modules
# Create a build directory
mkdir build
cd build
# Configure the project with CMake
cmake -DOpenCV_DIR=$OpenCV_DIR ..
# Build the project
make
# Run the executable generated by the build process
run-- ./openCV.sln
The included header files in this C++ program provide essential functionalities for implementing a facial recognition and voting system using OpenCV. They enable core operations such as image processing (opencv2/core.hpp
, opencv2/imgproc.hpp
), GUI interactions (opencv2/highgui.hpp
), object detection including face detection (opencv2/objdetect.hpp
), standard input/output operations (iostream
), file handling (fstream
, sstream
), date and time manipulation (ctime
), dynamic data storage (vector
, unordered_set
), and output formatting (iomanip
). Together, these headers support tasks ranging from capturing video, detecting faces, managing user data, encrypting information, and displaying results, essential for creating a robust application integrating computer vision with data handling in C++.
We developed the C++ database using the basic concepts of file handling, ensuring that our data is stored in the specified paths.
A simple encryption class is defined to encrypt and decrypt user data using a XOR-based encryption method.
The UserData
class encapsulates information about a user, storing details such as their name, age, CNIC (Pakistan's national identity card number), political party affiliation, and the file path to their image. Meanwhile, the BlockData
class serves to structure and display block details within a blockchain-inspired voting system, showcasing attributes like hash and timestamp. The VotingSystem
class integrates functionalities for face detection, user data collection, encryption, file management, and block handling. Its start()
method initiates video capture via OpenCV, verifies camera accessibility, and displays live video in a window labeled "Face Recognition". It continuously processes frames, detects faces using a pre-trained classifier, prompts for user details upon detection, saves captured images, encrypts and stores user data in files, displays block details for each entry, and manages face data until the user exits via '0' or 'q'. The getCurrentTimestamp()
method retrieves and returns the current timestamp formatted as %Y-%m-%d %H:%M:%S.
....
Initializes the path to the face cascade classifier XML file. Creates an instance of the VotingSystem class and starts the face recognition and data entry process.
The provided C++ code implements a facial recognition and voting system prototype using OpenCV. It integrates face detection, user data collection, encryption, file handling, and block-like data structuring. The program captures live video, detects faces, prompts for user details, stores encrypted user data in files, and displays block details akin to a blockchain system.
- Implemented face detection and real-time video capture functionalities, UML diagram.
- Developed the user data entry and encryption/decryption logic & block details and documented the project.
- Integrated the system and handled the storage of user data and did backend database with filing
- Created the OpenCV functionality code for the frontalface_cascade.xml and the idea to implement this on Blockchain
This is our team contribution. A significant aspect is that, in our team, we have two cybersecurity enthusiasts and a very special member who is blind but can see dreams better than anyone else ❤
This project needs a ⭐ from you. Don't forget to leave a star ⭐