PhotonVision / photonvision

PhotonVision is the free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition.
https://photonvision.org
GNU General Public License v3.0
264 stars 180 forks source link

mrcal intrinsics calculation differences between PV UI and mrcal CLI #1240

Open willtoth opened 6 months ago

willtoth commented 6 months ago

We ran calibration with mrcal enabled on ~80 images. At the end of the process, the intrinsics output were

'intrinsics': [ 964.3192542, 968.4167198, 766.3572371, 656.0259428, -0.03374426143, 0.0003779715023, 0.0008241449289, -0.009869350879, -1.381816601e-06, -0.05084474531, 0.0007160772276, -3.0046612e-06,],

Running the same images using calibrationUtil.py to extract them, but with the mrcal CLI as described here, the intrinsics result is:

'intrinsics': [ 899.2457549, 900.0461934, 828.2229362, 663.153752, 0.007466898828, 0.01911741769, -0.0002934119232, 0.001457083979, 0.1258894663, -0.04345164244, 0.09710341804, 0.1088452785,],

Some data in the mrcal CLI output

# generated on 2024-02-17 22:30:20 with   /usr/bin/mrcal-calibrate-cameras --corners-cache corners.vnl --lensmodel LENSMODEL_OPENCV8 --focal 1900 --object-spacing 0.030 --object-width-n 18 --object-height-n 13 '*.png'
# RMS reprojection error: 0.2 pixels
# Worst residual (by measurement): 0.7 pixels
# Noutliers: 426 out of 18720 total points: 2.3% of the data
# calobject_warp = [-0.00067182  0.00036481]

I also recall the output (number of outlines) being much higher on the PV UI, but I did not capture this unfortunately.

Additionally, the calibration results by running mrcal-show-projection-uncertainty --unset key ./cameramodel_0.cameramodel is quite poor with the output of the python script, but shows quite good values with the output of the mrcal.

Values generated from calibrationUtils.py

image

mrcal CLI

image

Platform (PV):

Platform (mrcal CLI):

JSON file is too big for Github, download here

mrcal results mrcal_camera-0.cameramodel.json

mcm001 commented 6 months ago

I've seen this once before but attributed it to problems converting from photon to mrcal lensmodel file, not an underlying difference. I think the next thing to do is set breakpoints in mrcal and compare seed poses and detected corners and stuff?

willtoth commented 6 months ago

The first time I ran this, the intrinsics calculated between the two were still different, but quite close to eachother. e.g.

mrcal

[ 901.7330686, 902.7952017, 799.8291256, 666.452847, 0.05673155155, -0.08460947181, -0.0009418336749, -0.0008824814115, 0.01479466453, 0.003773460448, 0.006533366048, -0.01477754318,]

PV

[ 900.3160751, 901.470041, 799.8930541, 667.18491, 0.05164757998, -0.08876075177, -0.0006819796758, -0.0008676279577, 0.02579295175, -0.0003870303465, 0.003100190011, -0.004102380634,]

The camera and lens itself is the same model between this and the one in the original message. The values are pretty close. Either way, for the intrinsics calculation, do you expect the mrcal CLI or the results from the PV run to be more accurate?

I won't have time to help debug for the next 2 or so weeks as we prepare for our first event, but I can probably dig into it a bit after that.

randomstring commented 6 months ago

I too am seeing differences between the PV output and what mrcal computes. When I map the uncertainty of the PV calibration I get an all yellow graph like the one linked above.

