Timelapse Sample.#352
Conversation
…Queues and seek feature
mraduldubey
left a comment
There was a problem hiding this comment.
formatting and other comments, restructure the format of tests, new impl for tests is required
| return ModuleProps::getSerializeSize() + sizeof(sendDecodedFrame) + sizeof(motionVectorThreshold); | ||
| } | ||
| bool sendDecodedFrame = false; | ||
| bool sendOverlayFrame = false; |
There was a problem hiding this comment.
should be added in serialization part below
| { | ||
| outFrame = makeFrameWithPinId(0, motionVectorPinId); | ||
| } | ||
| if (sendOverlayFrame == false) { |
There was a problem hiding this comment.
- formatting
- put a comment on what is this change about
| memset(&pDstInfo, 0, sizeof(SBufferInfo)); | ||
| outFrame = makeFrameWithPinId(mMotionVectorSize, motionVectorPinId); | ||
| mMotionVectorData = static_cast<int16_t*>(outFrame->data()); | ||
| if (sendOverlayFrame) |
There was a problem hiding this comment.
formatting, in vs code use Ctrl+K, F to auto format
| } | ||
|
|
||
| if ((!sDecParam.bParseOnly) && (pDstInfo.pDst[0] != nullptr) && (mMotionVectorSize != mWidth * mHeight * 8)) | ||
| if(sendOverlayFrame == false){ |
There was a problem hiding this comment.
what is this change about ? why is this reqd in the sample PR
There was a problem hiding this comment.
This is required to determine whether the frames are in the motion or not when we set the sendOverlayFrame to false.
| @@ -0,0 +1,10 @@ | |||
| #dependencies | |||
|
|
|||
| find_package(Threads REQUIRED) | |||
There was a problem hiding this comment.
Threads is required here, why ?
There was a problem hiding this comment.
Not required forgot to remove this from the CMakeLists was just testing something. Removing it.
| ${LIBRE_INC_DIR} | ||
| ${NVCODEC_INCLUDE_DIR} | ||
| ) | ||
| target_link_libraries( |
There was a problem hiding this comment.
If I remove this then how do I link the aprapipes lib with the samples?
There was a problem hiding this comment.
remove the libraries that are not required by the sample boss
| find_library(APRA_PIPES_LIB NAMES aprapipes) | ||
| add_library(example_aprapipes STATIC ${SOURCE}) | ||
| add_executable(runner_test ${UT_FILE}) | ||
| target_include_directories ( example_aprapipes PRIVATE |
There was a problem hiding this comment.
Renaming it to timelapsesample would be better as there will be multiple samples with this name.
| int main() { | ||
| LoggerProps loggerProps; | ||
| loggerProps.logLevel = boost::log::trivial::severity_level::info; | ||
| Logger::setLogLevel(boost::log::trivial::severity_level::info); |
There was a problem hiding this comment.
both 79 & 80 are not required. one is enough
| bool stopPipeline(); | ||
|
|
||
| private: | ||
| PipeLine pipeline; |
There was a problem hiding this comment.
add a method called test, and call from test added in timelapse-sample/ - it should use step - not the pipeline
|
|
||
| timelapsePipeline -> startPipeline(); | ||
|
|
||
| timelapsePipeline -> stopPipeline(); |
There was a problem hiding this comment.
this is not a test. it has no checks. also, need to use step() instead
There was a problem hiding this comment.
Done added an assertion to check the frame size.
| void DetailFfmpeg::getMotionVectors(frame_container& frames, frame_sp& outFrame, frame_sp& decodedFrame) | ||
| { | ||
|
|
||
| bool discardNoisyFrames(int black_pixel_percent, cv::Mat image) { |
There was a problem hiding this comment.
We should also check if the pixels are all white
| { | ||
| if ((!sDecParam.bParseOnly) && (pDstInfo.pDst[0] != nullptr) && | ||
| (mMotionVectorSize != mWidth * mHeight * 8) && | ||
| (abs(avgX) > threshold || abs(avgY) > threshold)) { |
There was a problem hiding this comment.
Add a new bool prop and enable avg based thresholding only then
There was a problem hiding this comment.
I discussed this with Mradul he suggested this should not be sample specific. The improvement should be for the module and not sample specific.
|
|
||
| cv::cvtColor(yuvImgCV, bgrImg, cv::COLOR_YUV2BGR_I420); | ||
| frames.insert(make_pair(rawFramePinId, decodedFrame)); | ||
| if (!discardNoisyFrames(97, bgrImg)) { |
There was a problem hiding this comment.
This should be also checked in the ffmpeg strategy
|
I have addressed the comments please have a look @mohammedzakikochargi . |
mraduldubey
left a comment
There was a problem hiding this comment.
make some minor changes
| ${Boost_LIBRARIES} | ||
| ${FFMPEG_LIBRARIES} | ||
| ${OpenCV_LIBRARIES} | ||
| ${JETSON_LIBS} |
There was a problem hiding this comment.
do you need all libs in the aprapipessampleut ? I dont think so.
| ${LIBRE_INC_DIR} | ||
| ${NVCODEC_INCLUDE_DIR} | ||
| ) | ||
| target_link_libraries( |
There was a problem hiding this comment.
remove the libraries that are not required by the sample boss
| mColorchange1 = boost::shared_ptr<ColorConversion>(new ColorConversion( | ||
| ColorConversionProps(ColorConversionProps::BGR_TO_RGB))); | ||
| //convert frames from RGB to YUV420PLANAR | ||
| //the two step color change is done because H264Encoder takes YUV data and we don't have direct BGR to YUV. |
There was a problem hiding this comment.
delete after YUV data
| return true; | ||
| } | ||
|
|
||
| bool TimelapsePipeline::stopPipeline() { |
There was a problem hiding this comment.
format this file with Ctrl+k,f
| //the two step color change is done because H264Encoder takes YUV data and we don't have direct BGR to YUV. | ||
| mColorchange2 = boost::shared_ptr<ColorConversion>(new ColorConversion( | ||
| ColorConversionProps(ColorConversionProps::RGB_TO_YUV420PLANAR))); | ||
| mSync = boost::shared_ptr<Module>( |
There was a problem hiding this comment.
sync is required by the encoder.
There was a problem hiding this comment.
Further points:
- They should be very easy to build and run
- MUST not assume hadware GPUs for them to run / have counterpart software implementations
sample example for valve module as well as seek and flush queue features
…raPipes into ns/samples_timelapse
Sample: Face Detection
Running pipeline for face detection wip as per the structure changes in cmake changes in constructor added sample example to create thumbnail from mp4 video reduced thread sleep seconds added new sample which will start video from beginning using flushAllQueues and seek feature refactored CMake list and renamed files using resolved time stamp when seeking timelapse sample timelaspe file changes samples WIP. added main to sample cpp file. removed sample test file from tests. Improved motion vector data code. using absolute path. Reverting unwanted changes. Fixed the ghost channel issue in MotionVectorExtractor. revert vcpkg. changes. taking video paths from terminal and modified cmake. vcpkg baseline revert. reset vcpkg head. vcpkg revert vcpkg revert. update submodule update vcpkg final Corrected cmake for samples. Corrected base cmake for samples. added test thumbnail sample test for play mp4 from beginning updated main CMake refactored test and CMake file refactored CMake and file structure for thumbnail samples refactored CMake and file structure for play mp4 from beginning sample base CMake changes 1. Fixed the props for Mp4ReaderSource and Mp4WriterSink 2. Fixed the memory leak issue in MotionVectorExtractor Corrected cmake and test for timelapse sample. 1. Removed the sendOverlayFrames prop to remove overlay frames, instead setting the RAW_IMAGE output pin to MotionVectorExtractor. 2. Enhanced the threshold logic to get the frames based on average of the vectors. 3. Removed not required tests. Algo to remove noisy black frames. files format. Addressed comments. Added readme file for samples. code refactoring and renaming. Addressed comments. removed not required libs and file formatting. restored files relay sample. base cmake changes. Corrected linking libraries in timelapse sample cmake. rename.
…agond14/ApraPipes into ab/timelapse_sample # Conflicts: # base/CMakeLists.txt
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #233 & #353
Description
This PR contains the Surveillance summary timelapse based on motion detection sample number 7 from above linked issue.
This sample utilizes the following modules:
Mp4ReaderSource
MotionVectorExtractor
ColorConversionXForm
H264EncoderNVCodec
Mp4WriterSink
The Mp4ReaderSource reads a mp4 file. Mp4ReaderSource next is MotionVectorExtractor which gets the frames which match the given threshold and which are in motion. After MotionVectorExtractor the frames are passed to ColorConversionFormX to convert from BGR tor RGB and then from RGB to YUV420Planar because the H264EncoderNVCodec module only accepts YUV frames. After color conversion next is H264EncoderNVCodec which encodes the frames. After H264EncoderNVCodec next is Mp4WriterSink which writes the frames to disk.
Also in the MotionVectorExtractor I have introduced a flag sendOverlayFrame which when enabled sends the overlay frame else does not send the overlay frames. Since we dont need the overlay frames in this sample setting it to false.
This PR also has the fix for the issue Raw yuv420 output from motion extractor module is having horizontally layered bands on the frame.
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Feature and Bug Fix.
Screenshots (if applicable)
Checklist