Sign inSign up

thtung1/opencv

By thtung1

Updated over 7 years ago

OpenCV + opencv_contrib + Python {2,3} + Java + GUI + media/video support + HDF5

Image
0

255

thtung1/opencv repository overview

OpenCV 3.4.4 for Ubuntu 16.04

OpenCV 3.4.4 + opencv_contrib + Python {2,3} + Java + GUI + media/video support + HDF5

Usage

  • Enable display so that container could access it

    xhost +
    
  • Create a new container and mount the home directory. Replace <CONTAINER_NAME> by a name that you love.

    docker run -it --name <CONTAINER_NAME> \
        --user $(id -u) -e DISPLAY --workdir=$(pwd) \
        --volume="/home/$USER:/home/$USER" \
        --volume="/etc/group:/etc/group:ro" \
        --volume="/etc/passwd:/etc/passwd:ro" \
        --volume="/etc/shadow:/etc/shadow:ro" \
        --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
        --volume="/tmp/.X11-unix:/tmp/.X11-unix" \
        thtung1/opencv
    
  • Detach using Ctrl+p->Ctrl+q.

  • Attach to a running docker container: docker attach --sig-proxy=false <CONTAINER_NAME>

  • Start an existing docker container: docker start <CONTAINER_NAME>

Compile an OpenCV example

The original instruction is here

  • write a simple code DisplayImage.cpp
    #include <stdio.h>
    #include <opencv2/opencv.hpp>
    using namespace cv;
    int main(int argc, char** argv )
    {
        Mat image;
        image = imread( argv[1], 1 );
        if ( !image.data )
        {
            printf("No image data \n");
            return -1;
        }
        namedWindow("Display Image", WINDOW_AUTOSIZE );
        imshow("Display Image", image);
        waitKey(0);
        return 0;
    }
    
  • Create a CMakeList.txt or a more detail verion
    cmake_minimum_required(VERSION 2.8)
    project( DisplayImage )
    find_package( OpenCV REQUIRED )
    include_directories( ${OpenCV_INCLUDE_DIRS} )
    add_executable( DisplayImage DisplayImage.cpp )
    target_link_libraries( DisplayImage ${OpenCV_LIBS} )
    
  • Build the program
    mkdir build
    cd build
    cmake ..
    make
    
  • Test the program ./DisplayImage whatever_image.jpg

References

Tag summary

Content type

Image

Digest

Size

1 GB

Last updated

over 7 years ago

docker pull thtung1/opencv