running calibration like this: (8x8 grid with 1" spacing, correct me if I'm getting the arguments wrong.)

mrcal-calibrate-cameras --corners-cache corners.vnl --lensmodel LENSMODEL_OPENCV8  --focal 1900 --object-spacing .02540125    --object-width-n 7  '*.png'

I get a more reasonable map of error, with a sweet spot in the middle in the 0.2 error rage with more error around the edges.

mcm001 commented 6 months ago

For continuity , are the intrinsics you get different? Or is only the graph.

randomstring commented 6 months ago

Yes, intrinsics were slightly different, mostly values just a few percent different: 685.66 -> 686.27, etc.

dkogan commented 6 months ago

Hello. I'm the mrcal author. Feel free to ask me for help about things mrcal itself is doing; use the mrcal bug tracker maybe. For photonvision problems, I cannot say much, but I'm happy to help @mcm001 or whoever else debug stuff.

mcm001 commented 6 months ago

I think that debugging this is probably going to require I sit down with a debugger and compare inputs to mrcal line-by-line against your implementation again.

Does mrcal-calibrate-cameras by default perform a calibration refinement? Right now, our calibration is just a single call to mrcal_optimize (see here). And we generate seed poses using solvepnp_epnp.

mcm001 commented 6 months ago

camera-0_RESOLVE_WITH_MRCAL_CALIBRATE_CAMERAS.zip

Here's the cameramodel I got from using mrcal-calibrate-cameras, which again matches the results you got using the mrcal CLI. I then wrote a little unit test to use your calibration JSON (attached in your comment above) and try calibrating. This is the output I see.

    @Test
    public void testWillBoard() throws IOException {
        var cal = JacksonUtils.deserialize(Path.of("/home/matt/mrcal_debug_tmp/pv_calibration_1600x1200.json"), 
            CameraCalibrationCoefficients.class);
        // System.out.println(cal);

        var corners = cal.observations.stream().map(it->{
                var mat = new MatOfPoint2f();
                mat.fromList(it.locationInImageSpace);
                return mat;
            }).collect(Collectors.toList());

        var result = MrCalJNI.calibrateCamera(
            corners,
            (int)cal.calobjectSize.width, (int)cal.calobjectSize.height, cal.calobjectSpacing, 
            (int)cal.resolution.width, (int)cal.resolution.height, 1200
        );
        System.out.println(result);
    }
Calibrate3dPipeTest > testWillBoard() STANDARD_OUT
    CameraCalibrationCoefficients [resolution=1600x1200, cameraIntrinsics=JsonMat [rows=3, cols=3, type=6, data=[964.3192542051779, 0.0, 766.3572370964357, 0.0, 968.4167197906467, 656.0259427916941, 0.0, 0.0, 1.0], wrappedMat=Mat [ 3*3*CV_64FC1, isCont=true, isSubmat=false, nativeObj=0x7fe345180730, dataAddr=0x7fe345180f40 ], wpilibMat=null, wrappedMatOfDouble=null], distCoeffs=JsonMat [rows=1, cols=8, type=6, data=[-0.03374426143309665, 3.779715023416348E-4, 8.241449288523903E-4, -0.009869350879493375, -1.3818166014360312E-6, -0.050844745308818114, 7.160772275740329E-4, -3.0046612000201336E-6], wrappedMat=Mat [ 1*8*CV_64FC1, isCont=true, isSubmat=false, nativeObj=0x7fe34510dc80, dataAddr=0x7fe34519b680 ], wpilibMat=null, wrappedMatOfDouble=Mat [ 1*8*CV_64FC1, isCont=true, isSubmat=false, nativeObj=0x7fe34510dc10, dataAddr=0x7fe3451ab080 ]], observationslen=80, calobjectWarp=[-2.25221267024838E-4, 7.336652791935415E-4], intrinsicsArr=[964.3192542051779, 0.0, 766.3572370964357, 0.0, 968.4167197906467, 656.0259427916941, 0.0, 0.0, 1.0], distCoeffsArr=[-0.03374426143309665, 3.779715023416348E-4, 8.241449288523903E-4, -0.009869350879493375, -1.3818166014360312E-6]]

libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114: CHOLMOD warning:
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114:  not positive definite.
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114:  file: ../Cholesky/t_cholmod_rowfac.c
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114:  line: 430
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114: 

Watching 173 directories to track changes
/home/runner/work/mrcal-java/mrcal-java/mrcal/mrcal.c(5540): Threw out some outliers. New count = 425/37440 (1.1%). Going again
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114: CHOLMOD warning:
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114:  not positive definite.
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114:  file: ../Cholesky/t_cholmod_rowfac.c
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114:  line: 430
libdogleg at /home/runner/work/mrcal-java/mrcal-java/libdogleg/dogleg.c:1114: 

Gradle Test Executor 13 finished executing tests.

> Task :photon-core:testHeadless
    MrCalResult [success=true, intrinsics=[815.2444290805902, 702.5299171031456, 783.7045709624529, 598.5380702840318, 16.022877352468576, -11.617096993914174, -0.012759261238650944, -0.16064034039996528, -6.856871701238218, 11.279315510816447, -8.68659166855614, -4.641638738271045], rms_error=48.3446650298785, warp_x=0.005452025977464822, warp_y=0.0011008387439970853, Noutliers=425]
dkogan commented 5 months ago

Does mrcal-calibrate-cameras by default perform a calibration refinement? Right now, our calibration is just a single call to mrcal_optimize. And we generate seed poses using solvepnp_epnp.

mrcal-calibrate-cameras does this also: there's an incremental seeing and solving routine. It's implemented in Python, which I guess means you can't use it directly. The seed routine is here:

https://github.com/dkogan/mrcal/blob/90818fdbb6ef422c90b644690d5b14add3a42724/mrcal/calibration.py#L1360

Look at mrcal-calibrate-cameras to see how that's called.

dkogan commented 5 months ago

I looked at the model in the .zip file and the model in the smaller .json file above (mrcal models aren't json: they're python dicts; so they can have comments, and such). Both those models show the "small" uncertainties.

Is this bug report summarized as "photonvision produces results with alarmingly-high reported uncertainties"? If so, I'd need a model that shows such high uncertainties to tell you what's going on. Are the high-uncertainty produced by running mrcal-show-projection-uncertainties, or is that wrapper inside photonvision somehow? I'd need some way to reproduce whatever failure you're seeing.

Similarly for the "not-positive-definite" messages you're seeing: if I reoptimize either for the models I have, I don't see this. The most common cause of these messages is described here:

https://mrcal.secretsauce.net/how-to-calibrate.html#orgea10dd0

mcm001 commented 5 months ago

Yeah, that summery is accurate. For a little more context, Photon uses JSON files for camera calibration, and these jsons contain the images, board corner observations, and other optimization inputs. We also provide a python script to convert this json to a mrcal cameramodel, and try to convert out optimization inputs to mrcal-land, so we can use your tools like mrcal-show-projection-uncertainty. The core bug report here is that when a calibration performed using PhotonVision is exported and converted to a mrcal cameramodel, the projection uncertainty shown using mrcal-show-projection-uncertainties is alarmingly high.

A bug could exist in our export/conversion script, or we could truly have a calibration that's wildly wrong.

mcm001 commented 5 months ago

mrcal-calibrate-cameras does this also: there's an incremental seeing and solving routine. It's implemented in Python, which I guess means you can't use it directly. The seed routine is here: https://github.com/dkogan/mrcal/blob/90818fdbb6ef422c90b644690d5b14add3a42724/mrcal/calibration.py#L1360 Look at mrcal-calibrate-cameras to see how that's called.

right now we just jump straight into a full solve optimizing everything simultaniously, which probably doesn't help. I'll try changing our code to properly do the same incremental optimization process you linked and see how that changes our results.

mcm001 commented 5 months ago

I've started prototyping this code over in this branch, but i'm still getting weird results. Needs more investigation

dkogan commented 5 months ago

The core bug report here is that when a calibration performed using PhotonVision is exported and converted to a mrcal cameramodel, the projection uncertainty shown using mrcal-show-projection-uncertainties is alarmingly high.

OK. Can I get a copy of one of those .cameramodel files that produce a very high mrcal-show-projection-uncertainty result? I believe all the ones that were linked in this report have reported low uncertainties

right now we just jump straight into a full solve optimizing everything simultaniously, which probably doesn't help. I'll try changing our code to properly do the same incremental optimization process you linked and see how that changes our results.

I won't claim that the seeding sequence I use currently is perfect, but it has been tested thoroughly, and does work ok. Is there really no way to use the Python code directly in photovision? If doing a rewrite in another language, it'll take a while (lots of testing and fixing things) to get to the same level of performance, and it feels like effort is being duplicated. You can embed Python in C like this:

https://docs.python.org/3/extending/embedding.html

Worth thinking about?

mcm001 commented 5 months ago

The main reason I'm hesitant to pursue that is it would require we install python3 and mrcal in our image. This would add ~450MB of packages to our image (at least for the mrcal package, version 2.4.1-1jammy1). Just python3 itself adds ~25MB, so I assume most of this extra size is from other dependencies the mrcal package pulls in?

If there's any way to get the size of the package down while still being able to wrap python, that could be something we consider for 2025. You're right that I'm not a fan of how much API I'm having to duplicate. I'd just also like to be cognizant of image size.

dkogan commented 5 months ago

You're talking about the debian packages here, and the "450MB" number comes from what APT tells you in will need when you ask to "apt install python3-mrcal"? If not, where does "450MB" come from? Presumably you're already installing "libmrcal4" and "libmrcal-dev", and you're looking at the EXTRA space "python3-mrcal" will require?

If so, can you get some more detailed accounting, to see which packages specifically are responsible for the ballooning size? mrcal itself and things it directly uses aren't nearly this fat, but there could be optional things, or things that dependencies optionally need.

I can help you get the detailed numbers, if you tell me exactly where you get the "450MB" number.

mcm001 commented 5 months ago

Sure. Starting from a blank ubuntu:22.04 docker image, I'm just using the size reported by apt (eg, After this operation, 264 MB of additional disk space will be used.). After i list the extra size of the package, I go ahead and install it.

apt-get install --yes openjdk-17-jre-headless -- 260 MB apt-get install --yes libcholmod3 liblapack3 libsuitesparseconfig5 -- 14 MB. These packages are what mrcal-java links to. Mrcal-java is a build that contains both mrcal and our JNI in the same so. mrcal-java shared libraries live inside of the photonvision JAR file we distribute, and on linux that's 107kb compressed in a jar. libmrcal4 -- 24 MB. I don't think it makes sense to install libmrcal-dev on user systems right, since they don't need to be compiling code?

Detailed command output for libmrcal4
``` root@ab408bde2eb4:/# apt show libmrcal4 Package: libmrcal4 Version: 2.4.1-1jammy1 Priority: optional Section: libs Source: mrcal Maintainer: Debian Science Maintainers Installed-Size: 310 kB Depends: libc6 (>= 2.33), libdogleg2 (>= 0.15.3), libfreeimage3 (>= 3.18.0+ds2) Homepage: http://mrcal.secretsauce.net Download-Size: 112 kB APT-Sources: http://mrcal.secretsauce.net/packages/jammy/public jammy/main amd64 Packages Description: Calibration and SFM library A photogrammetry toolkit that provides improved methods for making and using camera models (calibration, tracking, mapping, etc). The focus is on calibration and uncertainty propagation to produce the most accurate models possible. This package provides the runtime C libraries root@ab408bde2eb4:/# apt install libmrcal4 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libamd2 libblas3 libcamd2 libccolamd2 libcholmod3 libcolamd2 libdeflate0 libdogleg2 libfreeimage3 libgfortran5 libgomp1 libilmbase25 libjbig0 libjxr0 liblapack3 libmetis5 libopenexr25 libopenjp2-7 libquadmath0 libraw20 libsuitesparseconfig5 libtiff5 libwebp7 libwebpmux3 The following NEW packages will be installed: libamd2 libblas3 libcamd2 libccolamd2 libcholmod3 libcolamd2 libdeflate0 libdogleg2 libfreeimage3 libgfortran5 libgomp1 libilmbase25 libjbig0 libjxr0 liblapack3 libmetis5 libmrcal4 libopenexr25 libopenjp2-7 libquadmath0 libraw20 libsuitesparseconfig5 libtiff5 libwebp7 libwebpmux3 0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded. Need to get 7082 kB of archives. After this operation, 23.4 MB of additional disk space will be used. Do you want to continue? [Y/n] ^C root@ab408bde2eb4:/# ```

python3-mrcal: after installing libmrcal4, an additional 1615 MB

apt install output
``` root@ab408bde2eb4:/# apt show python3-mrcal Package: python3-mrcal Version: 2.4.1-1jammy1 Priority: optional Section: python Source: mrcal Maintainer: Debian Science Maintainers Installed-Size: 1555 kB Provides: python3.10-mrcal Depends: libc6 (>= 2.14), libmrcal4 (= 2.4.1-1jammy1), libsuitesparseconfig5 (>= 1:5.0.0), python3-numpy (>= 1:1.20.0), python3-numpy-abi9, python3 (<< 3.11), python3 (>= 3.10~), python3:any, python3-gnuplotlib (>= 0.38), python3-numpysane (>= 0.35), python3-opencv, python3-scipy (>= 0.18), python3-shapely, python3-ipython, python3-matplotlib, python3-yaml Homepage: http://mrcal.secretsauce.net Download-Size: 267 kB APT-Sources: http://mrcal.secretsauce.net/packages/jammy/public jammy/main amd64 Packages Description: Calibration and SFM library N: There is 1 additional record. Please use the '-a' switch to see it root@ab408bde2eb4:/# apt show python3-mrca^C root@ab408bde2eb4:/# apt install python3-mrcal Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: adwaita-icon-theme aglfn at-spi2-core binutils binutils-common binutils-x86-64-linux-gnu blt bzip2 cpp cpp-11 dbus-user-session dconf-gsettings-backend dconf-service dmsetup file fontconfig fonts-lyx g++ g++-11 gcc gcc-11 gcc-11-base gdal-data gir1.2-glib-2.0 gnuplot-data gnuplot-qt gsettings-desktop-schemas gstreamer1.0-plugins-base gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme i965-va-driver ibverbs-providers intel-media-va-driver iso-codes javascript-common libaacs0 libaec0 libaom3 libarchive13 libargon2-1 libarmadillo10 libarpack2 libasan6 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatomic1 libatspi2.0-0 libavcodec58 libavformat58 libavutil56 libbdplus0 libbinutils libblosc1 libbluray2 libboost-dev libboost1.74-dev libbsd0 libc-dev-bin libc-devtools libc6-dev libcairo-gobject2 libcairo2 libcap2-bin libcc1-0 libcdparanoia0 libcfitsio9 libcharls2 libchromaprint1 libcodec2-1.0 libcolord2 libcrypt-dev libcryptsetup12 libctf-nobfd0 libctf0 libcurl3-gnutls libcurl4 libdatrie1 libdav1d5 libdc1394-25 libdconf1 libde265-0 libdevmapper1.02.1 libdouble-conversion3 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libdw1 libedit2 libegl-mesa0 libegl1 libelf1 libepoxy0 libevdev2 libevent-core-2.1-7 libevent-pthreads-2.1-7 libexif12 libexpat1-dev libfabric1 libfreexl1 libfribidi0 libfyba0 libgbm1 libgcc-11-dev libgd3 libgdal30 libgdbm-compat4 libgdbm6 libgdcm3.0 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgeos-c1v5 libgeos3.10.2 libgeotiff5 libgif7 libgirepository-1.0-1 libgl1 libgl1-amber-dri libgl1-mesa-dri libgl2ps1.4 libglapi-mesa libglew2.2 libglvnd0 libglx-mesa0 libglx0 libgme0 libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgsm1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgudev-1.0-0 libhdf4-0-alt libhdf5-103-1 libhdf5-hl-100 libheif1 libhwloc-plugins libhwloc15 libibverbs1 libice6 libigdgmm12 libimagequant0 libinput-bin libinput10 libip4tc2 libisl23 libitm1 libjs-jquery libjs-jquery-ui libjs-sphinxdoc libjs-underscore libjson-c5 libjsoncpp25 libkmlbase1 libkmldom1 libkmlengine1 libkmod2 liblbfgsb0 libldap-2.5-0 libldap-common liblept5 libllvm15 liblsan0 libltdl7 liblua5.4-0 libmagic-mgc libmagic1 libmd0 libmd4c0 libmfx1 libminizip1 libmp3lame0 libmpc3 libmpfr6 libmpg123-0 libmtdev1 libmysqlclient21 libnetcdf19 libnghttp2-14 libnl-3-200 libnl-route-3-200 libnorm1 libnotify4 libnsl-dev libnss-systemd libnuma1 libodbc2 libodbcinst2 libogdi4.1 libogg0 libopenblas-dev libopenblas-pthread-dev libopenblas0 libopenblas0-pthread libopencv-calib3d4.5d libopencv-contrib4.5d libopencv-core4.5d libopencv-dnn4.5d libopencv-features2d4.5d libopencv-flann4.5d libopencv-highgui4.5d libopencv-imgcodecs4.5d libopencv-imgproc4.5d libopencv-ml4.5d libopencv-objdetect4.5d libopencv-photo4.5d libopencv-shape4.5d libopencv-stitching4.5d libopencv-video4.5d libopencv-videoio4.5d libopencv-viz4.5d libopengl0 libopenmpi3 libopenmpt0 libopus0 liborc-0.4-0 libpam-cap libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcre2-16-0 libperl5.34 libpgm-5.3-0 libpixman-1-0 libpmix2 libpoppler118 libpq5 libproj22 libprotobuf23 libpsl5 libpsm-infinipath1 libpsm2-2 libpython3-dev libpython3-stdlib libpython3.10-dev libqhull-r8.0 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5printsupport5 libqt5svg5 libqt5widgets5 librabbitmq4 libraqm0 libraw1394-11 librdmacm1 librsvg2-2 librsvg2-common librtmp1 librttopo1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsensors-config libsensors5 libshine3 libsm6 libsnappy1v5 libsocket++1 libsoxr0 libspatialite7 libspeex1 libsrt1.4-gnutls libssh-4 libssh-gcrypt-4 libstdc++-11-dev libsuperlu5 libswresample3 libswscale5 libsz2 libtbb12 libtbb2 libtbbmalloc2 libtcl8.6 libtesseract4 libthai-data libthai0 libtheora0 libtirpc-dev libtk8.6 libtsan0 libtwolame0 libubsan1 libucx0 libudfread0 libunwind8 liburiparser1 libusb-1.0-0 libva-drm2 libva-x11-2 libva2 libvdpau1 libvisual-0.4-0 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx7 libvtk9.1 libwacom-bin libwacom-common libwacom9 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 libwebpdemux2 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libx264-163 libx265-199 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxerces-c3.2 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxnvctrl0 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxsimd-dev libxslt1.1 libxss1 libxtst6 libxvidcore4 libxxf86vm1 libyaml-0-2 libzmq5 libzvbi-common libzvbi0 linux-libc-dev mailcap manpages manpages-dev mesa-va-drivers mesa-vdpau-drivers mime-support mysql-common netbase networkd-dispatcher ocl-icd-libopencl1 perl perl-modules-5.34 poppler-data proj-bin proj-data publicsuffix python-matplotlib-data python3 python3-appdirs python3-attr python3-backcall python3-beniget python3-brotli python3-bs4 python3-chardet python3-cycler python3-dateutil python3-dbus python3-decorator python3-dev python3-distutils python3-fonttools python3-fs python3-gast python3-gi python3-gnuplotlib python3-html5lib python3-ipython python3-jedi python3-kiwisolver python3-lib2to3 python3-lxml python3-lz4 python3-matplotlib python3-matplotlib-inline python3-minimal python3-mpmath python3-numpy python3-numpysane python3-olefile python3-opencv python3-packaging python3-parso python3-pexpect python3-pickleshare python3-pil python3-pil.imagetk python3-pkg-resources python3-ply python3-prompt-toolkit python3-ptyprocess python3-pygments python3-pyparsing python3-pythran python3-scipy python3-shapely python3-six python3-soupsieve python3-sympy python3-tk python3-traitlets python3-tz python3-ufolib2 python3-unicodedata2 python3-wcwidth python3-webencodings python3-yaml python3.10 python3.10-dev python3.10-minimal qt5-gtk-platformtheme qttranslations5-l10n rpcsvc-proto session-migration systemd systemd-sysv systemd-timesyncd tk8.6-blt2.5 tzdata ubuntu-mono unicode-data unixodbc-common va-driver-all vdpau-driver-all x11-common xkb-data xz-utils zlib1g-dev Suggested packages: binutils-doc blt-demo bzip2-doc cpp-doc gcc-11-locales g++-multilib g++-11-multilib gcc-11-doc gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc gcc-11-multilib gnuplot-doc gvfs i965-va-driver-shaders isoquery apache2 | lighttpd | httpd lrzip libcuda1 libnvcuvid1 libnvidia-encode1 libbluray-bdj libboost-doc libboost1.74-doc libboost-atomic1.74-dev libboost-chrono1.74-dev libboost-container1.74-dev libboost-context1.74-dev libboost-contract1.74-dev libboost-coroutine1.74-dev libboost-date-time1.74-dev libboost-exception1.74-dev libboost-fiber1.74-dev libboost-filesystem1.74-dev libboost-graph1.74-dev libboost-graph-parallel1.74-dev libboost-iostreams1.74-dev libboost-locale1.74-dev libboost-log1.74-dev libboost-math1.74-dev libboost-mpi1.74-dev libboost-mpi-python1.74-dev libboost-numpy1.74-dev libboost-program-options1.74-dev libboost-python1.74-dev libboost-random1.74-dev libboost-regex1.74-dev libboost-serialization1.74-dev libboost-stacktrace1.74-dev libboost-system1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libboost-timer1.74-dev libboost-type-erasure1.74-dev libboost-wave1.74-dev libboost1.74-tools-dev libmpfrc++-dev libntl-dev libboost-nowide1.74-dev glibc-doc colord libgd-tools gdbm-l10n geotiff-bin gdal-bin libgeotiff-epsg glew-utils gphoto2 libvisual-0.4-plugins gstreamer1.0-tools libhdf4-doc libhdf4-alt-dev hdf4-tools libhwloc-contrib-plugins libjs-jquery-ui-docs gnome-shell | notification-daemon odbc-postgresql tdsodbc ogdi-bin opus-tools pciutils qt5-image-formats-plugins qtwayland5 libraw1394-doc librsvg2-bin libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql lm-sensors speex libstdc++-11-doc tcl8.6 tk8.6 mpi-default-bin vtk9-doc vtk9-examples libxsimd-doc man-browser iw | wireless-tools opencl-icd perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl libtap-harness-archive-perl poppler-utils ghostscript fonts-japanese-mincho | fonts-ipafont-mincho fonts-japanese-gothic | fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-nanum python3-doc python3-venv python-attr-doc python-cycler-doc python-dbus-doc python3-genshi python-ipython-doc python-lxml-doc dvipng ffmpeg fonts-staypuft gir1.2-gtk-3.0 inkscape ipython3 python-matplotlib-doc python3-cairocffi python3-gi-cairo python3-gobject python3-pyqt5 python3-sip python3-tornado texlive-extra-utils texlive-latex-extra python-mpmath-doc python3-gmpy2 gfortran python-numpy-doc python3-pytest python-pexpect-doc python-pil-doc python3-setuptools python-ply-doc python-pygments-doc ttf-bitstream-vera python-pyparsing-doc python-scipy-doc texlive-fonts-extra python-sympy-doc tix python3-tk-dbg python3.10-venv python3.10-doc binfmt-support systemd-container libfido2-1 libtss2-esys-3.0.2-0 libtss2-mu0 libtss2-rc0 policykit-1 libvdpau-va-gl1 The following NEW packages will be installed: adwaita-icon-theme aglfn at-spi2-core binutils binutils-common binutils-x86-64-linux-gnu blt bzip2 cpp cpp-11 dbus-user-session dconf-gsettings-backend dconf-service dmsetup file fontconfig fonts-lyx g++ g++-11 gcc gcc-11 gcc-11-base gdal-data gir1.2-glib-2.0 gnuplot-data gnuplot-qt gsettings-desktop-schemas gstreamer1.0-plugins-base gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme i965-va-driver ibverbs-providers intel-media-va-driver iso-codes javascript-common libaacs0 libaec0 libaom3 libarchive13 libargon2-1 libarmadillo10 libarpack2 libasan6 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatomic1 libatspi2.0-0 libavcodec58 libavformat58 libavutil56 libbdplus0 libbinutils libblosc1 libbluray2 libboost-dev libboost1.74-dev libbsd0 libc-dev-bin libc-devtools libc6-dev libcairo-gobject2 libcairo2 libcap2-bin libcc1-0 libcdparanoia0 libcfitsio9 libcharls2 libchromaprint1 libcodec2-1.0 libcolord2 libcrypt-dev libcryptsetup12 libctf-nobfd0 libctf0 libcurl3-gnutls libcurl4 libdatrie1 libdav1d5 libdc1394-25 libdconf1 libde265-0 libdevmapper1.02.1 libdouble-conversion3 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libdw1 libedit2 libegl-mesa0 libegl1 libelf1 libepoxy0 libevdev2 libevent-core-2.1-7 libevent-pthreads-2.1-7 libexif12 libexpat1-dev libfabric1 libfreexl1 libfribidi0 libfyba0 libgbm1 libgcc-11-dev libgd3 libgdal30 libgdbm-compat4 libgdbm6 libgdcm3.0 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgeos-c1v5 libgeos3.10.2 libgeotiff5 libgif7 libgirepository-1.0-1 libgl1 libgl1-amber-dri libgl1-mesa-dri libgl2ps1.4 libglapi-mesa libglew2.2 libglvnd0 libglx-mesa0 libglx0 libgme0 libgphoto2-6 libgphoto2-l10n libgphoto2-port12 libgsm1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgudev-1.0-0 libhdf4-0-alt libhdf5-103-1 libhdf5-hl-100 libheif1 libhwloc-plugins libhwloc15 libibverbs1 libice6 libigdgmm12 libimagequant0 libinput-bin libinput10 libip4tc2 libisl23 libitm1 libjs-jquery libjs-jquery-ui libjs-sphinxdoc libjs-underscore libjson-c5 libjsoncpp25 libkmlbase1 libkmldom1 libkmlengine1 libkmod2 liblbfgsb0 libldap-2.5-0 libldap-common liblept5 libllvm15 liblsan0 libltdl7 liblua5.4-0 libmagic-mgc libmagic1 libmd0 libmd4c0 libmfx1 libminizip1 libmp3lame0 libmpc3 libmpfr6 libmpg123-0 libmtdev1 libmysqlclient21 libnetcdf19 libnghttp2-14 libnl-3-200 libnl-route-3-200 libnorm1 libnotify4 libnsl-dev libnss-systemd libnuma1 libodbc2 libodbcinst2 libogdi4.1 libogg0 libopenblas-dev libopenblas-pthread-dev libopenblas0 libopenblas0-pthread libopencv-calib3d4.5d libopencv-contrib4.5d libopencv-core4.5d libopencv-dnn4.5d libopencv-features2d4.5d libopencv-flann4.5d libopencv-highgui4.5d libopencv-imgcodecs4.5d libopencv-imgproc4.5d libopencv-ml4.5d libopencv-objdetect4.5d libopencv-photo4.5d libopencv-shape4.5d libopencv-stitching4.5d libopencv-video4.5d libopencv-videoio4.5d libopencv-viz4.5d libopengl0 libopenmpi3 libopenmpt0 libopus0 liborc-0.4-0 libpam-cap libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcre2-16-0 libperl5.34 libpgm-5.3-0 libpixman-1-0 libpmix2 libpoppler118 libpq5 libproj22 libprotobuf23 libpsl5 libpsm-infinipath1 libpsm2-2 libpython3-dev libpython3-stdlib libpython3.10-dev libqhull-r8.0 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5printsupport5 libqt5svg5 libqt5widgets5 librabbitmq4 libraqm0 libraw1394-11 librdmacm1 librsvg2-2 librsvg2-common librtmp1 librttopo1 libsasl2-2 libsasl2-modules libsasl2-modules-db libsensors-config libsensors5 libshine3 libsm6 libsnappy1v5 libsocket++1 libsoxr0 libspatialite7 libspeex1 libsrt1.4-gnutls libssh-4 libssh-gcrypt-4 libstdc++-11-dev libsuperlu5 libswresample3 libswscale5 libsz2 libtbb12 libtbb2 libtbbmalloc2 libtcl8.6 libtesseract4 libthai-data libthai0 libtheora0 libtirpc-dev libtk8.6 libtsan0 libtwolame0 libubsan1 libucx0 libudfread0 libunwind8 liburiparser1 libusb-1.0-0 libva-drm2 libva-x11-2 libva2 libvdpau1 libvisual-0.4-0 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx7 libvtk9.1 libwacom-bin libwacom-common libwacom9 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwayland-server0 libwebpdemux2 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libx264-163 libx265-199 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-present0 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxerces-c3.2 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon-x11-0 libxkbcommon0 libxnvctrl0 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxsimd-dev libxslt1.1 libxss1 libxtst6 libxvidcore4 libxxf86vm1 libyaml-0-2 libzmq5 libzvbi-common libzvbi0 linux-libc-dev mailcap manpages manpages-dev mesa-va-drivers mesa-vdpau-drivers mime-support mysql-common netbase networkd-dispatcher ocl-icd-libopencl1 perl perl-modules-5.34 poppler-data proj-bin proj-data publicsuffix python-matplotlib-data python3 python3-appdirs python3-attr python3-backcall python3-beniget python3-brotli python3-bs4 python3-chardet python3-cycler python3-dateutil python3-dbus python3-decorator python3-dev python3-distutils python3-fonttools python3-fs python3-gast python3-gi python3-gnuplotlib python3-html5lib python3-ipython python3-jedi python3-kiwisolver python3-lib2to3 python3-lxml python3-lz4 python3-matplotlib python3-matplotlib-inline python3-minimal python3-mpmath python3-mrcal python3-numpy python3-numpysane python3-olefile python3-opencv python3-packaging python3-parso python3-pexpect python3-pickleshare python3-pil python3-pil.imagetk python3-pkg-resources python3-ply python3-prompt-toolkit python3-ptyprocess python3-pygments python3-pyparsing python3-pythran python3-scipy python3-shapely python3-six python3-soupsieve python3-sympy python3-tk python3-traitlets python3-tz python3-ufolib2 python3-unicodedata2 python3-wcwidth python3-webencodings python3-yaml python3.10 python3.10-dev python3.10-minimal qt5-gtk-platformtheme qttranslations5-l10n rpcsvc-proto session-migration systemd systemd-sysv systemd-timesyncd tk8.6-blt2.5 tzdata ubuntu-mono unicode-data unixodbc-common va-driver-all vdpau-driver-all x11-common xkb-data xz-utils zlib1g-dev 0 upgraded, 472 newly installed, 0 to remove and 0 not upgraded. Need to get 362 MB of archives. After this operation, 1615 MB of additional disk space will be used. Do you want to continue? [Y/n] n Abort. root@ab408bde2eb4:/# ```
mcm001 commented 5 months ago

sorry, github formatting was messed up initially for my above comment. should be resolved now.

dkogan commented 5 months ago

OK. I just poked at it a bit. If I ask for the size of everything needed to install python3-mrcal that isn't also needed for libmrcal4, it says there's 1159MB extra:

for pkg (`join -v1 <(apt-rdepends python3-mrcal | grep -v '^ ' | sort) <(apt-rdepends libmrcal4 | grep -v '^ ' | sort)`) { echo $pkg/bookworm } | xargs apt-cache show | awk '/^Package:/ {p=$2} /^Installed-Size:/ { s+=$2 } END {print s/1e3}'

It's a bit different from your other numbers for uninteresting reasons; hopefully much of the reasoning would be the same either way. These are installed sizes. I looked at it a bit, and it looks like 735MB of that is python3-opencv. This package definitely isn't as fine-grained as it could be. So today, if you want to be able to import cv2 in Python, you need 735MB of space.

Of the remaining stuff, I THINK much of it is from installing the gnuplot-qt flavor of gnuplot, which pulls in a lot of stuff. There are other flavors of that, which would be lighter. So what do you see if you

apt install --no-install-recommends python3-mrcal gnuplot-x11

Hopefully that will give you a better number. Although the biggest hog (python3-opencv) will still be there.

I'm still not sure why we care about this though. Disks today are very large (which is why these packages are fatter than you want: nobody has cared enough to trim them). You are using a very common OS with very common packages. Why do you even need an image? You can use something like equivs to build a (tiny) meta-package that depends on the things that you need (let's call it photon-vision-deps). Then the instructions are:

