Skip to content

Commit 27cdad7

Browse files
committed
add config to enable MJPG encoded stream
1 parent 65949bd commit 27cdad7

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.RUNNING, "Start frame of the video ", 0, 0)
3636
gen.add("stop_frame", int_t, LEVEL.RUNNING, "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
@@ -269,6 +269,10 @@ virtual void subscribe() {
269269
}
270270
NODELET_INFO_STREAM("Video stream provider type detected: " << video_stream_provider_type);
271271

272+
if (latest_config.enable_mjpg) {
273+
cap->set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
274+
}
275+
272276
double reported_camera_fps;
273277
// OpenCV 2.4 returns -1 (instead of a 0 as the spec says) and prompts an error
274278
// HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument
@@ -391,6 +395,10 @@ virtual void configCallback(VideoStreamConfig& new_config, uint32_t level) {
391395
NODELET_INFO_STREAM("Forced image width is: " << new_config.width);
392396
NODELET_INFO_STREAM("Forced image height is: " << new_config.height);
393397
}
398+
if (new_config.enable_mjpg)
399+
{
400+
NODELET_INFO_STREAM("Trying to use MJPG camera stream.");
401+
}
394402

395403
NODELET_DEBUG_STREAM("subscriber_num: " << subscriber_num << " and level: " << level);
396404
if (subscriber_num > 0 && (level & 0x1))

0 commit comments

Comments
 (0)