<jupyter_start><jupyter_text>OpenCV Tutorial Sample 7: ocv_hw_info[Sample 07](ocv_hw_info.py) is a simple diagnostic program that determines how many logical CPU's are available and then queries the hardware to check whether MMX and Streaming SIMD Extensions (SSE), Advanced Vector Extensions etc. are supported .> _**Note:**_ The OpenCV function cv2.checkHardwareSupport(feature) returns true if the host hardware supports the specified feature. When users call setUseOptimized(False), all the subsequent calls to cv2.checkHardwareSupport() will return false until cv2.setUseOptimized(True) is called. This way users can dynamically switch on and off the optimized code in OpenCV.Start with the usual initializations<jupyter_code>#!/usr/bin/env python

# Python 2/3 compatibility
from __future__ import print_function
# Allows use of print like a function in Python 2.x

# Import the OpenCV2 module
import cv2<jupyter_output><empty_output><jupyter_text>Check the number of logical CPUs available<jupyter_code># Returns the number of logical CPUs available
cpu = cv2.getNumberOfCPUs()
print()
print("Number of logical CPU's Available: ", end='')
print(cpu)
print()
#Reset Hardware Optimization Flags
cv2.setUseOptimized(True)<jupyter_output><empty_output><jupyter_text>The functions below return true if the host hardware supports the specified feature.When user calls setUseOptimized(false), all the subsequent calls to checkHardwareSupport() will return false until setUseOptimized(true) is called. This way user can dynamically switch on and off the optimized code in OpenCV.<jupyter_code># Assign ID to Features as this doesn't seem to be working currently for Python
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)
print("CPU MMX Capable?: ", end='')
print(mmx)
# Returns True if CPU is SSE capable
sse = cv2.checkHardwareSupport(cv2.CPU_SSE)
print("CPU SSE Capable?: ", end='')
print(sse)
# Returns True if CPU is SSE2 capable
sse2 = cv2.checkHardwareSupport(cv2.CPU_SSE2)
print("CPU SSE 2 Capable?: ", end='')
print(sse2)
# Returns True if CPU is SSE3 capable
sse3 = cv2.checkHardwareSupport(cv2.CPU_SSE3)
print("CPU SSE 3 Capable?: ", end='')
print(sse3)
# Returns True if CPU is SSSE3 capable
ssse3 = cv2.checkHardwareSupport(cv2.CPU_SSSE3)
print("CPU SSSE 3 Capable?: ", end='')
print(ssse3)
# Returns True if CPU is SSE4.1 capable
sse4_1 = cv2.checkHardwareSupport(cv2.CPU_SSE4_1)
print("CPU SSE 4.1 Capable?: ", end='')
#print(cv2.getNumberOfCPUs())
print(sse4_1)
# Returns True if CPU is SSE4.2 capable
sse4_2 = cv2.checkHardwareSupport(cv2.CPU_SSE4_2)
print("CPU SSE 4.2 Capable?: ", end='')
print(sse4_2)
# Returns True if CPU is POP capable
popcnt = cv2.checkHardwareSupport(cv2.CPU_POPCNT)
print("CPU POPCNT Capable?: ", end='')
print(popcnt)
# Returns True if CPU is AVX capable
avx = cv2.checkHardwareSupport(cv2.CPU_AVX)
print("CPU AVX Capable?: ", end='')
print(avx)<jupyter_output>CPU AVX Capable?: True
{'fraction_non_alphanumeric': 0.09502407704654896, 'fraction_numerical': 0.029534510433386837, 'mean_word_length': 5.986547085201794, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '336764', 'license': 'MIT', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1064, 'n_words': 351, 'path': 'tutorials/opencv/Python/sample_07_hw_info/ocv_hw_info.ipynb', 'repo_name': 'intel-iot-devkit/Intel-Digital-Signage-Reference', 'size': '3115'}