Then even if photon-vision-deps contains some fat thing like python3-opencv, it isn't something you think about. And the students won't either: it's a fraction the size of a netflix movie.

And as an added bonus, having Python and opencv available is something the students should find useful.

Sorry if that's not completely what you wanted to hear. If you had infinite time and motivation, you could improve the python3-opencv packaging to make it more granular, to allow installing only the pieces we need. But that's not obviously a good use of anybody's time, which is why nobody has done it.

If you need help with equivs or setting up an APT server with the extra packages you need or whatever, feel free to ask. I do this all the time.

mcm001 commented 5 months ago

Robots are generally an offline environment, which drives the need for a completely offline solution. For competition, we also need to disable wireless, which forces you to somehow find a wired internet port at your school/workshop. I agree that in a perfect world, you'd just plug your coprocessor into your school LAN and download some packages, but that's outside the reach of a good chunk of our users.

The concern about total disk space is to keep image download/flashing speed from bloating too much, and also just proactively trying to not hit Github's download size limit. I'm just not sure if the value prop is there for increasing the size of our image this much is there yet.

From a fresh docker image of ubuntu:22.04, I see:

apt install --no-install-recommends gnuplot-x11 ``` root@2d3cc328ef2c:/# apt install gnuplot-x11 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: adwaita-icon-theme aglfn at-spi2-core dbus dbus-user-session dconf-gsettings-backend dconf-service dmsetup fontconfig fontconfig-config fonts-dejavu-core gir1.2-glib-2.0 gnuplot-data gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme libapparmor1 libargon2-1 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libbrotli1 libbsd0 libcairo-gobject2 libcairo2 libcolord2 libcryptsetup12 libcups2 libdatrie1 libdbus-1-3 libdconf1 libdeflate0 libdevmapper1.02.1 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libedit2 libelf1 libepoxy0 libfontconfig1 libfreetype6 libfribidi0 libgd3 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgirepository-1.0-1 libgl1 libgl1-amber-dri libgl1-mesa-dri libglapi-mesa libglib2.0-0 libglib2.0-data libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libharfbuzz0b libice6 libicu70 libip4tc2 libjbig0 libjpeg-turbo8 libjpeg8 libjson-c5 libkmod2 liblcms2-2 libllvm15 liblua5.4-0 libmd0 libnotify4 libnss-systemd libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpixman-1-0 libpng16-16 libpython3-stdlib librsvg2-2 librsvg2-common libsensors-config libsensors5 libsm6 libthai-data libthai0 libtiff5 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwebp7 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxml2 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 networkd-dispatcher python3 python3-dbus python3-gi python3-minimal python3.10 python3.10-minimal session-migration shared-mime-info systemd systemd-sysv systemd-timesyncd ubuntu-mono ucf x11-common xdg-user-dirs xkb-data Suggested packages: gnuplot-doc colord cups-common libgd-tools gvfs liblcms2-utils gnome-shell | notification-daemon pciutils librsvg2-bin lm-sensors iw | wireless-tools python3-doc python3-tk python3-venv python-dbus-doc python3.10-venv python3.10-doc binutils binfmt-support systemd-container libfido2-1 libtss2-esys-3.0.2-0 libtss2-mu0 libtss2-rc0 policykit-1 The following NEW packages will be installed: adwaita-icon-theme aglfn at-spi2-core dbus dbus-user-session dconf-gsettings-backend dconf-service dmsetup fontconfig fontconfig-config fonts-dejavu-core gir1.2-glib-2.0 gnuplot-data gnuplot-x11 gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme libapparmor1 libargon2-1 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libbrotli1 libbsd0 libcairo-gobject2 libcairo2 libcolord2 libcryptsetup12 libcups2 libdatrie1 libdbus-1-3 libdconf1 libdeflate0 libdevmapper1.02.1 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libedit2 libelf1 libepoxy0 libfontconfig1 libfreetype6 libfribidi0 libgd3 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgirepository-1.0-1 libgl1 libgl1-amber-dri libgl1-mesa-dri libglapi-mesa libglib2.0-0 libglib2.0-data libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libharfbuzz0b libice6 libicu70 libip4tc2 libjbig0 libjpeg-turbo8 libjpeg8 libjson-c5 libkmod2 liblcms2-2 libllvm15 liblua5.4-0 libmd0 libnotify4 libnss-systemd libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpixman-1-0 libpng16-16 libpython3-stdlib librsvg2-2 librsvg2-common libsensors-config libsensors5 libsm6 libthai-data libthai0 libtiff5 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwebp7 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxml2 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxtst6 libxxf86vm1 networkd-dispatcher python3 python3-dbus python3-gi python3-minimal python3.10 python3.10-minimal session-migration shared-mime-info systemd systemd-sysv systemd-timesyncd ubuntu-mono ucf x11-common xdg-user-dirs xkb-data 0 upgraded, 153 newly installed, 0 to remove and 0 not upgraded. Need to get 88.0 MB of archives. After this operation, 353 MB of additional disk space will be used. ```
apt install --no-install-recommends python3-mrcal gnuplot-x11 ``` root@2d3cc328ef2c:/# apt show python3-mrcal Package: python3-mrcal Version: 2.1-5build1 Priority: optional Section: universe/python Source: mrcal Origin: Ubuntu Maintainer: Ubuntu Developers Original-Maintainer: Debian Science Maintainers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 1337 kB Provides: python3.10-mrcal Depends: libc6 (>= 2.14), libmrcal2 (= 2.1-5build1), python3-numpy (>= 1:1.20.0), python3-numpy-abi9, python3 (<< 3.11), python3 (>= 3.10~), python3:any, python3-gnuplotlib (>= 0.38), python3-numpysane (>= 0.35), python3-opencv, python3-scipy (>= 0.18), python3-shapely, python3-ipython, python3-matplotlib Homepage: http://mrcal.secretsauce.net Download-Size: 219 kB APT-Sources: http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages Description: Calibration and SFM library root@2d3cc328ef2c:/# apt install --no-install-recommends python3-mrcal gnuplot-x11 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: adwaita-icon-theme aglfn binutils binutils-common binutils-x86-64-linux-gnu blt cpp cpp-11 dbus dbus-user-session dconf-gsettings-backend dconf-service fontconfig fontconfig-config fonts-dejavu-core fonts-lyx g++ g++-11 gcc gcc-11 gcc-11-base gdal-data gnuplot-data gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme ibverbs-providers iso-codes libaec0 libamd2 libaom3 libapparmor1 libarchive13 libargon2-1 libarmadillo10 libarpack2 libasan6 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatomic1 libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libavcodec58 libavformat58 libavutil56 libbinutils libblas3 libblosc1 libbluray2 libboost-dev libboost1.74-dev libbrotli1 libbsd0 libc-dev-bin libc6-dev libcairo-gobject2 libcairo2 libcamd2 libcap2-bin libcc1-0 libccolamd2 libcfitsio9 libcharls2 libcholmod3 libchromaprint1 libcodec2-1.0 libcolamd2 libcolord2 libcrypt-dev libcryptsetup12 libctf-nobfd0 libctf0 libcups2 libcurl3-gnutls libcurl4 libdatrie1 libdav1d5 libdbus-1-3 libdc1394-25 libdconf1 libde265-0 libdeflate0 libdevmapper1.02.1 libdogleg2 libdouble-conversion3 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libdw1 libedit2 libelf1 libepoxy0 libevent-core-2.1-7 libevent-pthreads-2.1-7 libexif12 libexpat1-dev libfabric1 libfontconfig1 libfreetype6 libfreexl1 libfribidi0 libfyba0 libgcc-11-dev libgd3 libgdal30 libgdcm3.0 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-common libgeos-c1v5 libgeos3.10.2 libgeotiff5 libgfortran5 libgif7 libgl1 libgl1-mesa-dri libgl2ps1.4 libglapi-mesa libglew2.2 libglib2.0-0 libglvnd0 libglx-mesa0 libglx0 libgme0 libgomp1 libgphoto2-6 libgphoto2-port12 libgraphite2-3 libgsm1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-common libharfbuzz0b libhdf4-0-alt libhdf5-103-1 libhdf5-hl-100 libheif1 libhwloc-plugins libhwloc15 libibverbs1 libice6 libicu70 libilmbase25 libimagequant0 libip4tc2 libisl23 libitm1 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui libjs-sphinxdoc libjs-underscore libjson-c5 libjsoncpp25 libkmlbase1 libkmldom1 libkmlengine1 libkmod2 liblapack3 liblbfgsb0 liblcms2-2 libldap-2.5-0 liblept5 libllvm15 liblsan0 libltdl7 liblua5.4-0 libmd0 libmetis5 libmfx1 libminizip1 libmp3lame0 libmpc3 libmpfr6 libmpg123-0 libmrcal2 libmysqlclient21 libnetcdf19 libnghttp2-14 libnl-3-200 libnl-route-3-200 libnorm1 libnotify4 libnsl-dev libnspr4 libnss3 libnuma1 libodbc2 libodbcinst2 libogdi4.1 libogg0 libopenblas-dev libopenblas-pthread-dev libopenblas0 libopenblas0-pthread libopencv-calib3d4.5d libopencv-contrib4.5d libopencv-core4.5d libopencv-dnn4.5d libopencv-features2d4.5d libopencv-flann4.5d libopencv-highgui4.5d libopencv-imgcodecs4.5d libopencv-imgproc4.5d libopencv-ml4.5d libopencv-objdetect4.5d libopencv-photo4.5d libopencv-shape4.5d libopencv-stitching4.5d libopencv-video4.5d libopencv-videoio4.5d libopencv-viz4.5d libopenexr25 libopengl0 libopenjp2-7 libopenmpi3 libopenmpt0 libopus0 liborc-0.4-0 libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpgm-5.3-0 libpixman-1-0 libpmix2 libpng16-16 libpoppler118 libpq5 libproj22 libprotobuf23 libpsl5 libpsm-infinipath1 libpsm2-2 libpython3-dev libpython3-stdlib libpython3.10-dev libqhull-r8.0 libquadmath0 librabbitmq4 libraqm0 libraw1394-11 librdmacm1 librsvg2-2 librtmp1 librttopo1 libsasl2-2 libsasl2-modules-db libsensors-config libsensors5 libshine3 libsm6 libsnappy1v5 libsocket++1 libsoxr0 libspatialite7 libspeex1 libsrt1.4-gnutls libssh-4 libssh-gcrypt-4 libstdc++-11-dev libsuitesparseconfig5 libsuperlu5 libswresample3 libswscale5 libsz2 libtbb12 libtbb2 libtbbmalloc2 libtcl8.6 libtesseract4 libthai-data libthai0 libtheora0 libtiff5 libtirpc-dev libtk8.6 libtsan0 libtwolame0 libubsan1 libucx0 libudfread0 libunwind8 liburiparser1 libusb-1.0-0 libva-drm2 libva-x11-2 libva2 libvdpau1 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx7 libvtk9.1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwebp7 libwebpdemux2 libwebpmux3 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libx264-163 libx265-199 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxerces-c3.2 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxml2 libxnvctrl0 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxsimd-dev libxslt1.1 libxss1 libxvidcore4 libxxf86vm1 libzmq5 libzvbi-common libzvbi0 linux-libc-dev mysql-common ocl-icd-libopencl1 proj-data python-matplotlib-data python3 python3-appdirs python3-attr python3-backcall python3-beniget python3-brotli python3-cycler python3-dateutil python3-decorator python3-dev python3-distutils python3-fonttools python3-fs python3-gast python3-gnuplotlib python3-ipython python3-jedi python3-kiwisolver python3-lib2to3 python3-lxml python3-lz4 python3-matplotlib python3-matplotlib-inline python3-minimal python3-mpmath python3-numpy python3-numpysane python3-opencv python3-packaging python3-parso python3-pexpect python3-pickleshare python3-pil python3-pil.imagetk python3-pkg-resources python3-ply python3-prompt-toolkit python3-ptyprocess python3-pygments python3-pyparsing python3-pythran python3-scipy python3-shapely python3-six python3-sympy python3-tk python3-traitlets python3-tz python3-ufolib2 python3-unicodedata2 python3-wcwidth python3.10 python3.10-dev python3.10-minimal rpcsvc-proto shared-mime-info systemd systemd-sysv tk8.6-blt2.5 tzdata ubuntu-mono ucf unicode-data unixodbc-common x11-common xkb-data zlib1g-dev Suggested packages: binutils-doc blt-demo cpp-doc gcc-11-locales g++-multilib g++-11-multilib gcc-11-doc gcc-multilib make manpages-dev autoconf automake libtool flex bison gdb gcc-doc gcc-11-multilib gnuplot-doc isoquery lrzip libcuda1 libnvcuvid1 libnvidia-encode1 libbluray-bdj libboost-doc libboost1.74-doc libboost-atomic1.74-dev libboost-chrono1.74-dev libboost-container1.74-dev libboost-context1.74-dev libboost-contract1.74-dev libboost-coroutine1.74-dev libboost-date-time1.74-dev libboost-exception1.74-dev libboost-fiber1.74-dev libboost-filesystem1.74-dev libboost-graph1.74-dev libboost-graph-parallel1.74-dev libboost-iostreams1.74-dev libboost-locale1.74-dev libboost-log1.74-dev libboost-math1.74-dev libboost-mpi1.74-dev libboost-mpi-python1.74-dev libboost-numpy1.74-dev libboost-program-options1.74-dev libboost-python1.74-dev libboost-random1.74-dev libboost-regex1.74-dev libboost-serialization1.74-dev libboost-stacktrace1.74-dev libboost-system1.74-dev libboost-test1.74-dev libboost-thread1.74-dev libboost-timer1.74-dev libboost-type-erasure1.74-dev libboost-wave1.74-dev libboost1.74-tools-dev libmpfrc++-dev libntl-dev libboost-nowide1.74-dev glibc-doc colord cups-common libgd-tools geotiff-bin gdal-bin libgeotiff-epsg glew-utils gphoto2 libvisual-0.4-plugins gstreamer1.0-tools gvfs libhdf4-doc libhdf4-alt-dev hdf4-tools libhwloc-contrib-plugins libjs-jquery-ui-docs liblcms2-utils gnome-shell | notification-daemon odbc-postgresql tdsodbc ogdi-bin opus-tools pciutils proj-bin libraw1394-doc librsvg2-bin lm-sensors speex libstdc++-11-doc tcl8.6 tk8.6 mpi-default-bin vtk9-doc vtk9-examples libxsimd-doc opencl-icd python3-doc python3-venv python-attr-doc python-cycler-doc python-ipython-doc python-lxml-doc dvipng ffmpeg fonts-staypuft ghostscript gir1.2-gtk-3.0 inkscape ipython3 librsvg2-common python-matplotlib-doc python3-cairocffi python3-gi python3-gi-cairo python3-gobject python3-pyqt5 python3-sip python3-tornado texlive-extra-utils texlive-latex-extra python-mpmath-doc python3-gmpy2 gfortran python-numpy-doc python3-pytest python-pexpect-doc python-pil-doc python3-setuptools python-ply-doc python-pygments-doc ttf-bitstream-vera python-pyparsing-doc python-scipy-doc texlive-fonts-extra python-sympy-doc tix python3-tk-dbg python3.10-venv python3.10-doc binfmt-support systemd-container libfido2-1 libtss2-esys-3.0.2-0 libtss2-mu0 libtss2-rc0 policykit-1 Recommended packages: librsvg2-common at-spi2-core libaacs0 manpages manpages-dev libc-devtools libpam-cap ca-certificates dmsetup proj-bin libgdk-pixbuf2.0-bin libgl1-amber-dri libglib2.0-data xdg-user-dirs libgphoto2-l10n gstreamer1.0-plugins-base libgtk-3-bin javascript-common libldap-common poppler-data publicsuffix libsasl2-modules va-driver-all | va-driver vdpau-driver-all | vdpau-driver python3-bs4 python3-html5lib python3-olefile networkd-dispatcher systemd-timesyncd | time-daemon libnss-systemd The following NEW packages will be installed: adwaita-icon-theme aglfn binutils binutils-common binutils-x86-64-linux-gnu blt cpp cpp-11 dbus dbus-user-session dconf-gsettings-backend dconf-service fontconfig fontconfig-config fonts-dejavu-core fonts-lyx g++ g++-11 gcc gcc-11 gcc-11-base gdal-data gnuplot-data gnuplot-x11 gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme ibverbs-providers iso-codes libaec0 libamd2 libaom3 libapparmor1 libarchive13 libargon2-1 libarmadillo10 libarpack2 libasan6 libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatomic1 libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libavcodec58 libavformat58 libavutil56 libbinutils libblas3 libblosc1 libbluray2 libboost-dev libboost1.74-dev libbrotli1 libbsd0 libc-dev-bin libc6-dev libcairo-gobject2 libcairo2 libcamd2 libcap2-bin libcc1-0 libccolamd2 libcfitsio9 libcharls2 libcholmod3 libchromaprint1 libcodec2-1.0 libcolamd2 libcolord2 libcrypt-dev libcryptsetup12 libctf-nobfd0 libctf0 libcups2 libcurl3-gnutls libcurl4 libdatrie1 libdav1d5 libdbus-1-3 libdc1394-25 libdconf1 libde265-0 libdeflate0 libdevmapper1.02.1 libdogleg2 libdouble-conversion3 libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libdw1 libedit2 libelf1 libepoxy0 libevent-core-2.1-7 libevent-pthreads-2.1-7 libexif12 libexpat1-dev libfabric1 libfontconfig1 libfreetype6 libfreexl1 libfribidi0 libfyba0 libgcc-11-dev libgd3 libgdal30 libgdcm3.0 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-common libgeos-c1v5 libgeos3.10.2 libgeotiff5 libgfortran5 libgif7 libgl1 libgl1-mesa-dri libgl2ps1.4 libglapi-mesa libglew2.2 libglib2.0-0 libglvnd0 libglx-mesa0 libglx0 libgme0 libgomp1 libgphoto2-6 libgphoto2-port12 libgraphite2-3 libgsm1 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libgtk-3-common libharfbuzz0b libhdf4-0-alt libhdf5-103-1 libhdf5-hl-100 libheif1 libhwloc-plugins libhwloc15 libibverbs1 libice6 libicu70 libilmbase25 libimagequant0 libip4tc2 libisl23 libitm1 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-jquery-ui libjs-sphinxdoc libjs-underscore libjson-c5 libjsoncpp25 libkmlbase1 libkmldom1 libkmlengine1 libkmod2 liblapack3 liblbfgsb0 liblcms2-2 libldap-2.5-0 liblept5 libllvm15 liblsan0 libltdl7 liblua5.4-0 libmd0 libmetis5 libmfx1 libminizip1 libmp3lame0 libmpc3 libmpfr6 libmpg123-0 libmrcal2 libmysqlclient21 libnetcdf19 libnghttp2-14 libnl-3-200 libnl-route-3-200 libnorm1 libnotify4 libnsl-dev libnspr4 libnss3 libnuma1 libodbc2 libodbcinst2 libogdi4.1 libogg0 libopenblas-dev libopenblas-pthread-dev libopenblas0 libopenblas0-pthread libopencv-calib3d4.5d libopencv-contrib4.5d libopencv-core4.5d libopencv-dnn4.5d libopencv-features2d4.5d libopencv-flann4.5d libopencv-highgui4.5d libopencv-imgcodecs4.5d libopencv-imgproc4.5d libopencv-ml4.5d libopencv-objdetect4.5d libopencv-photo4.5d libopencv-shape4.5d libopencv-stitching4.5d libopencv-video4.5d libopencv-videoio4.5d libopencv-viz4.5d libopenexr25 libopengl0 libopenjp2-7 libopenmpi3 libopenmpt0 libopus0 liborc-0.4-0 libpam-systemd libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpgm-5.3-0 libpixman-1-0 libpmix2 libpng16-16 libpoppler118 libpq5 libproj22 libprotobuf23 libpsl5 libpsm-infinipath1 libpsm2-2 libpython3-dev libpython3-stdlib libpython3.10-dev libqhull-r8.0 libquadmath0 librabbitmq4 libraqm0 libraw1394-11 librdmacm1 librsvg2-2 librtmp1 librttopo1 libsasl2-2 libsasl2-modules-db libsensors-config libsensors5 libshine3 libsm6 libsnappy1v5 libsocket++1 libsoxr0 libspatialite7 libspeex1 libsrt1.4-gnutls libssh-4 libssh-gcrypt-4 libstdc++-11-dev libsuitesparseconfig5 libsuperlu5 libswresample3 libswscale5 libsz2 libtbb12 libtbb2 libtbbmalloc2 libtcl8.6 libtesseract4 libthai-data libthai0 libtheora0 libtiff5 libtirpc-dev libtk8.6 libtsan0 libtwolame0 libubsan1 libucx0 libudfread0 libunwind8 liburiparser1 libusb-1.0-0 libva-drm2 libva-x11-2 libva2 libvdpau1 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx7 libvtk9.1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwebp7 libwebpdemux2 libwebpmux3 libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 libx11-6 libx11-data libx11-xcb1 libx264-163 libx265-199 libxau6 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxerces-c3.2 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxml2 libxnvctrl0 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxsimd-dev libxslt1.1 libxss1 libxvidcore4 libxxf86vm1 libzmq5 libzvbi-common libzvbi0 linux-libc-dev mysql-common ocl-icd-libopencl1 proj-data python-matplotlib-data python3 python3-appdirs python3-attr python3-backcall python3-beniget python3-brotli python3-cycler python3-dateutil python3-decorator python3-dev python3-distutils python3-fonttools python3-fs python3-gast python3-gnuplotlib python3-ipython python3-jedi python3-kiwisolver python3-lib2to3 python3-lxml python3-lz4 python3-matplotlib python3-matplotlib-inline python3-minimal python3-mpmath python3-mrcal python3-numpy python3-numpysane python3-opencv python3-packaging python3-parso python3-pexpect python3-pickleshare python3-pil python3-pil.imagetk python3-pkg-resources python3-ply python3-prompt-toolkit python3-ptyprocess python3-pygments python3-pyparsing python3-pythran python3-scipy python3-shapely python3-six python3-sympy python3-tk python3-traitlets python3-tz python3-ufolib2 python3-unicodedata2 python3-wcwidth python3.10 python3.10-dev python3.10-minimal rpcsvc-proto shared-mime-info systemd systemd-sysv tk8.6-blt2.5 tzdata ubuntu-mono ucf unicode-data unixodbc-common x11-common xkb-data zlib1g-dev 0 upgraded, 426 newly installed, 0 to remove and 0 not upgraded. Need to get 342 MB of archives. After this operation, 1497 MB of additional disk space will be used. ```
dkogan commented 5 months ago

