mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 12:24:57 +00:00
use libcamera with picam
This commit is contained in:
@@ -281,12 +281,12 @@ void sendKobukiData(TKobukiData &data) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CapnSend() {
|
||||
// Use OpenNI2 backend to access the Astra camera
|
||||
VideoCapture cap(cv::CAP_OPENNI2);
|
||||
// Use GStreamer pipeline to access the Astra camera with libcamera
|
||||
std::string pipeline = "libcamerasrc ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! appsink";
|
||||
VideoCapture cap(pipeline, cv::CAP_GSTREAMER);
|
||||
if (!cap.isOpened()) {
|
||||
cerr << "Error: Could not open Astra camera with OpenNI2 backend" << endl;
|
||||
cerr << "Error: Could not open camera with GStreamer pipeline" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -304,8 +304,9 @@ void CapnSend() {
|
||||
auto* enc_msg = reinterpret_cast<unsigned char*>(buf.data());
|
||||
|
||||
// Publish the image data
|
||||
client.publishMessage("kobuki/cam-", string(enc_msg, enc_msg + buf.size()));
|
||||
client.publishMessage("kobuki/cam", string(enc_msg, enc_msg + buf.size()));
|
||||
cout << "Sent image" << endl;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(400)); // Send image every 1000ms
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // Send image every 1000ms
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user