fixed not close ofstream

This commit is contained in:
Joe Dong
2024-01-30 10:07:43 +08:00
parent d6d4cff5ee
commit 3dc1080376
+1
View File
@@ -1202,6 +1202,7 @@ void OBCameraNode::saveImageToFile(const stream_index_pair &stream_index, const
if (stream_index.first == OB_STREAM_DEPTH) { if (stream_index.first == OB_STREAM_DEPTH) {
std::ofstream ofs(filename, std::ios::binary); std::ofstream ofs(filename, std::ios::binary);
ofs.write(reinterpret_cast<const char *>(image.data), image.total() * image.elemSize()); ofs.write(reinterpret_cast<const char *>(image.data), image.total() * image.elemSize());
ofs.close();
} else if (stream_index.first == OB_STREAM_COLOR) { } else if (stream_index.first == OB_STREAM_COLOR) {
auto image_to_save = auto image_to_save =
cv_bridge::toCvCopy(image_msg, sensor_msgs::image_encodings::BGR8)->image; cv_bridge::toCvCopy(image_msg, sensor_msgs::image_encodings::BGR8)->image;