Create avi container for mjpeg#10145
Create avi container for mjpeg#10145opencv-pushbot merged 1 commit intoopencv:masterfrom allnes:vedeoio_avi_container
Conversation
|
|
||
| AviMjpegStream mjpeg_video_stream; | ||
| bool is_parsed = mjpeg_video_stream.parseAvi(in_str, m_mjpeg_frames); | ||
| AVIReadContainer<MjpegInputStream> mjpeg_video_stream; |
There was a problem hiding this comment.
It will be better to move MjpegInputStream to the same place where AVIReadContainer is located, then you will be able to avoid templates in the code.
There was a problem hiding this comment.
@mshabunin And unless the task was not to separate mjpeg codec and avi container, it turns out they will be together to one file again
There was a problem hiding this comment.
I don't see a problem here: MjpegInputStream is just a convenient object for reading AVI files, it does not implement MJPEG specific behavior.
| AviStreamHeader strm_hdr; | ||
| *in_str >> strm_hdr; | ||
|
|
||
| if(strm_hdr.fccType == VIDS_CC && strm_hdr.fccHandler == MJPG_CC) |
There was a problem hiding this comment.
Probably we should pass FourCC code (MJPG_CC here) as a parameter into this method.
|
|
||
|
|
||
| bool MotionJpegCapture::parseRiff(MjpegInputStream& in_str) | ||
| bool MotionJpegCapture::parseRiff() |
There was a problem hiding this comment.
I think this method can be moved to the AVIReadContainer class.
| @@ -781,17 +140,17 @@ double MotionJpegCapture::getProperty(int property) const | |||
|
|
|||
| std::vector<char> MotionJpegCapture::readFrame(frame_iterator it) | |||
There was a problem hiding this comment.
I think this method can be moved to the AVIReadContainer class.
| void MotionJpegCapture::close() | ||
| { | ||
| m_file_stream.close(); | ||
| m_avi_container.getStream()->close(); |
There was a problem hiding this comment.
It is better to avoid exposing internal stream. You can either provide AVIReadContainer::release method or, even better, to create new m_avi_container object for each opened file (store it in Ptr):
Ptr<AVIReadContainer> avi;
...
MotionJpegCapture::MotionJpegCapture(const String& filename)
{
avi = makePtr<AVIReadContainer>(filename);
...
}
bool MotionJpegCapture::open(const String& filename)
{
avi = makePtr<AVIReadContainer>(filename);
...
}| @@ -0,0 +1,479 @@ | |||
| /*M/////////////////////////////////////////////////////////////////////////////////////// | |||
There was a problem hiding this comment.
Let's use short license in all new files:
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
modules/videoio/CMakeLists.txt
Outdated
| ${CMAKE_CURRENT_LIST_DIR}/src/cap_images.cpp | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/cap_mjpeg_encoder.cpp | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/cap_mjpeg_decoder.cpp | ||
| ${CMAKE_CURRENT_LIST_DIR}/src/cap_avi_container.cpp |
There was a problem hiding this comment.
Let's rename cap_avi_container.cpp to container_avi.cpp.
| #include "precomp.hpp" | ||
| #include <deque> | ||
| #include <stdint.h> | ||
| #include "opencv2/core/private.cap_avi_container.hpp" |
There was a problem hiding this comment.
Let's rename this header to container_avi.private.hpp and it should be moved to the videoio module.
| bool m_is_indx_present; | ||
| }; | ||
|
|
||
| static const int AVIH_STRH_SIZE = 56; |
There was a problem hiding this comment.
All variables and functions marked static should be moved to the .cpp file.
|
|
||
| #include "test_precomp.hpp" | ||
| #include "opencv2/core/private.cap_avi_container.hpp" | ||
| #include "opencv2/highgui.hpp" |
There was a problem hiding this comment.
This include should be removed.
|
@allnes , we have updated test writing guidelines, please take a look: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#implementing-tests You have to wrap your test into namespace |
|
|
||
| using namespace cv; | ||
| using namespace std; | ||
| using namespace opencv_test; |
There was a problem hiding this comment.
All source code should be put into this namespace.
| #include <cstdio> | ||
|
|
||
| using namespace cv; | ||
| using namespace std; |
There was a problem hiding this comment.
Avoid using namespace std. Use std:: if necessary (common types are imported into opencv_test namespace).
| class BunnyParameters | ||
| { | ||
| private: | ||
| int bunny_width, bunny_height, bunny_fps, bunny_count; |
There was a problem hiding this comment.
It is not necessary to store values in the object:
class BunnyParameters {
public:
inline static int getWidth() { return 672; }
inline static getCount() { return cvRound(getFps() * getTime()); }
...
// call BunnyParameters::getCount()Filename generation can be provided by this class too:
inline static String getFilename(const String &ext) {
return cvtest::TS::ptr()->get_data_path() + "video/big_buck_bunny" + ext;
}|
@mshabunin I'm fixed |
| ext = get<0>(GetParam()); | ||
| apiPref = get<1>(GetParam()); | ||
|
|
||
| video_file = cvtest::TS::ptr()->get_data_path() + "video/big_buck_bunny." + ext; |
There was a problem hiding this comment.
Please use bunny_param.getFilename(String(".") + ext) here.
| { | ||
|
|
||
| TEST(videoio_avi, good_MJPG) { | ||
| String filename = cvtest::TS::ptr()->get_data_path() + "video/big_buck_bunny.mjpg.avi"; |
There was a problem hiding this comment.
You should add BunnyParameters::getFilename(".mjpg.avi"); here for consistency.
|
@mshabunin fixed |
| #include "opencv2/core/cvdef.h" | ||
| #include "opencv2/videoio/videoio_c.h" | ||
| #include <deque> | ||
| #include <stdint.h> |
There was a problem hiding this comment.
This is C++11/C11 header: http://www.cplusplus.com/reference/cstdint/ like uint32_t and other types.
|
@alalek fixed types, review please |
No description provided.