Last active
October 26, 2018 08:30
-
-
Save jackersson/7fee7096f8347634d0da57013cba45dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
required_libs = { | |
"gstreamer": "1.14.2".split("."), | |
"tensorflow": "1.10.0".split("."), | |
"opencv": "3.4.0".split(".") | |
} | |
def check_opencv(): | |
major, minor, _ = 0, 0, 0 | |
try: | |
import cv2 | |
major, minor, _ = cv2.__version__.split(".") | |
except Exception as e: | |
raise ImportError("Can't import OpenCV") | |
rmajor, rminor, _ = required_libs["opencv"] | |
assert str(major) == str(rmajor), "Invalid OpenCV Version.Installed: {}.{}, Required: v{}.{}".format(major, minor, rmajor, rminor) | |
def check_tesorflow(): | |
major, minor, _ = 0, 0, 0 | |
try: | |
import tensorflow as tf | |
major, minor, _ = tf.__version__.split(".") | |
except Exception as e: | |
raise ImportError("Can't import Tensorflow") | |
rmajor, rminor, _ = required_libs["tensorflow"] | |
assert str(major) == str(rmajor) and str(minor) == str(rminor), \ | |
"Invalid Tensorflow Version. Installed: {}.{}. Required: v{}.{}".format(major, minor, rmajor, rminor) | |
def check_gstreamer(): | |
major, minor, micro = 0, 0, 0 | |
try: | |
import gi | |
gi.require_version('Gst', '1.0') | |
gi.require_version('GstBase', '1.0') | |
from gi.repository import Gst, GObject | |
Gst.init(None) | |
major, minor, micro, _ = Gst.version() | |
except Exception as e: | |
raise ImportError("Can't import Gstreamer") | |
rmajor, rminor, rmicro = required_libs["gstreamer"] | |
assert str(major) == str(rmajor) and str(minor) == str(rminor), \ | |
"Invalid Gstreamer Version. Installed: {}.{}.{}.Required: v{}.{}.{}".format(major, minor, micro, rmajor, rminor, rmicro) | |
check_gstreamer() | |
check_opencv() | |
check_tesorflow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment