mdegans / nano_build_opencv

Build OpenCV on Nvidia Jetson Nano
MIT License
504 stars 199 forks source link

OpenCV was not built with OpenGL support #51

Open mdegans opened 3 years ago

mdegans commented 3 years ago

Which means imshow can't display a GpuMat without a download. Fix is to track down opengl dev packages in ubuntu's repos and add them to the apt-get install stanza.

ArosPrince commented 2 years ago

Hi, can you please elaborate a bit on the proposed fix? It's not clear to me at all, what should I do in such a case. Is this before running the script or after?

mdegans commented 2 years ago

Hi, can you please elaborate a bit on the proposed fix? It's not clear to me at all, what should I do in such a case. Is this before running the script or after?

So, in order to directly imshow a GpuMat without downloading it to a Mat, you need to build OpenCV with OpenGL support or you get this error:

... Library was built without OpenGL support ...

Generally this means tracking down some blablabla-dev package in Canonical's apt repositories and making sure it's installed before build.

To answer your question, you could either install such a package before running the script or add it somewhere in this list here: https://github.com/mdegans/nano_build_opencv/blob/0832a850f33a64e3c14de065ed205db863b25f0e/build_opencv.sh#L64

it's likely these packages: https://askubuntu.com/questions/306703/compile-opengl-program-missing-gl-gl-h#comment1952106_866868

So just adding mesa-common-dev, libglu1-mesa-dev, freeglut3-dev, libglfw3-dev and libgles2-mesa-dev will probably fix it. I don't know exactly which if those OpenCV actually requires. Possibly just the first. Possibly all of them. You can test and see. I haven't had time to recently or to look into exactly what cmake is expecting.

If it works, you should see:

--     OpenGL support:              YES

If you do, and get a GpuMat displaying directly in imshow feel free to submit a PR closing this issue out.

ArosPrince commented 2 years ago

OK, will try that and submit a PR if that works.

One more question though... Can I just rerun the script after installing the packages, do I somehow have to uninstall it first (I have already built opencv).

mdegans commented 2 years ago

You should be able to just re-run the script.

On Tue, Oct 19, 2021, 3:59 AM ArosPrince @.***> wrote:

OK, will try that and submit a PR if that works.

One more question though... Can I just rerun the script after installing the packages, do I somehow have to uninstall it first (I have already built opencv).

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/mdegans/nano_build_opencv/issues/51#issuecomment-946609730, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALKPTHPQWSVVLTAY3TDTWMDUHVFQDANCNFSM4Y4GDVKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.