change namespace from kb::viz2d to cv::viz

pull/3471/head
kallaballa 2 years ago
parent 007db69c8c
commit 9c27d52c6c
  1. 12
      src/beauty/beauty-demo.cpp
  2. 4
      src/common/detail/clvacontext.cpp
  3. 6
      src/common/detail/clvacontext.hpp
  4. 4
      src/common/detail/framebuffercontext.cpp
  5. 6
      src/common/detail/framebuffercontext.hpp
  6. 6
      src/common/detail/nanovgcontext.cpp
  7. 4
      src/common/detail/nanovgcontext.hpp
  8. 4
      src/common/dialog.cpp
  9. 4
      src/common/dialog.hpp
  10. 6
      src/common/formhelper.cpp
  11. 4
      src/common/formhelper.hpp
  12. 4
      src/common/nvg.cpp
  13. 4
      src/common/nvg.hpp
  14. 4
      src/common/sink.cpp
  15. 4
      src/common/sink.hpp
  16. 4
      src/common/source.cpp
  17. 4
      src/common/source.hpp
  18. 8
      src/common/util.cpp
  19. 4
      src/common/util.hpp
  20. 6
      src/common/viz2d.cpp
  21. 6
      src/common/viz2d.hpp
  22. 14
      src/font/font-demo.cpp
  23. 10
      src/nanovg/nanovg-demo.cpp
  24. 14
      src/optflow/optflow-demo.cpp
  25. 6
      src/pedestrian/pedestrian-demo.cpp
  26. 8
      src/shader/shader-demo.cpp
  27. 2
      src/tetra/tetra-demo.cpp
  28. 2
      src/video/video-demo.cpp

