davidstutz / superpixel-benchmark

An extensive evaluation and comparison of 28 state-of-the-art superpixel algorithms on 5 datasets.
398 stars 109 forks source link

potential contrib: help with compilation #15

Closed mathematicalmichael closed 10 months ago

mathematicalmichael commented 1 year ago

Hi!

First, thank you for this repo. I've found it tremendously helpful and have been building / using docker images with it for some time. I don't have something super modern working at the moment, but for what it's worth, here's a Dockerfile that's worked for me:

FROM python:3.11.4-buster
RUN export DEBIAN_FRONTEND="noninteractive"
ENV APP_HOME /app

RUN apt-get update && \
    apt-get install -qq -y \
        build-essential \
        autotools-dev \
        automake \
        cmake \
        libboost-all-dev \
        libeigen3-dev \
        libopencv-dev \
        cimg-dev \
        cimg-doc \
        cimg-examples \
        libpng-dev \
        libpng++-dev \
        git \
        potrace \
        graphicsmagick-imagemagick-compat \
        ffmpeg \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir -p $APP_HOME/

# libglog 0.3.3 is needed, edit cmake/FindGlog.cmake if using below (already done in my branch, see next comments)
RUN apt-get update && \
    apt-get install -qq -y \
        libgoogle-glog-dev \
        libpcl-dev \
        libusb-1.0-0 \
        libopenni2-0 \
        libpcap0.8 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN cd /usr/local/include && \
    ln -sf eigen3/Eigen Eigen
    #ln -sf eigen3/unsupported unsupported
# the commented out line above helps depending on the base image. python ones dont need it.

# Superpixel comparison benchmarks. This is from the develop branch of mathematicalmichael/superpixel-benchmark:
# https://github.com/mathematicalmichael/superpixel-benchmark/tree/1c653080a13cb34a8f3c40e49e7979a4ca5d3c53
# which contains my minor updates. not all algorithms are built, but many are. 
# cd superpixel-benchmark && git submodule update --init --recursive

COPY ./superpixel-benchmark $APP_HOME/super
RUN cd /app/super && \
    mkdir build && \
    cd build && \
    #cmake .. -DGLOG_ROOT_DIR=/app/glog && \
    cmake .. && \
    make

WORKDIR $APP_HOME
# dumb-init for proper handling of control-signals when interacting with the container
RUN apt-get update && \
    apt-get install -qq -y \
    dumb-init \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# adding a non-root user, helps with permissions on mounted volumes
RUN useradd -m super
RUN chown -R super $APP_HOME
USER super
ENTRYPOINT ["dumb-init", "--"]

This isn't a minimal image, though I can easily modify the above to remove the utils. I installed graphicsmagick to deal with things like image resizing and reformatting (png/jpg -> bmp). ffmpeg for animating outputs and extracting frames (movie -> images -> superpixels -> movie) python for other scripting.

my oldest image was this, and is quite minimal:

FROM ubuntu:14.04
RUN export DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && \
    apt-get install -qq -y \
        build-essential \
        cmake \
        libboost-all-dev \
        libopencv-dev \
        cimg-dev \
        cimg-doc \
        cimg-examples \
        libpng-dev \
        libpng++-dev \
        git \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /app && cd /app && \
    git clone https://github.com/davidstutz/glog && \
    cd glog && \
    git reset --hard 0b0b022 && \
    ./configure && \
    make

WORKDIR /app
# may need to change this to reference a specific commit
RUN cd /app/ && \
    git clone https://github.com/davidstutz/superpixel-benchmark.git && \
    cd superpixel-benchmark && \
    git submodule update --init --recursive && \
    mkdir build && \
    cd build && \
    cmake .. -DGLOG_ROOT_DIR=/app/glog && \
    make

If you'd like a PR, please let me know. But I figured I'd give back in at least one small way. Thank you again

davidstutz commented 1 year ago

Sure, a PR would be great - maybe you can also add a note in the update section of the README and update docs/BUILDING.md? Thanks!

mathematicalmichael commented 1 year ago

will do! just need to find some time to revisit the changes I made to the cmake file in order to document it properly.

preference for the inclusion of minimal image, "bloated" image, or both?

davidstutz commented 1 year ago

Great :)

No preference - whatever you deem appropriate for reproducibility.