-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1241 from prominenceai/v0.30.a.alpha
V0.30.a.alpha
- Loading branch information
Showing
13 changed files
with
579 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# v0.30.a.alpha (patch) Release Notes | ||
**Important!** | ||
* `v0.30.a.alpha` is a **patch** release (patch `a` for the `v0.30.alpha` release). | ||
* The public/client API in DslApi.h has not been changed - i.e there are no new services. | ||
* There is one critical bug fix, 2 new examples, minor documentation updates, and more test coverage. | ||
|
||
## Issues closed in this release | ||
### Bugs closed in this release | ||
* Fix and complete the V4L2 Sink - revert previous invalid change, and add test coverage and examples [#1238](https://github.com/prominenceai/deepstream-services-library/issues/1238). | ||
|
||
## New Examples in this release | ||
* [1file_pgie_iou_tracker_osd_window_v4l2.py](/examples/python/1file_pgie_iou_tracker_osd_window_v4l2.py) | ||
* [1file_pgie_iou_tracker_osd_window_v4l2.cpp](/examples/python/1file_pgie_iou_tracker_osd_window_v4l2.cpp) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
220 changes: 220 additions & 0 deletions
220
examples/cpp/1file_pgie_iou_tracker_osd_window_v4l2.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
/* | ||
The MIT License | ||
Copyright (c) 2024, Prominence AI, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in- | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
/* ############################################################################## | ||
# | ||
# This simple example demonstrates how to create a set of Pipeline components, | ||
# specifically: | ||
# - A File Source | ||
# - Primary GST Inference Engine (PGIE) | ||
# - IOU Tracker | ||
# - On-Screen Display | ||
# - Window Sink | ||
# - V4L2 Sink | ||
# ...and how to add them to a new Pipeline and play. | ||
# | ||
# The V4L2 Sink is used to display video to v4l2 video devices. | ||
# | ||
# V4L2 Loopback can be used to create "virtual video devices". Normal (v4l2) | ||
# applications will read these devices as if they were ordinary video devices. | ||
# See: https://github.com/umlaeute/v4l2loopback for more information. | ||
# | ||
# You can install v4l2loopback with | ||
# $ sudo apt-get install v4l2loopback-dkms | ||
# | ||
# Run the following to setup '/dev/video3' | ||
# $ sudo modprobe v4l2loopback video_nr=3 | ||
# | ||
# When the script is running, you can use the following GStreamer launch | ||
# command to test the loopback | ||
# $ gst-launch-1.0 v4l2src device=/dev/video3 ! videoconvert ! xvimagesink | ||
# | ||
# The example registers handler callback functions for: | ||
# - key-release events | ||
# - delete-window events | ||
# - end-of-stream EOS events | ||
# - Pipeline change-of-state events | ||
# | ||
############################################################################## */ | ||
|
||
#include <iostream> | ||
#include <glib.h> | ||
#include <gst/gst.h> | ||
#include <gstnvdsmeta.h> | ||
#include <nvdspreprocess_meta.h> | ||
|
||
#include "DslApi.h" | ||
|
||
std::wstring file_path( | ||
L"/opt/nvidia/deepstream/deepstream/samples/streams/sample_1080p_h265.mp4"); | ||
|
||
// Config and model-engine files | ||
std::wstring primary_infer_config_file( | ||
L"/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-preprocess-test/config_infer.txt"); | ||
std::wstring primary_model_engine_file( | ||
L"/opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b8_gpu0_int8.engine"); | ||
|
||
// Config file used by the IOU Tracker | ||
std::wstring iou_tracker_config_file( | ||
L"/opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app/config_tracker_IOU.yml"); | ||
|
||
// V4L2 Sink device location to stream to | ||
std::wstring DEVICE_LOCATION = L"/dev/video3"; | ||
|
||
uint WINDOW_WIDTH = 1280; | ||
uint WINDOW_HEIGHT = 720; | ||
|
||
// | ||
// Function to be called on XWindow KeyRelease event | ||
// | ||
void xwindow_key_event_handler(const wchar_t* in_key, void* client_data) | ||
{ | ||
std::wstring wkey(in_key); | ||
std::string key(wkey.begin(), wkey.end()); | ||
std::cout << "key released = " << key << std::endl; | ||
key = std::toupper(key[0]); | ||
if(key == "P"){ | ||
dsl_pipeline_pause(L"pipeline"); | ||
} else if (key == "R"){ | ||
dsl_pipeline_play(L"pipeline"); | ||
} else if (key == "Q" or key == "" or key == ""){ | ||
std::cout << "Main Loop Quit" << std::endl; | ||
dsl_pipeline_stop(L"pipeline"); | ||
dsl_main_loop_quit(); | ||
} | ||
} | ||
|
||
// | ||
// Function to be called on XWindow Delete event | ||
// | ||
void xwindow_delete_event_handler(void* client_data) | ||
{ | ||
std::cout<<"delete window event"<<std::endl; | ||
dsl_pipeline_stop(L"pipeline"); | ||
dsl_main_loop_quit(); | ||
} | ||
|
||
// | ||
// Function to be called on End-of-Stream (EOS) event | ||
// | ||
void eos_event_listener(void* client_data) | ||
{ | ||
std::cout<<"Pipeline EOS event"<<std::endl; | ||
dsl_pipeline_stop(L"pipeline"); | ||
dsl_main_loop_quit(); | ||
} | ||
|
||
// | ||
// Function to be called on every change of Pipeline state | ||
// | ||
void state_change_listener(uint old_state, uint new_state, void* client_data) | ||
{ | ||
std::cout<<"previous state = " << dsl_state_value_to_string(old_state) | ||
<< ", new state = " << dsl_state_value_to_string(new_state) << std::endl; | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
DslReturnType retval = DSL_RESULT_FAILURE; | ||
|
||
// Since we're not using args, we can Let DSL initialize GST on first call | ||
while(true) | ||
{ | ||
|
||
// New File Source using the file path specified above, repeat enabled. | ||
retval = dsl_source_file_new(L"file-source", file_path.c_str(), true); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// New Primary GIE using the filespecs defined above, with interval and Id | ||
retval = dsl_infer_gie_primary_new(L"primary-gie", | ||
primary_infer_config_file.c_str(), primary_model_engine_file.c_str(), 0); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// New IOU Tracker, setting operational width and height of input frame | ||
retval = dsl_tracker_new(L"iou-tracker", | ||
iou_tracker_config_file.c_str(), 480, 272); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// New OSD with text, clock and bbox display all enabled. | ||
retval = dsl_osd_new(L"on-screen-display", true, true, true, false); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// New 3D Window Sink with 0 x/y offsets, and same dimensions as Camera Source | ||
// EGL Sink runs on both platforms. 3D Sink is Jetson only. | ||
if (dsl_info_gpu_type_get(0) == DSL_GPU_TYPE_INTEGRATED) | ||
{ | ||
retval = dsl_sink_window_3d_new(L"window-sink", 0, 0, | ||
WINDOW_WIDTH, WINDOW_HEIGHT); | ||
} | ||
else | ||
{ | ||
retval = dsl_sink_window_egl_new(L"window-sink", 0, 0, | ||
WINDOW_WIDTH, WINDOW_HEIGHT); | ||
} | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// Add the XWindow event handler functions defined above | ||
retval = dsl_sink_window_key_event_handler_add(L"window-sink", | ||
xwindow_key_event_handler, NULL); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
retval = dsl_sink_window_delete_event_handler_add(L"window-sink", | ||
xwindow_delete_event_handler, NULL); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// New V4L2 Sink | ||
retval = dsl_sink_v4l2_new(L"v4l2-sink", DEVICE_LOCATION.c_str()); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// Create a list of Pipeline Components to add to the new Pipeline. | ||
const wchar_t* components[] = {L"file-source", L"primary-gie", | ||
L"iou-tracker", L"on-screen-display", L"window-sink", L"v4l2-sink", NULL}; | ||
|
||
// Add all the components to our pipeline | ||
retval = dsl_pipeline_new_component_add_many(L"pipeline", components); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// Add the EOS listener function defined above | ||
retval = dsl_pipeline_eos_listener_add(L"pipeline", eos_event_listener, NULL); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// Play the pipeline | ||
retval = dsl_pipeline_play(L"pipeline"); | ||
if (retval != DSL_RESULT_SUCCESS) break; | ||
|
||
// Start and join the main-loop | ||
dsl_main_loop_run(); | ||
break; | ||
|
||
} | ||
|
||
// Print out the final result | ||
std::cout << dsl_return_value_to_string(retval) << std::endl; | ||
|
||
dsl_delete_all(); | ||
|
||
std::cout<<"Goodbye!"<<std::endl; | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.