@ -43,7 +43,7 @@ bool side_by_side = false;
bool stretch = false;
#endif
static cv::Ptr<kb::viz2d::Viz2D> v2d = new kb::viz2d::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
static cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Beauty Demo");
static cv::Ptr<cv::face::Facemark> facemark = cv::face::createFacemarkLBF();
#ifdef USE_TRACKER
static cv::Ptr<cv::Tracker> tracker = cv::TrackerKCF::create();
@ -126,7 +126,7 @@ struct FaceFeatures {
};
void draw_face_oval_mask(const vector<FaceFeatures> &lm) {
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
for (size_t i = 0; i < lm.size(); i++) {
vector<vector<cv::Point2f>> features = lm[i].features();
cv::RotatedRect rotRect = cv::fitEllipse(features[0]);
@ -140,7 +140,7 @@ void draw_face_oval_mask(const vector<FaceFeatures> &lm) {
}
void draw_face_eyes_and_lips_mask(const vector<FaceFeatures> &lm) {
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
for (size_t i = 0; i < lm.size(); i++) {
vector<vector<cv::Point2f>> features = lm[i].features();
for (size_t j = 5; j < 8; ++j) {
@ -176,8 +176,8 @@ void adjust_saturation(const cv::UMat &srcBGR, cv::UMat &dstBGR, float factor) {
cvtColor(hls, dstBGR, cv::COLOR_HLS2BGR);
}
void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d) {
v2d->nanogui([&](kb::viz2d::FormHelper& form){
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
v2d->nanogui([&](cv::viz::FormHelper& form){
form.makeWindow(5, 30, "Effect");
form.makeGroup("Display");
@ -361,7 +361,7 @@ void iteration() {
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
#ifndef __EMSCRIPTEN__
if (argc != 2) {
std::cerr << "Usage: beauty-demo <input-video-file>" << endl;

@ -2,8 +2,8 @@
#include "../viz2d.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace detail {
CLVAContext::CLVAContext(FrameBufferContext &clglContext) :

@ -3,13 +3,13 @@
#include "framebuffercontext.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
class Viz2D;
namespace detail {
class CLVAContext {
friend class kb::viz2d::Viz2D;
friend class cv::viz::Viz2D;
CLExecContext_t context_;
FrameBufferContext &clglContext_;
cv::UMat frameBuffer_;

@ -3,8 +3,8 @@
#include "../util.hpp"
#include "../viz2d.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace detail {
//FIXME use cv::ogl

@ -21,8 +21,8 @@
#include "../util.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
class Viz2D;
namespace detail {
typedef cv::ocl::OpenCLExecutionContext CLExecContext_t;
@ -31,7 +31,7 @@ typedef cv::ocl::OpenCLExecutionContextScope CLExecScope_t;
class FrameBufferContext {
friend class CLVAContext;
friend class NanoVGContext;
friend class kb::viz2d::Viz2D;
friend class cv::viz::Viz2D;
bool clglSharing_ = true;
GLuint frameBufferID_ = 0;
GLuint textureID_ = 0;

@ -2,8 +2,8 @@
#include "../viz2d.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace detail {
NanoVGContext::NanoVGContext(Viz2D &v2d, NVGcontext *context, FrameBufferContext &fbContext) :
v2d_(v2d), context_(context), clglContext_(fbContext) {
@ -18,7 +18,7 @@ void NanoVGContext::render(std::function<void(const cv::Size&)> fn) {
#endif
FrameBufferContext::GLScope glScope(clglContext_);
NanoVGContext::Scope nvgScope(*this);
kb::viz2d::nvg::detail::NVG::setCurrentContext(context_),
cv::viz::nvg::detail::NVG::setCurrentContext(context_),
fn(clglContext_.getSize());
}

@ -13,8 +13,8 @@
#include "../util.hpp"
#include "../nvg.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace detail {
class NanoVGContext {
Viz2D& v2d_;

@ -9,8 +9,8 @@
#include <nanogui/layout.h>
#include <GLFW/glfw3.h>
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
std::function<bool(Dialog*, Dialog*)> Dialog::viz2DWin_Xcomparator([](Dialog* lhs, Dialog* rhs){ return lhs->position()[0] < rhs->position()[0]; });

@ -6,8 +6,8 @@
#include <set>
#include <string>
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
using std::string;

@ -1,7 +1,7 @@
#include "formhelper.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
FormHelper::FormHelper(nanogui::Screen* screen) : nanogui::FormHelper(screen) {
}
@ -10,7 +10,7 @@ FormHelper::~FormHelper() {
}
Dialog* FormHelper::makeWindow(int x, int y, const string &title) {
auto* win = new kb::viz2d::Dialog(m_screen, x, y, title);
auto* win = new cv::viz::Dialog(m_screen, x, y, title);
this->set_window(win);
return win;
}

@ -9,8 +9,8 @@
#include <string>
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
using std::string;
class FormHelper: public nanogui::FormHelper {
public:

@ -1,7 +1,7 @@
#include "nvg.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace nvg {
namespace detail {
class NVG;

@ -10,8 +10,8 @@
#endif
#include <nanogui/opengl.h>
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace nvg {
struct TextRow : public NVGtextRow {

@ -1,7 +1,7 @@
#include "sink.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
Sink::Sink(std::function<bool(const cv::UMat&)> consumer) : consumer_(consumer) {
}

@ -4,8 +4,8 @@
#include <functional>
#include <opencv2/opencv.hpp>
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
class Sink {
bool open_ = true;

@ -1,7 +1,7 @@
#include "source.hpp"
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
Source::Source(std::function<bool(cv::UMat&)> generator, float fps) : generator_(generator), fps_(fps) {
}

@ -4,8 +4,8 @@
#include <functional>
#include <opencv2/opencv.hpp>
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
class Source {
bool open_ = true;

@ -12,8 +12,8 @@
# include <csignal>
#endif
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
std::string get_gl_info() {
return reinterpret_cast<const char*>(glGetString(GL_VERSION));
@ -110,7 +110,7 @@ bool keep_running() {
return !finish_requested;
}
void update_fps(cv::Ptr<kb::viz2d::Viz2D> v2d, bool graphically) {
void update_fps(cv::Ptr<cv::viz::Viz2D> v2d, bool graphically) {
static uint64_t cnt = 0;
static cv::TickMeter tick;
static float fps;
@ -131,7 +131,7 @@ void update_fps(cv::Ptr<kb::viz2d::Viz2D> v2d, bool graphically) {
if (graphically) {
v2d->nvg([&](const cv::Size &size) {
using namespace kb;
using namespace cv;
string text = "FPS: " + std::to_string(fps);
nvg::beginPath();
nvg::roundedRect(5, 5, 15 * text.size() + 5, 30, 5);

@ -14,8 +14,8 @@
# include <fstream>
#endif
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
using std::string;
class Viz2D;
std::string get_gl_info();

@ -7,8 +7,8 @@
# include <emscripten.h>
#endif
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace detail {
void gl_check_error(const std::filesystem::path &file, unsigned int line, const char *expression) {
int errorCode = glGetError();
@ -78,7 +78,7 @@ bool Viz2D::initializeWindowing() {
if(glfwInit() != GLFW_TRUE)
return false;
glfwSetErrorCallback(kb::viz2d::error_callback);
glfwSetErrorCallback(cv::viz::error_callback);
if (debug_)
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);

@ -25,8 +25,8 @@ using std::cerr;
using std::endl;
using std::string;
namespace kb {
namespace viz2d {
namespace cv {
namespace viz {
namespace detail {
class FrameBufferContext;
class CLVAContext;
@ -45,7 +45,7 @@ cv::Scalar color_convert(const cv::Scalar& src, cv::ColorConversionCodes code);
std::function<bool(int, int, int, int)> make_default_keyboard_event_callback();
using namespace kb::viz2d::detail;
using namespace cv::viz::detail;
class NVG;

@ -19,7 +19,7 @@ const unsigned long DIAG = hypot(double(WIDTH), double(HEIGHT));
constexpr bool OFFSCREEN = false;
constexpr const char* OUTPUT_FILENAME = "font-demo.mkv";
constexpr double FPS = 60;
const cv::Scalar_<float> INITIAL_COLOR = kb::viz2d::color_convert(cv::Scalar(0.15 * 180.0, 128, 255, 255), cv::COLOR_HLS2BGR);
const cv::Scalar_<float> INITIAL_COLOR = cv::viz::color_convert(cv::Scalar(0.15 * 180.0, 128, 255, 255), cv::COLOR_HLS2BGR);
/** Visualization parameters **/
float min_star_size = 0.5f;
@ -41,13 +41,13 @@ using std::string;
using std::vector;
using std::istringstream;
cv::Ptr<kb::viz2d::Viz2D> v2d = new kb::viz2d::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Font Demo");
cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Font Demo");
vector<string> lines;
bool update_stars = true;
bool update_perspective = true;
void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d) {
v2d->nanogui([&](kb::viz2d::FormHelper& form){
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
v2d->nanogui([&](cv::viz::FormHelper& form){
form.makeWindow(5, 30, "Effect");
form.makeGroup("Text Crawl");
form.makeFormVariable("Font Size", font_size, 1.0f, 100.0f, true, "pt", "Font size of the text crawl");
@ -120,7 +120,7 @@ void iteration() {
if(update_stars) {
v2d->nvg([&](const cv::Size& sz) {
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
v2d->clear();
//draw stars
int numStars = rng.uniform(min_star_count, max_star_count);
@ -151,7 +151,7 @@ void iteration() {
}
v2d->nvg([&](const cv::Size& sz) {
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
v2d->clear();
fontSize(font_size);
@ -200,7 +200,7 @@ void iteration() {
int main(int argc, char **argv) {
try {
using namespace kb::viz2d;
using namespace cv::viz;
print_system_info();
if(!v2d->isOffscreen()) {

@ -12,7 +12,7 @@ using std::endl;
void draw_color_wheel(float x, float y, float w, float h, float hue) {
//color wheel drawing code taken from https://github.com/memononen/nanovg/blob/master/example/demo.c
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
int i;
float r0, r1, ax, ay, bx, by, cx, cy, aeps, r;
Paint paint;
@ -37,8 +37,8 @@ void draw_color_wheel(float x, float y, float w, float h, float hue) {
bx = cx + cosf(a1) * (r0 + r1) * 0.5f;
by = cy + sinf(a1) * (r0 + r1) * 0.5f;
paint = linearGradient(ax, ay, bx, by,
kb::viz2d::color_convert(cv::Scalar((a0 / (CV_PI * 2.0)) * 180.0, 0.55 * 255.0, 255.0, 255.0), cv::COLOR_HLS2BGR),
kb::viz2d::color_convert(cv::Scalar((a1 / (CV_PI * 2.0)) * 180.0, 0.55 * 255, 255, 255), cv::COLOR_HLS2BGR));
cv::viz::color_convert(cv::Scalar((a0 / (CV_PI * 2.0)) * 180.0, 0.55 * 255.0, 255.0, 255.0), cv::COLOR_HLS2BGR),
cv::viz::color_convert(cv::Scalar((a1 / (CV_PI * 2.0)) * 180.0, 0.55 * 255, 255, 255), cv::COLOR_HLS2BGR));
fillPaint(paint);
fill();
}
@ -81,7 +81,7 @@ void draw_color_wheel(float x, float y, float w, float h, float hue) {
lineTo(ax, ay);
lineTo(bx, by);
closePath();
paint = linearGradient(r, 0, ax, ay, kb::viz2d::color_convert(cv::Scalar(hue, 128, 255, 255), cv::COLOR_HLS2BGR_FULL), cv::Scalar(255, 255, 255, 255));
paint = linearGradient(r, 0, ax, ay, cv::viz::color_convert(cv::Scalar(hue, 128, 255, 255), cv::COLOR_HLS2BGR_FULL), cv::Scalar(255, 255, 255, 255));
fillPaint(paint);
fill();
paint = linearGradient((r + ax) * 0.5f, (0 + ay) * 0.5f, bx, by, cv::Scalar(0, 0, 0, 0), cv::Scalar(0, 0, 0, 255));
@ -113,7 +113,7 @@ void draw_color_wheel(float x, float y, float w, float h, float hue) {
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
if (argc != 2) {
cerr << "Usage: nanovg-demo <video-file>" << endl;
exit(1);

@ -42,9 +42,9 @@ const unsigned long DIAG = hypot(double(WIDTH), double(HEIGHT));
constexpr const char* OUTPUT_FILENAME = "optflow-demo.mkv";
constexpr bool OFFSCREEN = false;
static cv::Ptr<kb::viz2d::Viz2D> v2d = new kb::viz2d::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
static cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Sparse Optical Flow Demo");
#ifndef __EMSCRIPTEN__
static cv::Ptr<kb::viz2d::Viz2D> v2dMenu = new kb::viz2d::Viz2D(cv::Size(240, 360), cv::Size(240,360), false, "Display Settings");
static cv::Ptr<cv::viz::Viz2D> v2dMenu = new cv::viz::Viz2D(cv::Size(240, 360), cv::Size(240,360), false, "Display Settings");
#endif
/** Visualization parameters **/
@ -188,7 +188,7 @@ void visualize_sparse_optical_flow(const cv::UMat &prevGrey, const cv::UMat &nex
upNextPoints.push_back(pt /= scaleFactor);
}
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
beginPath();
strokeWidth(strokeSize);
strokeColor(color);
@ -301,8 +301,8 @@ void composite_layers(cv::UMat& background, const cv::UMat& foreground, const cv
cv::add(background, post, dst);
}
void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d, cv::Ptr<kb::viz2d::Viz2D> v2dMenu) {
v2d->nanogui([&](kb::viz2d::FormHelper& form){
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d, cv::Ptr<cv::viz::Viz2D> v2dMenu) {
v2d->nanogui([&](cv::viz::FormHelper& form){
form.makeWindow(5, 30, "Effects");
form.makeGroup("Foreground");
@ -373,7 +373,7 @@ void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d, cv::Ptr<kb::viz2d::Viz2D> v2dMenu)
form.makeFormVariable("Threshold Diff", scene_change_thresh_diff, 0.1f, 1.0f, true, "", "Difference of peak thresholds. Lowering it makes detection more sensitive");
});
v2dMenu->nanogui([&](kb::viz2d::FormHelper& form){
v2dMenu->nanogui([&](cv::viz::FormHelper& form){
form.makeWindow(8, 16, "Display");
form.makeGroup("Display");
@ -458,7 +458,7 @@ void iteration() {
exit(0);
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
#ifndef __EMSCRIPTEN__
if (argc != 2) {
std::cerr << "Usage: optflow <input-video-file>" << endl;

@ -103,7 +103,7 @@ void composite_layers(const cv::UMat background, const cv::UMat frameBuffer, cv:
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
if (argc != 2) {
std::cerr << "Usage: pedestrian-demo <video-input>" << endl;
@ -190,12 +190,12 @@ int main(int argc, char **argv) {
}
v2d->nvg([&](const cv::Size& sz) {
using namespace kb::viz2d::nvg;
using namespace cv::viz::nvg;
v2d->clear();
beginPath();
strokeWidth(std::fmax(2.0, WIDTH / 960.0));
strokeColor(kb::viz2d::color_convert(cv::Scalar(0, 127, 255, 200), cv::COLOR_HLS2BGR));
strokeColor(cv::viz::color_convert(cv::Scalar(0, 127, 255, 200), cv::COLOR_HLS2BGR));
float width = tracked.width * WIDTH_FACTOR;
float height = tracked.height * HEIGHT_FACTOR;
float cx = tracked.x * WIDTH_FACTOR + (width / 2.0f);

@ -317,10 +317,10 @@ void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {
cv::bitwise_not(dst, dst);
}
cv::Ptr<kb::viz2d::Viz2D> v2d = new kb::viz2d::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Shader Demo");
cv::Ptr<cv::viz::Viz2D> v2d = new cv::viz::Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Shader Demo");
void setup_gui(cv::Ptr<kb::viz2d::Viz2D> v2d) {
v2d->nanogui([](kb::viz2d::FormHelper& form){
void setup_gui(cv::Ptr<cv::viz::Viz2D> v2d) {
v2d->nanogui([](cv::viz::FormHelper& form){
form.makeWindow(5, 30, "Fractal");
form.makeGroup("Navigation");
@ -412,7 +412,7 @@ void iteration() {
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
try {
if(argc != 2) {
cerr << "Usage: shader-demo <video-file>" << endl;

@ -78,7 +78,7 @@ void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
cv::Ptr<Viz2D> v2d = new Viz2D(cv::Size(WIDTH, HEIGHT), cv::Size(WIDTH, HEIGHT), OFFSCREEN, "Tetra Demo");
print_system_info();

@ -78,7 +78,7 @@ void glow_effect(const cv::UMat &src, cv::UMat &dst, const int ksize) {
}
int main(int argc, char **argv) {
using namespace kb::viz2d;
using namespace cv::viz;
if(argc != 2) {
cerr << "Usage: video-demo <video-file>" << endl;

Loading…
Cancel
Save