示例#1
0
def check_build_info():
    success = True

    print("OpenCV Version: {}".format(cv2.__version__))
    if (cv2.getVersionMajor() != CURRENT_OPENCV_BUILD_VERSION[0]) and (
            cv2.getVersionMinor() != CURRENT_OPENCV_BUILD_VERSION[1]) and (
            cv2.getVersionRevision() != CURRENT_OPENCV_BUILD_VERSION[2]):
        print("ERROR: OpenCV version is different than the expected.")
        success = False

    print("Available CPUs: ", cv2.getNumberOfCPUs())
    print("Available threads: ", cv2.getNumThreads())
    if cv2.getNumThreads() < cv2.getNumberOfCPUs():
        print("ERROR: TBB is not enabled.")
        success = False

    cv2.CPU_NEON = 100  # Value taken from OpenCV doc. CPU labels don't work correctly in Python
    print("Cpu NEON support: ", cv2.checkHardwareSupport(cv2.CPU_NEON))
    if not cv2.checkHardwareSupport(cv2.CPU_NEON):
        print("ERROR: NEON is not enabled.")
        success = False

    return success
示例#2
0
cv2.imshow("blank", img)


def rotate_imutils(img, angle):
    return imutils.rotate(img, angle)


def rotate_function(img, angle):
    rotation_mat = cv2.getRotationMatrix2D(
        (img.shape[0] / 2, img.shape[1] / 2), angle, 1.0)
    return cv2.warpAffine(img, rotation_mat, (img.shape[0], img.shape[1]))


for i in range(1, 15):
    print("index: {} feature:{} supported: {}".format(
        i, cv2.getHardwareFeatureName(i), cv2.checkHardwareSupport(i)))

start = time.time()
ri = rotate_imutils(img, 90)
end = time.time()
print("Total time taken by imutils {}".format(end - start))

start = time.time()
rf = rotate_function(img, 90)
end = time.time()
print("Total time taken by rotate function {}".format(end - start))

# do something with blank image
cnt = 0
while True:
    img = img + cnt
	# until setUseOptimized(true) is called. 
	# This way user can dynamically switch on and off the optimized code in OpenCV.

	# Assign ID to Features as this doesn't seem to be working currently
	cv2.CPU_MMX = 1
	cv2.CPU_SSE = 2
	cv2.CPU_SSE2 = 3
	cv2.CPU_SSE3 = 4
	cv2.CPU_SSSE3 = 5
	cv2.CPU_SSE4_1 = 6
	cv2.CPU_SSE4_2 = 7
	cv2.CPU_POPCNT = 8
	cv2.CPU_AVX = 9

	# Returns True if CPU is MMX capable
	mmx = cv2.checkHardwareSupport(cv2.CPU_MMX)
	# Returns True if CPU is SSE capable
	sse = cv2.checkHardwareSupport(cv2.CPU_SSE)
	# Returns True if CPU is SSE2 capable
	sse2 = cv2.checkHardwareSupport(cv2.CPU_SSE2)
	# Returns True if CPU is SSE3 capable
	sse3 = cv2.checkHardwareSupport(cv2.CPU_SSE3)
	# Returns True if CPU is SSSE3 capable
	ssse3 = cv2.checkHardwareSupport(cv2.CPU_SSSE3)
	# Returns True if CPU is SSE4.1 capable
	sse4_1 = cv2.checkHardwareSupport(cv2.CPU_SSE4_1)
	# Returns True if CPU is SSE4.2 capable
	sse4_2 = cv2.checkHardwareSupport(cv2.CPU_SSE4_2)
	# Returns True if CPU is POP capable
	popcnt = cv2.checkHardwareSupport(cv2.CPU_POPCNT)
	# Returns True if CPU is AVX capable
示例#4
0
        CV_CPU_AVX - AVX
    """
    if config.OCV_OLD_PY_BINDINGS == False:
        featDict = {cv2.CPU_AVX: "AVX",
                cv2.CPU_MMX: "MMX",
                cv2.CPU_NEON: "NEON",
                cv2.CPU_POPCNT: "POPCNT",
                cv2.CPU_SSE: "SSE",
                cv2.CPU_SSE2: "SSE2",
                cv2.CPU_SSE3: "SSE3",
                cv2.CPU_SSE4_1: "SSE4.1",
                cv2.CPU_SSE4_2: "SSE4.2",
                cv2.CPU_SSSE3: "SSSE3"};

        for feat in featDict:
            res = cv2.checkHardwareSupport(feat);
            print("%s = %d" % (featDict[feat], res));
        #cv2.setUseOptimized(onoff)!!!!

    # "Returns the number of logical CPUs available for the process."
    common.DebugPrint("cv2.getNumberOfCPUs() (#logical CPUs) is %s" % str(cv2.getNumberOfCPUs()));
    common.DebugPrint("cv2.getTickFrequency() is %s" % str(cv2.getTickFrequency()));

    """
    Available only in C++:
    # "getNumThreads - Returns the number of threads used by OpenCV for parallel regions."
    common.DebugPrint("cv2.getNumThreads() (#logical CPUs) is %s" % str(cv2.getNumThreads()));
    """


    videoPathFileNameQ = sys.argv[1]; # input/current video