Skip to content

Commit

Permalink
add config to enable MJPG encoded stream
Browse files Browse the repository at this point in the history
  • Loading branch information
machinekoder committed Nov 17, 2020
1 parent 6c3629c commit 3182b6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions cfg/VideoStream.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ gen.add("reopen_on_read_failure", bool_t, LEVEL.RUNNING, "Re-open camera device
gen.add("output_encoding", str_t, LEVEL.NORMAL, "Output encoding", "bgr8")
gen.add("start_frame", int_t, LEVEL.RUNNING, "Start frame of the video ", 0, 0)
gen.add("stop_frame", int_t, LEVEL.RUNNING, "Stop frame of the video", -1, -1)
gen.add("enable_mjpg", bool_t, LEVEL.NORMAL, "Try to use MJPG capture stream", False)

exit(gen.generate(PKG, PKG, "VideoStream"))
8 changes: 8 additions & 0 deletions src/video_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ virtual void subscribe() {
}
NODELET_INFO_STREAM("Video stream provider type detected: " << video_stream_provider_type);

if (latest_config.enable_mjpg) {
cap->set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
}

double reported_camera_fps;
// OpenCV 2.4 returns -1 (instead of a 0 as the spec says) and prompts an error
// HIGHGUI ERROR: V4L2: Unable to get property <unknown property string>(5) - Invalid argument
Expand Down Expand Up @@ -393,6 +397,10 @@ virtual void configCallback(VideoStreamConfig& new_config, uint32_t level) {
NODELET_INFO_STREAM("Forced image width is: " << new_config.width);
NODELET_INFO_STREAM("Forced image height is: " << new_config.height);
}
if (new_config.enable_mjpg)
{
NODELET_INFO_STREAM("Trying to use MJPG camera stream.");
}

NODELET_DEBUG_STREAM("subscriber_num: " << subscriber_num << " and level: " << level);
if (subscriber_num > 0 && (level & 0x1))
Expand Down

0 comments on commit 3182b6f

Please sign in to comment.