Robots are generally an offline environment, which drives the need for a completely offline solution. For competition, we also need to disable wireless, which forces you to somehow find a wired internet port at your school/workshop. I agree that in a perfect world, you'd just plug your coprocessor into your school LAN and download some packages, but that's outside the reach of a good chunk of our users.

I don't follow. Currently you download an image from the internet and use it to initialize an OS with some packages; then you can be offline. How's that different from downloading some packages from the internet and then going offline?

The concern about total disk space is to keep image download/flashing speed from bloating too much, and also just proactively trying to not hit Github's download size limit. I'm just not sure if the value prop is there for increasing the size of our image this much is there yet.

I don't know your system at all, so I'm going to stop proposing things. If you want to have a separate conversation about Debian packages and apt servers and managing installs and whatnot, we can do that separately from this issue. I'm a Debian Developer, and have managed many such things previously.

From a fresh docker image of ubuntu:22.04, I see:

... After this operation, 1497 MB of additional disk space will be used.

OK, so we saved ~ 100MB by picking a different gnuplot? That's not nothing, but it's also not everything either.

mcm001 commented 5 months ago

Yeah, that's something! When we're talking about the co-processors that people run photon on, they tend to be completely headless setups -- is it worth trying to avoid installing gnuplot/other GUI tools altogether?

