I encountered the same issue lately.
You can downgrade with sudo apt -y --allow-downgrades install libopencv-dev=3.2.0+dfsg-4ubuntu0.1
and hold (avoid it being upgraded) with sudo apt-mark hold libopencv-dev
.
If you have time, try to work on making your packages compatible with OpenCV 4 (e.g. by removing usage of the C API) since focal, and therefore noetic, drops support for OpenCV 3. To make everything work on melodic, your best bet right now is to downgrade and hold.
Originally posted by kmfrick with karma: 26 on 2020-05-08
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by jorgemia on 2020-05-09:
Thanks! Managed to find and install from source releases of certain packages that were compatible with OpenCV 4 but it has been a real pain to get it to work because had to rebuild CV Bridge and many others...I think downgrading is probably better as you say until more packages work with OpenCV 4.
Will the downgrade command you posted remove OpenCV 4 from the Nano?
Comment by kmfrick on 2020-05-10:
Yes, it should remove OpenCV 4 and install version 3.2.0.
Comment by floda on 2020-06-21:
@jorgemia Do you mind posting your steps in recompiling cv_bridge? I got badly stuck there.
Comment by jorgemia on 2020-06-22:
@floda Hey I did it a while back but basically installed someone's fork from github where they had changed files to support opencv 4. You can find info here that might be useful: Github Issue and you could check some of the pull requests on github. Some of them might have been merged already so cv_bridge might already support OpenCV4. Also, the latest noetic release of cv-bridge supports OpenCv4, you might be able to install that.