Skip to content

Commit 961ecfc

Browse files
committed
add config to enable MJPG encoded stream
1 parent d3d9045 commit 961ecfc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cfg/VideoStream.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ gen.add("reopen_on_read_failure", bool_t, LEVEL.RUNNING, "Re-open camera device
3434
gen.add("output_encoding", str_t, LEVEL.NORMAL, "Output encoding", "bgr8")
3535
gen.add("start_frame", int_t, LEVEL.NORMAL, "Start frame of the video ", 0, 0)
3636
gen.add("stop_frame", int_t, LEVEL.NORMAL, "Stop frame of the video", -1, -1)
37+
gen.add("enable_mjpg", bool_t, LEVEL.NORMAL, "Try to use MJPG capture stream", False)
3738

3839
exit(gen.generate(PKG, PKG, "VideoStream"))

src/video_stream.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ virtual void subscribe() {
263263
}
264264
NODELET_INFO_STREAM("Video stream provider type detected: " << video_stream_provider_type);
265265

266+
if (latest_config.enable_mjpg) {
267+
cap->set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
268+
}
269+
266270
double reported_camera_fps;
267271
// OpenCV 2.4 returns -1 (instead of a 0 as the spec says) and prompts an error
268272
// HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument
@@ -385,6 +389,10 @@ virtual void configCallback(VideoStreamConfig& new_config, uint32_t level) {
385389
NODELET_INFO_STREAM("Forced image width is: " << new_config.width);
386390
NODELET_INFO_STREAM("Forced image height is: " << new_config.height);
387391
}
392+
if (new_config.enable_mjpg)
393+
{
394+
NODELET_INFO_STREAM("Trying to use MJPG camera stream.");
395+
}
388396

389397
if (subscriber_num > 0 && (level & 0x1))
390398
{

0 commit comments

Comments
 (0)