Code Monkey home page Code Monkey logo

selene's People

Contributors

danilaml avatar kmhofmann avatar mocabe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selene's Issues

Question: Dynamic image to file generates empty file without errors or warnings.

I was experimenting with wrapping the SANE library and everything worked great; other than writing to a jpeg.
The "doesn't work" section in the code below produces an empty file. I took a look at the tests and saw the conversion to a typed image and then a typed image view, gave it a try and it worked. Just wondering if I missed something/if the library should give some sort of warning for the way I tried to use the file io.

#include <sane/sane.h>

#include <selene/base/io/FileUtils.hpp>
#include <selene/img/dynamic/DynImage.hpp>
#include <selene/img/pixel/PixelTypeAliases.hpp>
#include <selene/img/typed/ImageTypeAliases.hpp>
#include <selene/base/io/FileWriter.hpp>
#include <selene/img_io/IO.hpp>

#include <selene/img/interop/ImageToDynImage.hpp>
#include <selene/img/interop/DynImageToImage.hpp>

#include <iostream>

int main(int argc, char **argv) {
    sane_init(nullptr, nullptr);
    const SANE_Device** device_list;
    sane_get_devices(&device_list, true);
    auto device = device_list[0];
    SANE_Handle handle;
    sane_open(device->name, &handle);
    
    constexpr auto test_picture = 10;
    constexpr auto mode = 2;

    constexpr auto grid = 3;
    constexpr auto colours = 2;

    auto mode_option =  sane_get_option_descriptor(handle, mode);
    sane_control_option(handle, mode, SANE_ACTION_SET_VALUE, (void*) mode_option->constraint.string_list[1], nullptr);
    
    auto option = sane_get_option_descriptor(handle, test_picture);
    sane_control_option(handle, test_picture, SANE_ACTION_SET_VALUE, (void*) option->constraint.string_list[grid], nullptr);

    SANE_Parameters params;
    sane_get_parameters(handle, &params);

    auto height = sln::PixelLength{params.lines};
    auto width = sln::PixelLength{params.pixels_per_line};
    short depth = params.depth / 8;
    short channels = params.format==SANE_FRAME_RGB?3:1;
    
    sln::DynImage input_buffer{{width, height, channels, depth}, sln::ImageRowAlignment{0}};

    sane_start(handle);
    int total_read = 0;
    int read = 0;
    while(total_read < input_buffer.total_bytes()) {
        sane_read(handle, reinterpret_cast<unsigned char*>(input_buffer.data<sln::PixelRGB_8u>()) + total_read, input_buffer.total_bytes(), &read);
        total_read += read;
    }
    sane_close(handle);


    // Doesn't work
    auto output_empty_filename_jpg = "empty_test.jpg";
    sln::write_image(input_buffer, sln::ImageFormat::JPEG, sln::FileWriter(output_empty_filename_jpg));

    // WORKS
    const sln::Image<sln::PixelRGB_8u> img = sln::to_image<sln::PixelRGB_8u>(std::move(input_buffer));
    const auto img_data_1 = sln::to_dyn_image_view(img);
    
    auto output_filename_jpg = "test.jpg";
    sln::write_image(img_data_1, sln::ImageFormat::JPEG, sln::FileWriter(output_filename_jpg));
}

[Question] Perform interpolation on vector of pixels?

Hi,

I'm so sorry if this is not the right place to ask this. If it's not please let me know, I will close this and open the new one in appropriate place.

I'm looking for a way to perform interpolation to scale the image I get from network and stumbled upon Selene through the Awesome GIS repo. Unfortunately, I cannot get this to work for my use case.

I'm using SFML library to write a small application that receives a vector of raw pixel from network, a UDP socket, and renders it on screen. The pixels are RGBA pixels. They are stored in a std::vector<unsigned char>. So every four values in the vector makes a pixel. I was able to use that vector to fill a SFML texture and displayed that. Everything worked great.

However, the problem is that to save the bandwidth, the imaged was sent out with just 256x256 in size. And I want to scale that into a bigger image, I can scale the sprite inside SFML but it makes everything blurry. That led me to find Selene. I was able to convert that std::vector<unsigned char> to std::vector<sln::PixelRGBA_8u> by just looping through the vector and manually push back the pixel. But I'm stuck at how to convert that new vector to an image in Selene and then do the interpolation on that image, or even just do the interpolation right on the vector of pixels itself. If possible, can you point me to the direction where I can find some more instruction on how to do that?

Thank you so much for your time and help.

Q: How Selene compares to Boost.GIL

Question: would be able to provide brief comparison on how Selene is similar/different to Boost.GIL?

A similar reference as you make to OpenCV in the Rationale document would be helpful for prospect users considering Selene.

Some deprecated function

FileReader.hpp use function fopen and strerror, these functions are marked as deprecated in MSVC(for me, Visual Studio 2017). It requires a definition of macro _CRT_SECURE_NO_WARNINGS or use the suggested fopen_s or strerror_s. Why don't you choose std::ifstream?

Lower cmake to 3.10?

Is it possible to lower cmake requirement to 3.10? Which is default on ubuntu 18.04?

compile error building tests on apple M1 machine

Seeing:

In file included from /Users/sehome/projects/selene/test/selene/Catch.cpp:6:
/Users/sehome/projects/selene/external/Catch2/single_include/catch2/catch.hpp:7937:13: error: unrecognized instruction mnemonic, did you mean: bit, cnt, hint, ins, not?
            CATCH_BREAK_INTO_DEBUGGER();
            ^
/Users/sehome/projects/selene/external/Catch2/single_include/catch2/catch.hpp:7651:79: note: expanded from macro 'CATCH_BREAK_INTO_DEBUGGER'
    #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }()
                                                                              ^
./projects/selene/external/Catch2/single_include/catch2/catch.hpp:7630:34: note: expanded from macro 'CATCH_TRAP'
    #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
                                 ^
<inline asm>:1:2: note: instantiated into assembly here
        int $3
        ^
1 error generated.

It looks like this is a bug in Catch2, which can be fixed by upgrading the library submodule: catchorg/Catch2#1127

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.