Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions highgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ set(highgui_srcs
${CMAKE_CURRENT_LIST_DIR}/src/kanna_rotate.cpp
${CMAKE_CURRENT_LIST_DIR}/src/videocapture.cpp
${CMAKE_CURRENT_LIST_DIR}/src/videowriter.cpp
${CMAKE_CURRENT_LIST_DIR}/src/writer_http.cpp

# dnn
${CMAKE_CURRENT_LIST_DIR}/src/nms.cpp
)
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND highgui_srcs
${CMAKE_CURRENT_LIST_DIR}/src/capture_v4l2.cpp
${CMAKE_CURRENT_LIST_DIR}/src/display_fb.cpp
${CMAKE_CURRENT_LIST_DIR}/src/writer_http.cpp)
)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand Down Expand Up @@ -121,3 +122,4 @@ else()
ocv_highgui_configure_target()
endif()
endif()

60 changes: 19 additions & 41 deletions highgui/src/videowriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
#include <stdio.h>
#include <string.h>

#if defined __linux__ && !__ANDROID__
#if ((defined __linux__ && !__ANDROID__) || defined(_WIN32))
#include "writer_http.h"
#endif

namespace cv {

class VideoWriterImpl
{
class VideoWriterImpl {
public:
VideoWriterImpl();

Expand All @@ -37,64 +35,51 @@ class VideoWriterImpl
int height;
float fps;

#if defined __linux__ && !__ANDROID__
#if ((defined __linux__ && !__ANDROID__) || defined(_WIN32))
writer_http wt_http;
#endif
};

VideoWriterImpl::VideoWriterImpl()
{
VideoWriterImpl::VideoWriterImpl() {
is_opened = false;
width = 0;
height = 0;
fps = 0;
}

VideoWriter::VideoWriter() : d(new VideoWriterImpl)
{
VideoWriter::VideoWriter() : d(new VideoWriterImpl) {
}

VideoWriter::~VideoWriter()
{
VideoWriter::~VideoWriter() {
release();

delete d;
}

bool VideoWriter::open(const String& name, int port)
{
if (d->is_opened)
{
bool VideoWriter::open(const String &name, int port) {
if (d->is_opened) {
release();
}

if (name == "httpjpg")
{
#if defined __linux__ && !__ANDROID__
if (writer_http::supported())
{
#if ((defined __linux__ && !__ANDROID__) || defined(_WIN32))
if (name == "httpjpg") {
if (writer_http::supported()) {
int ret = d->wt_http.open(port);
if (ret == 0)
{
if (ret == 0) {
d->is_opened = true;
}
}
else
#endif
{
}
}
#endif

return d->is_opened;
}

bool VideoWriter::isOpened() const
{
bool VideoWriter::isOpened() const {
return d->is_opened;
}

void VideoWriter::release()
{
void VideoWriter::release() {
if (!d->is_opened)
return;

Expand All @@ -114,31 +99,24 @@ void VideoWriter::release()
d->fps = 0;
}

VideoWriter& VideoWriter::operator<<(const Mat& image)
{
VideoWriter &VideoWriter::operator<<(const Mat &image) {
write(image);

return *this;
}

void VideoWriter::write(const Mat& image)
{
void VideoWriter::write(const Mat &image) {
if (!d->is_opened)
return;

#if defined __linux__ && !__ANDROID__
if (writer_http::supported())
{
#if ((defined __linux__ && !__ANDROID__) || defined(_WIN32))
if (writer_http::supported()) {
// encode jpg
std::vector<uchar> buf;
cv::imencode(".JPG", image, buf);

d->wt_http.write_jpgbuf(buf);
}
else
#endif
{
}
}

} // namespace cv
Loading