Photonvision also ships with opencv (not installed as a package, but as just shared libraries from our opencv fork here embedded in the JAR, so it seems duplicative to also install opencv packages assuming mrcal could work with opencv 4.8.0. And you only need a couple modules from opencv for a vanilla monocular camera calibration right? (I saw solvePNP used, but I think that was it). I see used:

I also noticed that python3-opencv is using packages named libopencv-[MODULE]4.5d -- does this mean that they're packages with debug symbols?

I think if we can get opencv trimmed down a bit, this could be a viable option to pursue once the season wraps up

mcm001 commented 5 months ago

Another thing I'll throw onto the pile for consideration. Our current JNI setup doesn't require Windows users install any additional programs to make Photon work. If we go the path of directly calling mrcal-python, that won't be true anymore. I think that whatever solution we end up at, making sure it work painlessly under windows is a hard requirement.

dkogan commented 5 months ago

Matt @.***> writes:

they tend to be completely headless setups -- is it worth trying to avoid installing gnuplot/other GUI tools altogether?

Some things are still useful: you can x-forward gnuplot for instance. But the gnuplot packages have flavors of different fatness (because those packages were built when disk space was more at a premium). You certainly don't need most of opencv, but it would take some work to disentangle that

Photonvision also ships with opencv (not installed as a package, but as just shared libraries from our opencv fork here embedded in the JAR, so it seems duplicative to also install opencv packages assuming mrcal could work with opencv 4.8.0.

That's on photonvision for doing something weird. It should be installing and using the system packages.

And you only need a couple modules from opencv for a vanilla monocular camera calibration right? (I saw solvePNP used, but I think that was it). I see used:

  • cv2.findContours
  • cv2.contourArea
  • cv2.solvePNP

That sounds right.

I also noticed that python3-opencv is using packages named libopencv-[MODULE]4.5d -- does this mean that they're packages with debug symbols?

The meaning of the "d" is a question for whoever wrote the opencv build system. The debian packaging strips out the debug symbols into separate packages (called whatever-dbgsym). All the package sizes we've been looking at do not include the debug symbols.

I think if we can get opencv trimmed down a bit, this could be a viable option to pursue once the season wraps up

Let's talk separately from this issue later, when you actually want to undertake bigger surgery.

mcm001 commented 5 months ago
   // Fill in object/image points
   for (int i = 0; i < boardSize.height; i++) {
     for (int j = 0; j < boardSize.width; j++) {
-      auto &corner = c_observations_board_pool[i * boardSize.height + j];
+      auto &corner = c_observations_board_pool[i * boardSize.width + j];

Found the bug! Bad iteration bounds in where we fill in our chessboard corner array. I found it by just comparing inputs to cv::solvePNP between mrcal-calibrate-cameras and our JNI. This was causing solvepnp to give totally wrong seed poses, leading to the not positive definite warnings (I think). I now get basically identical outputs from the two calibration APIs:

cpp: Intrinsics [12]:    895.605941   896.407818   829.075501   665.325699   -0.001086       -0.007815     0.000080 0.001626 0.116579 -0.049334 0.064817 0.100289 
mrcal-calibrate-cameras: 895.5869583, 896.3883938, 829.0801411, 665.3252287, 0.004235123928, -0.01917739877, 7.928632284e-05, 0.001627242293, 0.107986625, -0.04425876899, 0.05428592994, 0.09100042495

See https://github.com/PhotonVision/mrcal-java/pull/3

dkogan commented 5 months ago

Awesome! Glad you found that. Let me know if you hit any other issues that I can help with.