prabindh / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
122 stars 46 forks source link

Arapaho: "libdarknet-spp-shared.so: no such file or directory" #17

Closed halt9 closed 7 years ago

halt9 commented 7 years ago

Following compilation instructions of arapaho, I can compile it but I can't get it to work. Here's my Makefile:

COMMON= 
CFLAGS=-Wall -Wfatal-errors 

OPTS=-O0 -g
CFLAGS+=$(OPTS)

COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand

COMMON+= -DCUDNN 
CFLAGS+= -DCUDNN
LDFLAGS+= -lcudnn

COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv-3.2.0-dev` 
COMMON+= `pkg-config --cflags opencv-3.2.0-dev` 

arapaho: clean
    g++ test.cpp arapaho.cpp  $(COMMON) $(CFLAGS) -I../src/ -L./ $(LDFLAGS) -ldarknet-cpp-shared -L/usr/local/lib -std=c++11 -o arapaho.out

clean:
    rm -rf ./arapaho.out    

The parameters are all copy-pasted from my Makefile for darknet. This compiles fine. Yet when I try to run it I get: ./arapaho.out: error while loading shared libraries: libdarknet-cpp-shared.so: cannot open shared object file: No such file or directory despite the lib file being in the same directory and rwx-enabled.

prabindh commented 7 years ago

Perhaps some other dependent lib is not found - can you try

ldd ./libdarknet-cpp-shared.so

halt9 commented 7 years ago

I won't have access to the machine until tomorrow, but darknet itself runs fine - shouldn't the library file work as well?

prabindh commented 7 years ago

It should, which is why ldd will help in finding what is going on.

halt9 commented 7 years ago

I did an ldd, and also an lddtree (from pax-utils). Here's the ldd:

linux-vdso.so.1 =>  (0x00007ffc823fc000)
        libopencv_highgui3.so.3.2 => /opt/ros/kinetic/lib/libopencv_highgui3.so.3.2 (0x00007f1263002000)
        libopencv_videoio3.so.3.2 => /opt/ros/kinetic/lib/libopencv_videoio3.so.3.2 (0x00007f1262dd8000)
        libopencv_imgcodecs3.so.3.2 => /opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.2 (0x00007f12629b4000)
        libopencv_core3.so.3.2 => /opt/ros/kinetic/lib/libopencv_core3.so.3.2 (0x00007f1261ce6000)
        libcudart.so.8.0 => /usr/local/cuda-8.0/lib64/libcudart.so.8.0 (0x00007f1261a7f000)
        libcublas.so.8.0 => /usr/local/cuda-8.0/lib64/libcublas.so.8.0 (0x00007f125f0cf000)
        libcurand.so.8.0 => /usr/local/cuda-8.0/lib64/libcurand.so.8.0 (0x00007f125b166000)
        libcudnn.so.5 => /usr/lib/x86_64-linux-gnu/libcudnn.so.5 (0x00007f1255eb3000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1255b31000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1255828000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1255611000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f12553f4000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f125502b000)
        libQt5Widgets.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 (0x00007f125499d000)
        libQt5Test.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Test.so.5 (0x00007f1254969000)
        libQt5Gui.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f1254421000)
        libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f1253f4a000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1253d42000)
        libavcodec-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56 (0x00007f1252916000)
        libavformat-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavformat-ffmpeg.so.56 (0x00007f1252517000)
        libavutil-ffmpeg.so.54 => /usr/lib/x86_64-linux-gnu/libavutil-ffmpeg.so.54 (0x00007f12522a8000)
        libswscale-ffmpeg.so.3 => /usr/lib/x86_64-linux-gnu/libswscale-ffmpeg.so.3 (0x00007f1252019000)
        libopencv_imgproc3.so.3.2 => /opt/ros/kinetic/lib/libopencv_imgproc3.so.3.2 (0x00007f1250861000)
        libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f1250608000)
        libwebp.so.5 => /usr/lib/x86_64-linux-gnu/libwebp.so.5 (0x00007f12503ac000)
        libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f1250186000)
        libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f124ff12000)
        libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1 (0x00007f124fcbb000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f124faa0000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f124f89c000)
        /lib64/ld-linux-x86-64.so.2 (0x000055b62495f000)
        libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f124f648000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f124f337000)
        libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f124effd000)
        libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f124ed9e000)
        libGL.so.1 => /usr/lib/nvidia-375/libGL.so.1 (0x00007f124eb0e000)
        libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55 (0x00007f124e6ac000)
        libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55 (0x00007f124e317000)
        libpcre16.so.3 => /usr/lib/x86_64-linux-gnu/libpcre16.so.3 (0x00007f124e0b1000)
        libswresample-ffmpeg.so.1 => /usr/lib/x86_64-linux-gnu/libswresample-ffmpeg.so.1 (0x00007f124de93000)
        libva.so.1 => /usr/lib/x86_64-linux-gnu/libva.so.1 (0x00007f124dc77000)
        libzvbi.so.0 => /usr/lib/x86_64-linux-gnu/libzvbi.so.0 (0x00007f124d9ec000)
        libxvidcore.so.4 => /usr/lib/x86_64-linux-gnu/libxvidcore.so.4 (0x00007f124d6d8000)
        libx265.so.79 => /usr/lib/x86_64-linux-gnu/libx265.so.79 (0x00007f124cab8000)
        libx264.so.148 => /usr/lib/x86_64-linux-gnu/libx264.so.148 (0x00007f124c714000)
        libwavpack.so.1 => /usr/lib/x86_64-linux-gnu/libwavpack.so.1 (0x00007f124c4eb000)
        libvpx.so.3 => /usr/lib/x86_64-linux-gnu/libvpx.so.3 (0x00007f124c0c6000)
        libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f124be1d000)
        libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f124bbf1000)
        libtwolame.so.0 => /usr/lib/x86_64-linux-gnu/libtwolame.so.0 (0x00007f124b9cd000)
        libtheoraenc.so.1 => /usr/lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007f124b78e000)
        libtheoradec.so.1 => /usr/lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007f124b574000)
        libspeex.so.1 => /usr/lib/x86_64-linux-gnu/libspeex.so.1 (0x00007f124b35a000)
        libsnappy.so.1 => /usr/lib/x86_64-linux-gnu/libsnappy.so.1 (0x00007f124b152000)
        libshine.so.3 => /usr/lib/x86_64-linux-gnu/libshine.so.3 (0x00007f124af45000)
        libschroedinger-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libschroedinger-1.0.so.0 (0x00007f124ac6f000)
        libopus.so.0 => /usr/lib/x86_64-linux-gnu/libopus.so.0 (0x00007f124aa25000)
        libopenjpeg.so.5 => /usr/lib/x86_64-linux-gnu/libopenjpeg.so.5 (0x00007f124a802000)
        libmp3lame.so.0 => /usr/lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007f124a58c000)
        libgsm.so.1 => /usr/lib/x86_64-linux-gnu/libgsm.so.1 (0x00007f124a37e000)
        libcrystalhd.so.3 => /usr/lib/x86_64-linux-gnu/libcrystalhd.so.3 (0x00007f124a163000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f1249f40000)
        libssh-gcrypt.so.4 => /usr/lib/x86_64-linux-gnu/libssh-gcrypt.so.4 (0x00007f1249cf7000)
        librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f1249ada000)
        libmodplug.so.1 => /usr/lib/x86_64-linux-gnu/libmodplug.so.1 (0x00007f124974f000)
        libgme.so.0 => /usr/lib/x86_64-linux-gnu/libgme.so.0 (0x00007f1249501000)
        libbluray.so.1 => /usr/lib/x86_64-linux-gnu/libbluray.so.1 (0x00007f12492b7000)
        libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f1248f87000)
        libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f1248d77000)
        libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f1248b68000)
        libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f1248960000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f12486ef000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f12484cd000)
        libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f1248223000)
        libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f1247ffd000)
        libGLX.so.0 => /usr/lib/nvidia-375/libGLX.so.0 (0x00007f1247dcd000)
        libGLdispatch.so.0 => /usr/lib/nvidia-375/libGLdispatch.so.0 (0x00007f1247ae4000)
        libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55 (0x00007f124602c000)
        libsoxr.so.0 => /usr/lib/x86_64-linux-gnu/libsoxr.so.0 (0x00007f1245dc7000)
        libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f1245bbb000)
        libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f12459b2000)
        liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0 (0x00007f1245731000)
        libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f1245450000)
        libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f1245205000)
        libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f1244fd2000)
        libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f1244d9c000)
        libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f1244b1b000)
        libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f1244760000)
        libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f124451d000)
        libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f12442b8000)
        libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007f1244085000)
        libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f1243e72000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f1243c6d000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f1243a67000)
        libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f1243854000)
        libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f1243632000)
        libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f124341d000)
        libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f124314b000)
        libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f1242f1c000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f1242d17000)
        libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f1242b0c000)
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f12428e2000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f12426de000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f12424c2000)

and here's the lddtree:

libdarknet-cpp-shared.so => ./libdarknet-cpp-shared.so (interpreter => none)
    libopencv_highgui3.so.3.2 => /opt/ros/kinetic/lib/libopencv_highgui3.so.3.2
        libQt5Widgets.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
            libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
                libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6
            libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0
                libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3
            libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6
                libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1
                    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6
                    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
                libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
                    ld-linux-x86-64.so.2 => /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
        libQt5Test.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Test.so.5
        libQt5Gui.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
            libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0
            libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
                libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6
                libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3
            libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1
            libGL.so.1 => /usr/lib/nvidia-375/libGL.so.1
                libGLX.so.0 => /usr/lib/nvidia-375/libGLX.so.0
                    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6
                libGLdispatch.so.0 => /usr/lib/nvidia-375/libGLdispatch.so.0
        libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
            libicui18n.so.55 => /usr/lib/x86_64-linux-gnu/libicui18n.so.55
            libicuuc.so.55 => /usr/lib/x86_64-linux-gnu/libicuuc.so.55
                libicudata.so.55 => /usr/lib/x86_64-linux-gnu/libicudata.so.55
            libpcre16.so.3 => /usr/lib/x86_64-linux-gnu/libpcre16.so.3
            librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
    libopencv_videoio3.so.3.2 => /opt/ros/kinetic/lib/libopencv_videoio3.so.3.2
        libavcodec-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavcodec-ffmpeg.so.56
            libswresample-ffmpeg.so.1 => /usr/lib/x86_64-linux-gnu/libswresample-ffmpeg.so.1
                libsoxr.so.0 => /usr/lib/x86_64-linux-gnu/libsoxr.so.0
                    libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1
            libva.so.1 => /usr/lib/x86_64-linux-gnu/libva.so.1
            libzvbi.so.0 => /usr/lib/x86_64-linux-gnu/libzvbi.so.0
            libxvidcore.so.4 => /usr/lib/x86_64-linux-gnu/libxvidcore.so.4
            libx265.so.79 => /usr/lib/x86_64-linux-gnu/libx265.so.79
                libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1
            libx264.so.148 => /usr/lib/x86_64-linux-gnu/libx264.so.148
            libwebp.so.5 => /usr/lib/x86_64-linux-gnu/libwebp.so.5
            libwavpack.so.1 => /usr/lib/x86_64-linux-gnu/libwavpack.so.1
            libvpx.so.3 => /usr/lib/x86_64-linux-gnu/libvpx.so.3
            libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2
            libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0
                libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0
            libtwolame.so.0 => /usr/lib/x86_64-linux-gnu/libtwolame.so.0
            libtheoraenc.so.1 => /usr/lib/x86_64-linux-gnu/libtheoraenc.so.1
            libtheoradec.so.1 => /usr/lib/x86_64-linux-gnu/libtheoradec.so.1
            libspeex.so.1 => /usr/lib/x86_64-linux-gnu/libspeex.so.1
            libsnappy.so.1 => /usr/lib/x86_64-linux-gnu/libsnappy.so.1
            libshine.so.3 => /usr/lib/x86_64-linux-gnu/libshine.so.3
            libschroedinger-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libschroedinger-1.0.so.0
                liborc-0.4.so.0 => /usr/lib/x86_64-linux-gnu/liborc-0.4.so.0
            libopus.so.0 => /usr/lib/x86_64-linux-gnu/libopus.so.0
            libopenjpeg.so.5 => /usr/lib/x86_64-linux-gnu/libopenjpeg.so.5
            libmp3lame.so.0 => /usr/lib/x86_64-linux-gnu/libmp3lame.so.0
            libgsm.so.1 => /usr/lib/x86_64-linux-gnu/libgsm.so.1
            libcrystalhd.so.3 => /usr/lib/x86_64-linux-gnu/libcrystalhd.so.3
            liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5
        libavformat-ffmpeg.so.56 => /usr/lib/x86_64-linux-gnu/libavformat-ffmpeg.so.56
            libssh-gcrypt.so.4 => /usr/lib/x86_64-linux-gnu/libssh-gcrypt.so.4
                libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20
                    libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0
                libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2
                    libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3
                        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1
                        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2
                    libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3
                    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2
                    libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0
            librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1
                libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4
                libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6
                libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10
            libmodplug.so.1 => /usr/lib/x86_64-linux-gnu/libmodplug.so.1
            libgme.so.0 => /usr/lib/x86_64-linux-gnu/libgme.so.0
            libbluray.so.1 => /usr/lib/x86_64-linux-gnu/libbluray.so.1
                libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2
                libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1
                    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1
            libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30
                libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0
                libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11
                libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6
            libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0
        libavutil-ffmpeg.so.54 => /usr/lib/x86_64-linux-gnu/libavutil-ffmpeg.so.54
        libswscale-ffmpeg.so.3 => /usr/lib/x86_64-linux-gnu/libswscale-ffmpeg.so.3
        libopencv_imgproc3.so.3.2 => /opt/ros/kinetic/lib/libopencv_imgproc3.so.3.2
    libopencv_imgcodecs3.so.3.2 => /opt/ros/kinetic/lib/libopencv_imgcodecs3.so.3.2
        libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8
        libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5
            libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0
        libjasper.so.1 => /usr/lib/x86_64-linux-gnu/libjasper.so.1
    libopencv_core3.so.3.2 => /opt/ros/kinetic/lib/libopencv_core3.so.3.2
    libcudart.so.8.0 => /usr/local/cuda-8.0/lib64/libcudart.so.8.0
    libcublas.so.8.0 => /usr/local/cuda-8.0/lib64/libcublas.so.8.0
    libcurand.so.8.0 => /usr/local/cuda-8.0/lib64/libcurand.so.8.0
    libcudnn.so.5 => /usr/lib/x86_64-linux-gnu/libcudnn.so.5
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
prabindh commented 7 years ago

Could you please try - from linux cmd line - type below

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

before you execute arapaho ?

halt9 commented 7 years ago

Same error. My LD_LIBRARY_PATH already includes CUDA's libraries.

Would it help if I attached my .so file so you can inspect it?

libdarknet-cpp-shared.zip

prabindh commented 7 years ago

I think the issue is because, you are linking (in the Makefile) against a version of OpenCV in /usr/local/lib, but somehow loader is picking up from /opt/ros/kinetic/lib/. Is this likely ?

halt9 commented 7 years ago

The pkg-config --libs opencv-3.2.0-dev command actually returns files in /opt/ros/kinetic/lib - removing the /usr/local/lib line did not change the end result.

By the way, ldd arapaho.out produced libdarknet-cpp-shared.so => not found

prabindh commented 7 years ago

Did you see any warning messages in the linking process of arapaho.out (libraries not found, ..) ?

prabindh commented 7 years ago

The below indicates a dependent library was not found, though it shows libdarknet-cpp-shared.so,

ldd arapaho.out produced libdarknet-cpp-shared.so => not found

halt9 commented 7 years ago

I only get warning: left operand of comma operator has no effect [-Wunused-value] type output from the makefile, no linking related messages.

prabindh commented 7 years ago

I still suspect it is to do with OpenCV. Since I am unable to replicate it, could you try once disabling OPENCV flag in both darknet makefile and the arapaho makefile ? Arapaho test wrapper needs opencv, so you will need to just comment out the opencv calls, to make it to build..

prabindh commented 7 years ago

Will check again in a couple of hours.

halt9 commented 7 years ago

Solved it! ran it as LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./arapaho.out

But now I get error Warning: Read classes from cfg (80) > maxClasses (2)Could not load the AV file input.mp4 even though I have an input.jpg in the folder

prabindh commented 7 years ago

Pls change the input file name in test. Cpp

On Thu, Apr 6, 2017 at 12:05 AM, halt9notifications@github.com wrote:
Solved it! ran it as LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./arapaho.out

But now I get error Warning: Read classes from cfg (80) > maxClasses (2)Could not load the AV file input.mp4 even though I have an input.jpg in the folder

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub, or mute the thread.

halt9 commented 7 years ago

Wait, never mind, it very briefly shows a window then closes it. I missed it since it was so fast. Seems like it might be working, but it's hard to tell since the window is immediately closed. Is there a way to output the result to the command line or save to a file? Here's the full output:

layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    2 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64
    3 max          2 x 2 / 2   208 x 208 x  64   ->   104 x 104 x  64
    4 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    5 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64
    6 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    7 max          2 x 2 / 2   104 x 104 x 128   ->    52 x  52 x 128
    8 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
    9 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128
   10 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
   11 max          2 x 2 / 2    52 x  52 x 256   ->    26 x  26 x 256
   12 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   13 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   14 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   15 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   16 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   17 max          2 x 2 / 2    26 x  26 x 512   ->    13 x  13 x 512
   18 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   19 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   20 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   21 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   22 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   23 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   24 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   25 route  16
   26 reorg              / 2    26 x  26 x 512   ->    13 x  13 x2048
   27 route  26 24
   28 conv   1024  3 x 3 / 1    13 x  13 x3072   ->    13 x  13 x1024
   29 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425
   30 detection
Loading weights from input.weights...Done!
init done
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
Warning: Read classes from cfg (80) > maxClasses (2)Could not load the AV file input.mp4

edit: I'm running this through SSH, but normal darknet works and I can see the window and boxes.

With some effort, I was able to capture the arapaho window. It's just a black box and it's not even the same size as input.jpg.

prabindh commented 7 years ago

I dont think ut worked right.  If detection step was successful you wud see the log as in arapahoreadme.txt And window stays open. Sent from Yahoo Mail on Android

On Thu, Apr 6, 2017 at 12:18 AM, halt9notifications@github.com wrote:
Wait, never mind, it very briefly shows a window then closes it. I missed it since it was so fast. Seems like it might be working, but it's hard to tell since the window is immediately closed. Is there a way to output the result to the command line or save to a file? Here's the full output: layer filters size input output 0 conv 32 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 32 1 max 2 x 2 / 2 416 x 416 x 32 -> 208 x 208 x 32 2 conv 64 3 x 3 / 1 208 x 208 x 32 -> 208 x 208 x 64 3 max 2 x 2 / 2 208 x 208 x 64 -> 104 x 104 x 64 4 conv 128 3 x 3 / 1 104 x 104 x 64 -> 104 x 104 x 128 5 conv 64 1 x 1 / 1 104 x 104 x 128 -> 104 x 104 x 64 6 conv 128 3 x 3 / 1 104 x 104 x 64 -> 104 x 104 x 128 7 max 2 x 2 / 2 104 x 104 x 128 -> 52 x 52 x 128 8 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 9 conv 128 1 x 1 / 1 52 x 52 x 256 -> 52 x 52 x 128 10 conv 256 3 x 3 / 1 52 x 52 x 128 -> 52 x 52 x 256 11 max 2 x 2 / 2 52 x 52 x 256 -> 26 x 26 x 256 12 conv 512 3 x 3 / 1 26 x 26 x 256 -> 26 x 26 x 512 13 conv 256 1 x 1 / 1 26 x 26 x 512 -> 26 x 26 x 256 14 conv 512 3 x 3 / 1 26 x 26 x 256 -> 26 x 26 x 512 15 conv 256 1 x 1 / 1 26 x 26 x 512 -> 26 x 26 x 256 16 conv 512 3 x 3 / 1 26 x 26 x 256 -> 26 x 26 x 512 17 max 2 x 2 / 2 26 x 26 x 512 -> 13 x 13 x 512 18 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 19 conv 512 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 512 20 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 21 conv 512 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 512 22 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024 23 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024 24 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024 25 route 16 26 reorg / 2 26 x 26 x 512 -> 13 x 13 x2048 27 route 26 24 28 conv 1024 3 x 3 / 1 13 x 13 x3072 -> 13 x 13 x1024 29 conv 425 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 425 30 detection Loading weights from input.weights...Done! init done Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface. Warning: Read classes from cfg (80) > maxClasses (2)Could not load the AV file input.mp4

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub, or mute the thread.

halt9 commented 7 years ago

Is there a way to debug it?

prabindh commented 7 years ago

Did you change the input file name INPUT_AV_FILE to input.jpg in test.cpp (Line 36) ?

halt9 commented 7 years ago

Yeah, now I get a window popup with a part of the image, then it goes away fast saying

QXcbConnection: XCB error: 145 (Unknown), sequence: 164, resource id: 0, major code: 139 (Unknown), minor code: 20
cap.read failed/EoF - AV file input.jpg
prabindh commented 7 years ago

Looks like an OpenCV error reading the input.jpg. Something related to video/image plugins in the system ? The original comment said [6] detections were done. Was that another image ?

halt9 commented 7 years ago

Sorry, I just posted the last line. Here's the full output:

layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    2 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64
    3 max          2 x 2 / 2   208 x 208 x  64   ->   104 x 104 x  64
    4 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    5 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64
    6 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    7 max          2 x 2 / 2   104 x 104 x 128   ->    52 x  52 x 128
    8 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
    9 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128
   10 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
   11 max          2 x 2 / 2    52 x  52 x 256   ->    26 x  26 x 256
   12 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   13 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   14 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   15 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   16 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   17 max          2 x 2 / 2    26 x  26 x 512   ->    13 x  13 x 512
   18 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   19 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   20 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   21 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   22 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   23 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   24 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   25 route  16
   26 reorg              / 2    26 x  26 x 512   ->    13 x  13 x2048
   27 route  26 24
   28 conv   1024  3 x 3 / 1    13 x  13 x3072   ->    13 x  13 x1024
   29 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425
   30 detection
Loading weights from input.weights...Done!
init done
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
Warning: Read classes from cfg (80) > maxClasses (2)==> Detected [6] objects in [0.130110] seconds
QXcbConnection: XCB error: 145 (Unknown), sequence: 164, resource id: 0, major code: 139 (Unknown), minor code: 20
cap.read failed/EoF - AV file input.jpg

It very briefly shows the image, but I can't tell if it draws detections on it.

prabindh commented 7 years ago

Please pull master, for an update to the test code. Since the jpg is just one frame, the window shows and exits immediately. You can pull the latest code that waits for the user to close the window instead of just exiting. (https://github.com/prabindh/darknet/commit/463a12d7327c12c980dfb75ac339b8584ecdb71c)

halt9 commented 7 years ago

I didn't know you could read a single image with VideoCapture. It works now, and draws boxes. BBut it only seems to draw a box around one object instead of 6 detections.

prabindh commented 7 years ago

Very good, could you post a screenshot ?

It draws just one, the 0th block, per current code. All boxes in a future commit,

halt9 commented 7 years ago

arapaho_screenshot_06 04 2017

prabindh commented 7 years ago

ok thanks ! Looks like you are not using the latest tree, as it adds class label display also.

halt9 commented 7 years ago

arapaho is from yesterday, though darknet is not because I have some local modifications based on an older version

prabindh commented 7 years ago

Added support for displaying all detected object boundaries and labels. Please get master, commit https://github.com/prabindh/darknet/commit/0e66eed15ef645cd5fcf438fc626c00e05113cf8

halt9 commented 7 years ago

note - this commit seems to change the location it looks for the config/data files? Couldn't open file: data/coco.names is what I get when I run it? Or is it related to my darknet .so file being compiled from different code?

prabindh commented 7 years ago

No, but it does look for the names file you have specified in input.data. Looks like you have specified data/coco.names in there, because that path is relative to the main darknet folder. You can change this to the full path name of the coco.names, or atleast ../data/coco.names, as relative to arapaho folder.

halt9 commented 7 years ago

You're right, I fixed that now. But I'm back to the EOF error despite waitKey() being in my test.cpp


layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    2 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64
    3 max          2 x 2 / 2   208 x 208 x  64   ->   104 x 104 x  64
    4 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    5 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64
    6 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    7 max          2 x 2 / 2   104 x 104 x 128   ->    52 x  52 x 128
    8 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
    9 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128
   10 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
   11 max          2 x 2 / 2    52 x  52 x 256   ->    26 x  26 x 256
   12 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   13 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   14 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   15 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   16 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   17 max          2 x 2 / 2    26 x  26 x 512   ->    13 x  13 x 512
   18 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   19 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   20 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   21 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   22 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   23 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   24 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   25 route  16
   26 reorg              / 2    26 x  26 x 512   ->    13 x  13 x2048
   27 route  26 24
   28 conv   1024  3 x 3 / 1    13 x  13 x3072   ->    13 x  13 x1024
   29 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425
   30 detection
Loading weights from input.weights...Done!
Warning: Read classes from cfg (80) > maxClasses (2)
init done
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
==> Detected [6] objects in [0.129176] seconds
QXcbConnection: XCB error: 145 (Unknown), sequence: 164, resource id: 0, major code: 139 (Unknown), minor code: 20
cap.read failed/EoF - AV file input.jpg
prabindh commented 7 years ago

clean and rebuild ?

halt9 commented 7 years ago

Now I'm getting compilation errors I didn't get before:

/tmp/cc6VnX7q.o: In function `ArapahoV2::Detect(ArapahoV2ImageBuff&, float, float, int&)':
~/darknet/arapaho/arapaho.cpp:220: undefined reference to `get_region_boxes'
~/darknet/arapaho/arapaho.cpp:225: undefined reference to `do_nms_obj'
~/darknet/arapaho/arapaho.cpp:228: undefined reference to `do_nms_sort'
collect2: error: ld returned 1 exit status
Makefile:26: recipe for target 'arapaho' failed
make: *** [arapaho] Error 1
halt9 commented 7 years ago

Note, I'm using my Makefile I posted above (with the modifications we discussed) instead of yours

prabindh commented 7 years ago

Full log would be better to see if any symbols were missing. Nothing has changed in that code however, so if it had linked earlier it should link now.

halt9 commented 7 years ago
make arapaho
rm -rf ./arapaho.out
g++ test.cpp arapaho.cpp   -DGPU -I/usr/local/cuda/include/ -DCUDNN  -DOPENCV `pkg-config --cflags opencv-3.2.0-dev`  -Wall -Wfatal-errors  -O0 -g -DGPU -DCUDNN -DOPENCV -I../src/ -L./ -lm -pthread  -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -lcudnn `pkg-config --libs opencv-3.2.0-dev`  -ldarknet-cpp-shared -std=c++11 -o arapaho.out
test.cpp: In function ‘int main()’:
test.cpp:142:64: warning: left operand of comma operator has no effect [-Wunused-value]
             DPRINTF("Image data = %p, w = %d, h = %d\n", image.data, image.size().width, image.size().height);
                                                                ^
test.cpp:142:64: warning: right operand of comma operator has no effect [-Wunused-value]
test.cpp:203:86: warning: left operand of comma operator has no effect [-Wunused-value]
                     DPRINTF("Box #%d: center {x,y}, box {w,h} = [%f, %f, %f, %f]\n", objId, boxes[objId].x, boxes[o
                                                                                      ^
test.cpp:203:106: warning: right operand of comma operator has no effect [-Wunused-value]
                    DPRINTF("Box #%d: center {x,y}, box {w,h} = [%f, %f, %f, %f]\n", objId, boxes[objId].x, boxes[ob
                                                                                                         ^
test.cpp:203:106: warning: right operand of comma operator has no effect [-Wunused-value]
test.cpp:203:122: warning: right operand of comma operator has no effect [-Wunused-value]
    DPRINTF("Box #%d: center {x,y}, box {w,h} = [%f, %f, %f, %f]\n", objId, boxes[objId].x, boxes[objId].y, boxes[ob
                                                                                                         ^
test.cpp:203:138: warning: right operand of comma operator has no effect [-Wunused-value]
 #%d: center {x,y}, box {w,h} = [%f, %f, %f, %f]\n", objId, boxes[objId].x, boxes[objId].y, boxes[objId].w, boxes[ob
                                                                                                         ^
test.cpp:212:69: warning: left operand of comma operator has no effect [-Wunused-value]
                         DPRINTF("Label:%s\n\n", labels[objId].c_str());
                                                                     ^
test.cpp:240:28: warning: statement has no effect [-Wunused-value]
     DPRINTF("Exiting...\n");
                            ^
test.cpp:236:1: warning: label ‘clean_exit’ defined but not used [-Wunused-label]
 clean_exit:
 ^
arapaho.cpp: In member function ‘bool ArapahoV2::Setup(ArapahoV2Params&, int&, int&)’:
arapaho.cpp:54:59: warning: statement has no effect [-Wunused-value]
         DPRINTF("No data configuration file specified!\n");
                                                           ^
arapaho.cpp:64:79: warning: left operand of comma operator has no effect [-Wunused-value]
         DPRINTF("No valid nameList file specified in options file [%s]!\n", p.datacfg);
                                                                               ^
arapaho.cpp:70:76: warning: left operand of comma operator has no effect [-Wunused-value]
         DPRINTF("No valid class names specified in nameList file [%s]!\n", nameListFile);
                                                                            ^
arapaho.cpp:97:40: warning: left operand of comma operator has no effect [-Wunused-value]
     DPRINTF("Setup: net.n = %d\n", net.n);
                                        ^
arapaho.cpp:98:57: warning: left operand of comma operator has no effect [-Wunused-value]
     DPRINTF("net.layers[0].batch = %d\n", net.layers[0].batch);
                                                         ^
arapaho.cpp:103:47: warning: left operand of comma operator has no effect [-Wunused-value]
     DPRINTF("Setup: layers = %d, %d, %d\n", l.w, l.h, l.n);
                                               ^
arapaho.cpp:103:47: warning: right operand of comma operator has no effect [-Wunused-value]
arapaho.cpp:103:52: warning: right operand of comma operator has no effect [-Wunused-value]
     DPRINTF("Setup: layers = %d, %d, %d\n", l.w, l.h, l.n);
                                                    ^
arapaho.cpp:113:53: warning: left operand of comma operator has no effect [-Wunused-value]
     DPRINTF("Image expected w,h = [%d][%d]!\n", net.w, net.h);
                                                     ^
arapaho.cpp:113:53: warning: right operand of comma operator has no effect [-Wunused-value]
arapaho.cpp:136:29: warning: statement has no effect [-Wunused-value]
     DPRINTF("Setup: Done\n");
                             ^
arapaho.cpp: In member function ‘bool ArapahoV2::Detect(ArapahoV2ImageBuff&, float, float, int&)’:
arapaho.cpp:206:62: warning: statement has no effect [-Wunused-value]
         DPRINTF("Detect: Resizing image to match network \n");
                                                              ^
arapaho.cpp:222:50: warning: left operand of comma operator has no effect [-Wunused-value]
     DPRINTF("l.softmax_tree = %p, nms = %f\n", l.softmax_tree, nms);
                                                  ^
arapaho.cpp:222:50: warning: right operand of comma operator has no effect [-Wunused-value]
/tmp/cc6VnX7q.o: In function `ArapahoV2::Detect(ArapahoV2ImageBuff&, float, float, int&)':
~/darknet/arapaho/arapaho.cpp:220: undefined reference to `get_region_boxes'
~/darknet/arapaho/arapaho.cpp:225: undefined reference to `do_nms_obj'
~/darknet/arapaho/arapaho.cpp:228: undefined reference to `do_nms_sort'
collect2: error: ld returned 1 exit status
Makefile:26: recipe for target 'arapaho' failed
make: *** [arapaho] Error 1
halt9 commented 7 years ago

Actually, I got it to compile, but I'm back to

layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    2 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64
    3 max          2 x 2 / 2   208 x 208 x  64   ->   104 x 104 x  64
    4 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    5 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64
    6 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    7 max          2 x 2 / 2   104 x 104 x 128   ->    52 x  52 x 128
    8 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
    9 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128
   10 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
   11 max          2 x 2 / 2    52 x  52 x 256   ->    26 x  26 x 256
   12 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   13 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   14 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   15 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   16 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   17 max          2 x 2 / 2    26 x  26 x 512   ->    13 x  13 x 512
   18 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   19 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   20 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   21 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   22 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   23 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   24 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   25 route  16
   26 reorg              / 2    26 x  26 x 512   ->    13 x  13 x2048
   27 route  26 24
   28 conv   1024  3 x 3 / 1    13 x  13 x3072   ->    13 x  13 x1024
   29 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425
   30 detection
Loading weights from input.weights...Done!
Warning: Read classes from cfg (80) > maxClasses (2)
init done
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
==> Detected [6] objects in [0.129357] seconds
QXcbConnection: XCB error: 145 (Unknown), sequence: 164, resource id: 0, major code: 139 (Unknown), minor code: 20
cap.read failed/EoF - AV file input.jpg

And it shows this window: image

prabindh commented 7 years ago

For a single frame, the log is expected after it displays the frame. The code waits for the ESC key from user, before exiting. But I am not able to see the full window screenshot.

halt9 commented 7 years ago

That's the full window I get. It doesn't display the entire image for whatever reason.

prabindh commented 7 years ago

Could you share the JPG please ?

halt9 commented 7 years ago

Weird, I changed nothing and it just worked now! worked

prabindh commented 7 years ago

It might point to a bad build procedure (including in Arapaho), so keep an eye on it. If you keep facing it, let me know. Thx

halt9 commented 7 years ago

Unrelated to this issue, but I'm now trying to include arapaho in my own code, and I get:

CMakeFiles/detector_node.dir/src/arapaho.cpp.o: In function `ArapahoV2::~ArapahoV2()':
arapaho.cpp:(.text+0xec): undefined reference to `free_ptrs'
CMakeFiles/detector_node.dir/src/arapaho.cpp.o: In function `ArapahoV2::Setup(ArapahoV2Params&, int&, int&)':
arapaho.cpp:(.text+0x180): undefined reference to `read_data_cfg(char*)'
arapaho.cpp:(.text+0x1c4): undefined reference to `option_find_str(list*, char*, char*)'
arapaho.cpp:(.text+0x1e5): undefined reference to `get_labels'
arapaho.cpp:(.text+0x299): undefined reference to `parse_network_cfg(char*)'
arapaho.cpp:(.text+0x2cd): undefined reference to `load_weights(network*, char*)'
arapaho.cpp:(.text+0x2e2): undefined reference to `set_batch_network'
arapaho.cpp:(.text+0x549): undefined reference to `free_ptrs'
CMakeFiles/detector_node.dir/src/arapaho.cpp.o: In function `ArapahoV2::Detect(ArapahoV2ImageBuff&, float, float, int&)':
arapaho.cpp:(.text+0x684): undefined reference to `make_image(int, int, int)'
arapaho.cpp:(.text+0x840): undefined reference to `resize_image(image, int, int)'
arapaho.cpp:(.text+0x90e): undefined reference to `network_predict'
arapaho.cpp:(.text+0x989): undefined reference to `get_region_boxes(layer, int, int, float, float**, box*, int, int*, float)'
arapaho.cpp:(.text+0xa1b): undefined reference to `do_nms_obj(box*, float**, int, int, float)'
arapaho.cpp:(.text+0xa98): undefined reference to `do_nms_sort(box*, float**, int, int, float)'
arapaho.cpp:(.text+0xaf8): undefined reference to `max_index'
CMakeFiles/detector_node.dir/src/arapaho.cpp.o: In function `ArapahoV2::GetBoxes(box*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, int)':
arapaho.cpp:(.text+0xc4c): undefined reference to `max_index'
collect2: error: ld returned 1 exit status
detector/CMakeFiles/detector_node.dir/build.make:264: recipe for target '/home/halt9/dark_ws/devel/lib/detector/detector_node' failed
make[2]: *** [/home/halt9/dark_ws/devel/lib/detector/detector_node] Error 1
CMakeFiles/Makefile2:353: recipe for target 'detector/CMakeFiles/detector_node.dir/all' failed
make[1]: *** [detector/CMakeFiles/detector_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed

Does this mean the .so file is not being recognized by my cmake? The file is in my include directory that cmake is getting passed (line 108) in the cmakelists file here attached.

Also, presumably I need to compile this code with CUDA and CUDNN like I do the arapaho test code? Are these errors related to darknet, arapaho or cuda/cudnn? CMakeLists.txt

prabindh commented 7 years ago
halt9 commented 7 years ago

I got it to build. Will run it later today and let you know if I encounter any issues.

halt9 commented 7 years ago
layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    2 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64
    3 max          2 x 2 / 2   208 x 208 x  64   ->   104 x 104 x  64
    4 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    5 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64
    6 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128
    7 max          2 x 2 / 2   104 x 104 x 128   ->    52 x  52 x 128
    8 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
    9 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128
   10 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256
   11 max          2 x 2 / 2    52 x  52 x 256   ->    26 x  26 x 256
   12 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   13 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   14 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   15 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256
   16 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512
   17 max          2 x 2 / 2    26 x  26 x 512   ->    13 x  13 x 512
   18 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   19 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   20 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   21 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512
   22 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024
   23 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   24 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024
   25 route  16
   26 reorg              / 2    26 x  26 x 512   ->    13 x  13 x2048
   27 route  26 24
   28 conv   1024  3 x 3 / 1    13 x  13 x3072   ->    13 x  13 x1024
   29 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425
   30 detection
Loading weights from /home/halt9/dark_ws/src/detector/src/input.weights...Done!
Error allocating boxes/probs, (nil)/(nil) !
Setup failed!
init done

Any ideas?

Here's my code. Essentially, I took test.cpp and took all the initialization stuff in the constructor of my class, and all the processing stuff in the image callback method imageCb (this is a realtime application):

#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "arapaho.hpp"
#include <chrono>

static const std::string OPENCV_WINDOW = "Image window";
using namespace cv;
class ImageConverter
{
  ros::NodeHandle nh_;
  image_transport::ImageTransport it_;
  image_transport::Subscriber image_sub_;
  image_transport::Publisher image_pub_;
  ArapahoV2* p;
  ArapahoV2Params ap;
  int expectedW = 0, expectedH = 0;

public:
  ImageConverter()
    : it_(nh_)
  {
    // Subscrive to input video feed and publish output video feed
    image_sub_ = it_.subscribe("/camera/rgb/image_raw", 1,
                   &ImageConverter::imageCb, this);
    p = new ArapahoV2();
    if(!p)
    {
        EPRINTF("ARAPAHO FAILED TO INIT\n");
    }

    static char INPUT_DATA_FILE[]    = "/home/halt9/dark_ws/src/detector/src/input.data"; 
    static char INPUT_CFG_FILE[]     = "/home/halt9/dark_ws/src/detector/src/input.cfg";
    static char INPUT_WEIGHTS_FILE[] = "/home/halt9/dark_ws/src/detector/src/input.weights";
    //static char INPUT_AV_FILE[]      = "/home/halt9/dark_ws/src/detector/src/input.jpg"; //"input.mp4"; //// Can take in either Video or Image file
    #define MAX_OBJECTS_PER_FRAME (100)

    ap.datacfg = INPUT_DATA_FILE;
    ap.cfgfile = INPUT_CFG_FILE;
    ap.weightfile = INPUT_WEIGHTS_FILE;
    ap.nms = 0.4;
    ap.maxClasses = 2;

    // Always setup before detect

    bool ret = p->Setup(ap, expectedW, expectedH);
    if(false == ret)
    {
        EPRINTF("Setup failed!\n");
        if(p) delete p;
        p = 0;
    }

    image_pub_ = it_.advertise("/image_converter/output_video", 1);

    cv::namedWindow(OPENCV_WINDOW);
  }

  ~ImageConverter()
  {
    cv::destroyWindow(OPENCV_WINDOW);
  }

  void imageCb(const sensor_msgs::ImageConstPtr& msg)
  {

    cv_bridge::CvImagePtr cv_ptr;
        try
      {
        cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8);
      }
    catch (cv_bridge::Exception& e)
      {
        ROS_ERROR("cv_bridge exception: %s", e.what());
        return;
      }
    ArapahoV2ImageBuff arapahoImage;
    cv::Mat image = cv_ptr->image;

    auto detectionStartTime = std::chrono::system_clock::now();
            bool ret = false;

            box* boxes = 0;
            std::string* labels;
            // Process the image
            arapahoImage.bgr = image.data;
            arapahoImage.w = image.size().width;
            arapahoImage.h = image.size().height;
            arapahoImage.channels = 3;
            // Using expectedW/H, can optimise scaling using HW in platforms where available

            int numObjects = 0;

            // Detect the objects in the image
            p->Detect(
                arapahoImage,
                0.24,
                0.5,
                numObjects);
            std::chrono::duration<double> detectionTime = (std::chrono::system_clock::now() - detectionStartTime);

            printf("==> Detected [%d] objects in [%f] seconds\n", numObjects, detectionTime.count());

            if(numObjects > 0 && numObjects < MAX_OBJECTS_PER_FRAME) // Realistic maximum
            {    
                boxes = new box[numObjects];
                labels = new std::string[numObjects];
                if(!boxes)
                {
                    if(p) delete p;
                    p = 0;
                    return;
                }
                if(!labels)
                {
                    if(p) delete p;
                    p = 0;
                    if(boxes)
                    {
                        delete[] boxes;
                        boxes = NULL;                        
                    }
                    return;
                }

                // Get boxes and labels
                p->GetBoxes(
                    boxes,
                    labels,
                    numObjects
                    );

                int objId = 0;
                int leftTopX = 0, leftTopY = 0, rightBotX = 0,rightBotY = 0;
                for (objId = 0; objId < numObjects; objId++)
                {
                    leftTopX = 1 + arapahoImage.w*(boxes[objId].x - boxes[objId].w / 2);
                    leftTopY = 1 + arapahoImage.h*(boxes[objId].y - boxes[objId].h / 2);
                    rightBotX = 1 + arapahoImage.w*(boxes[objId].x + boxes[objId].w / 2);
                    rightBotY = 1 + arapahoImage.h*(boxes[objId].y + boxes[objId].h / 2);
                    DPRINTF("Box #%d: center {x,y}, box {w,h} = [%f, %f, %f, %f]\n", objId, boxes[objId].x, boxes[objId].y, boxes[objId].w, boxes[objId].h);
                    // Show image and overlay using OpenCV
                    rectangle(image,
                        cvPoint(leftTopX, leftTopY),
                        cvPoint(rightBotX, rightBotY),
                        CV_RGB(255, 0, 0), 1, 8, 0);
                    // Show labels
                    if (labels[objId].c_str())
                    {
                        DPRINTF("Label:%s\n\n", labels[objId].c_str());
                        putText(image, labels[objId].c_str(), cvPoint(leftTopX, leftTopY),
                            FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(200, 200, 250), 1, CV_AA);
                    }
                }

                if (boxes)
                {
                    delete[] boxes;
                    boxes = NULL;
                }
                if (labels)
                {
                    delete[] labels;
                    labels = NULL;
                }   

            }// If objects were detected

    // Draw an example circle on the video stream
    if (cv_ptr->image.rows > 60 && cv_ptr->image.cols > 60)
      cv::circle(cv_ptr->image, cv::Point(50, 50), 10, CV_RGB(255,0,0));

    // Update GUI Window
    cv::imshow(OPENCV_WINDOW, cv_ptr->image);
    cv::waitKey(3);

    // Output modified video stream
    image_pub_.publish(cv_ptr->toImageMsg());
  }
};

int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_converter");
  ImageConverter ic;
  ros::spin();
  return 0;
}

my prediction is that since I initialize Arapaho in the constructor then call it in the imageCb method, maybe that's the cause for error.

prabindh commented 7 years ago

It seems the memory allocation failed, is there enough memory in the system ?

halt9 commented 7 years ago

Yeah, several gigs of unused memory. That seems to me like an error instead of actually being unable to claim memory.

prabindh commented 7 years ago

I can see one issue - // Subscrive to input video feed and publish output video feed image_sub_ = it_.subscribe("/camera/rgb/image_raw", 1, &ImageConverter::imageCb, this);

This needs to be "after" the class is setup.