"""Utilities for opencv library"""
from __future__ import print_function
from __future__ import absolute_import

import cv2


class single_threaded_opencv(object):  # pylint: disable=invalid-name
    '''
    Context manager that disables IPP for deterministic results and sets number of threads to 0 to avoid
    hanging in multiprocessing forks
    '''
    def __init__(self):
        self._number_of_threads = None

    def __enter__(self):
        cv2.ipp.setUseIPP(flag=False)
        self._number_of_threads = cv2.getNumThreads()
        cv2.setNumThreads(0)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        cv2.setNumThreads(self._number_of_threads)

9a5d2df267aa8c673ab68c6f87695c3c35804c56
<mask token>


class single_threaded_opencv(object):
    <mask token>
    <mask token>

    def __enter__(self):
        cv2.ipp.setUseIPP(flag=False)
        self._number_of_threads = cv2.getNumThreads()
        cv2.setNumThreads(0)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        cv2.setNumThreads(self._number_of_threads)

<mask token>


class single_threaded_opencv(object):
    <mask token>

    def __init__(self):
        self._number_of_threads = None

    def __enter__(self):
        cv2.ipp.setUseIPP(flag=False)
        self._number_of_threads = cv2.getNumThreads()
        cv2.setNumThreads(0)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        cv2.setNumThreads(self._number_of_threads)

<mask token>


class single_threaded_opencv(object):
    """
    Context manager that disables IPP for deterministic results and sets number of threads to 0 to avoid
    hanging in multiprocessing forks
    """

    def __init__(self):
        self._number_of_threads = None

    def __enter__(self):
        cv2.ipp.setUseIPP(flag=False)
        self._number_of_threads = cv2.getNumThreads()
        cv2.setNumThreads(0)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        cv2.setNumThreads(self._number_of_threads)

<mask token>
from __future__ import print_function
from __future__ import absolute_import
import cv2


class single_threaded_opencv(object):
    """
    Context manager that disables IPP for deterministic results and sets number of threads to 0 to avoid
    hanging in multiprocessing forks
    """

    def __init__(self):
        self._number_of_threads = None

    def __enter__(self):
        cv2.ipp.setUseIPP(flag=False)
        self._number_of_threads = cv2.getNumThreads()
        cv2.setNumThreads(0)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        cv2.setNumThreads(self._number_of_threads)

"""Utilities for opencv library"""
from __future__ import print_function
from __future__ import absolute_import

import cv2


class single_threaded_opencv(object):  # pylint: disable=invalid-name
    '''
    Context manager that disables IPP for deterministic results and sets number of threads to 0 to avoid
    hanging in multiprocessing forks
    '''
    def __init__(self):
        self._number_of_threads = None

    def __enter__(self):
        cv2.ipp.setUseIPP(flag=False)
        self._number_of_threads = cv2.getNumThreads()
        cv2.setNumThreads(0)
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        cv2.setNumThreads(self._number_of_threads)
