mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
Compare commits
1 Commits
rtsp-camer
...
1fd88c7636
Author | SHA1 | Date | |
---|---|---|---|
|
1fd88c7636 |
35
README.md
35
README.md
@@ -1,8 +1,39 @@
|
|||||||
# TI-project - Kobuki
|
# TI-project - exploration robot Kobuki
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
This project is a kobuki that drives around in dangerous areas and detects objects in its path. It uses a camera to detect objects. The kobuki is able to drive around in a room and detect objects.
|
This project is a kobuki that drives around in dangerous areas and detects objects in its path. It uses a camera to detect objects. The purpose of this project is to explore dangerous areas without risking human lives. You are able to control the robot using controller on the website.
|
||||||
|
|
||||||
## Photos
|
## Photos
|
||||||

|

|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
- Kobuki robot
|
||||||
|
- Raspberry Pi (minimum 3B)
|
||||||
|
- Camera
|
||||||
|
- power supply for Raspberry Pi
|
||||||
|
- laptop or computer
|
||||||
|
|
||||||
|
### Steps
|
||||||
|
|
||||||
|
1. **Install Python and Pip**
|
||||||
|
- Ensure you have Python installed on your system. You can download it from [python.org](https://www.python.org/).
|
||||||
|
- Pip is the package installer for Python. It usually comes with Python, but you can install it separately if needed.
|
||||||
|
|
||||||
|
2. **Clone Our Repository**
|
||||||
|
- Clone our repository to your local machine doing the following :
|
||||||
|
- Open your terminal
|
||||||
|
- Change the current working directory to the location where you want the cloned directory.
|
||||||
|
- Type `git clone https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
|
||||||
|
|
||||||
|
3. **Install the required packages**
|
||||||
|
- Open the terminal and navigate to the project - scr - Python - flask.
|
||||||
|
- Run the following command to install the required packages:
|
||||||
|
- `pip install -r requirements.txt`
|
||||||
|
- This will install all the python packages required to run the project.
|
||||||
|
- for C++, you will need to install the following packages:
|
||||||
|
- OpenCV
|
||||||
|
- mqtt-client
|
||||||
|
4.
|
@@ -289,23 +289,12 @@ void sendKobukiData(TKobukiData &data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CapnSend() {
|
void CapnSend() {
|
||||||
int fps = 15;
|
VideoCapture cap(0);
|
||||||
int width = 800;
|
|
||||||
int height = 600;
|
|
||||||
|
|
||||||
VideoCapture cap("/dev/video0");
|
|
||||||
if (!cap.isOpened()) {
|
if (!cap.isOpened()) {
|
||||||
cerr << "Error: Could not open camera" << endl;
|
cerr << "Error: Could not open camera" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoWriter out("appsrc ! videoconvert ! video/x-raw,format=I420 ! x264enc speed-preset=ultrafast bitrate=600 key-int-max=" + to_string(fps * 2) + " ! video/x-h264,profile=baseline ! mpegtsmux ! udpsink host=127.0.0.1 port=5001",
|
|
||||||
CAP_GSTREAMER, 0, fps, Size(width, height), true);
|
|
||||||
if (!out.isOpened()) {
|
|
||||||
cerr << "Error: Can't open video writer" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mat frame;
|
Mat frame;
|
||||||
while (true) {
|
while (true) {
|
||||||
cap >> frame; // Capture a new image frame
|
cap >> frame; // Capture a new image frame
|
||||||
@@ -314,10 +303,15 @@ void CapnSend() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the frame to the UDP stream
|
// Convert the image to a byte array
|
||||||
out.write(frame);
|
vector<uchar> buf;
|
||||||
|
imencode(".jpg", frame, buf);
|
||||||
|
auto* enc_msg = reinterpret_cast<unsigned char*>(buf.data());
|
||||||
|
|
||||||
|
// Publish the image data
|
||||||
|
client.publishMessage("kobuki/cam", string(enc_msg, enc_msg + buf.size()));
|
||||||
cout << "Sent image" << endl;
|
cout << "Sent image" << endl;
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000 / fps)); // Control the frame rate
|
std::this_thread::sleep_for(std::chrono::milliseconds(200)); // Send image every 200ms
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user