refactoring, renaming and commenting

pull/3471/head
kallaballa 2 years ago
parent 55592b3dcb
commit b127c7c94a
  1. 4
      modules/v4d/include/opencv2/v4d/util.hpp
  2. 2
      modules/v4d/samples/cube-demo.cpp
  3. 2
      modules/v4d/samples/display_image.cpp
  4. 2
      modules/v4d/samples/display_image_fb.cpp
  5. 2
      modules/v4d/samples/shader-demo.cpp
  6. 2
      modules/v4d/samples/video-demo.cpp
  7. 2
      modules/v4d/src/detail/framebuffercontext.cpp
  8. 17
      modules/v4d/src/util.cpp

@ -81,10 +81,10 @@ size_t cnz(const cv::UMat& m);
using std::string; using std::string;
class V4D; class V4D;
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
CV_EXPORTS Mat read_image(const string &path); CV_EXPORTS Mat read_embedded_image(const string &path);
#endif #endif
CV_EXPORTS unsigned int init_shader(const char* vShader, const char* fShader, const char* outputAttributeName); CV_EXPORTS unsigned int initShader(const char* vShader, const char* fShader, const char* outputAttributeName);
/*! /*!
* Returns the OpenGL Version information. * Returns the OpenGL Version information.
* @return a string object with the OpenGL version information * @return a string object with the OpenGL version information

@ -66,7 +66,7 @@ static GLuint load_shader() {
} }
)"; )";
return cv::v4d::init_shader(vert.c_str(), frag.c_str(), "fragColor"); return cv::v4d::initShader(vert.c_str(), frag.c_str(), "fragColor");
} }
static void init_scene(const cv::Size& sz) { static void init_scene(const cv::Size& sz) {

@ -10,7 +10,7 @@ static Ptr<V4D> window = V4D::make(Size(1280, 720), "Show image");
int main() { int main() {
//An image //An image
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
Mat image = read_image("doc/lena.png"); Mat image = read_embedded_image("doc/lena.png");
#else #else
Mat image = imread(samples::findFile("lena.jpg")); Mat image = imread(samples::findFile("lena.jpg"));
#endif #endif

@ -10,7 +10,7 @@ static Ptr<V4D> window = V4D::make(Size(1280, 720), "Show image");
int main() { int main() {
//Read an image as UMat //Read an image as UMat
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
UMat image = read_image("doc/lena.png").getUMat(ACCESS_READ); UMat image = read_embedded_image("doc/lena.png").getUMat(ACCESS_READ);
#else #else
UMat image = imread(samples::findFile("lena.jpg")).getUMat(ACCESS_READ); UMat image = imread(samples::findFile("lena.jpg")).getUMat(ACCESS_READ);
#endif #endif

@ -168,7 +168,7 @@ static void load_shader() {
cerr << "##### Fragment Shader #####" << endl; cerr << "##### Fragment Shader #####" << endl;
cerr << frag << endl; cerr << frag << endl;
shader_program_hdl = cv::v4d::init_shader(vert.c_str(), frag.c_str(), "fragColor"); shader_program_hdl = cv::v4d::initShader(vert.c_str(), frag.c_str(), "fragColor");
} }
static float easeInOutQuint(float x) { static float easeInOutQuint(float x) {

@ -64,7 +64,7 @@ static GLuint load_shader() {
} }
)"; )";
return cv::v4d::init_shader(vert.c_str(), frag.c_str(), "fragColor"); return cv::v4d::initShader(vert.c_str(), frag.c_str(), "fragColor");
} }
static void init_scene() { static void init_scene() {

@ -84,7 +84,7 @@ void FrameBufferContext::init() {
glfwWindowHint(GLFW_STENCIL_BITS, 8); glfwWindowHint(GLFW_STENCIL_BITS, 8);
glfwWindowHint(GLFW_DEPTH_BITS, 24); glfwWindowHint(GLFW_DEPTH_BITS, 24);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE); glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_FALSE);
glfwWindow_ = glfwCreateWindow(frameBufferSize_.width, frameBufferSize_.height, std::to_string(++window_cnt).c_str(), nullptr, glfwWindow_ = glfwCreateWindow(frameBufferSize_.width, frameBufferSize_.height, std::to_string(++window_cnt).c_str(), nullptr,
sharedWindow_); sharedWindow_);

@ -38,22 +38,9 @@ void run_sync_on_main(std::function<void()> fn) {
#endif #endif
} }
size_t cnz(const cv::UMat& m) {
cv::UMat grey;
if(m.channels() == 1) {
grey = m;
} else if(m.channels() == 3) {
cvtColor(m, grey, cv::COLOR_BGR2GRAY);
} else if(m.channels() == 4) {
cvtColor(m, grey, cv::COLOR_BGRA2GRAY);
} else {
assert(false);
}
return cv::countNonZero(grey);
}
} }
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
Mat read_image(const string &path) { Mat read_embedded_image(const string &path) {
SDL_Surface *loadedSurface = IMG_Load(path.c_str()); SDL_Surface *loadedSurface = IMG_Load(path.c_str());
Mat result; Mat result;
if (loadedSurface == NULL) { if (loadedSurface == NULL) {
@ -89,7 +76,7 @@ Mat read_image(const string &path) {
} }
#endif #endif
unsigned int init_shader(const char* vShader, const char* fShader, const char* outputAttributeName) { unsigned int initShader(const char* vShader, const char* fShader, const char* outputAttributeName) {
struct Shader { struct Shader {
GLenum type; GLenum type;
const char* source; const char* source;

Loading…
Cancel
Save