# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import division

import warnings

from telemetry.internal.util import external_modules
from telemetry.util import color_histogram
from telemetry.util import rgba_color
import png

cv2 = external_modules.ImportOptionalModule('cv2')
np = external_modules.ImportRequiredModule('numpy')


def Channels(image):
    return image.shape[2]


def Width(image):
    return image.shape[1]


def Height(image):
    return image.shape[0]


def Pixels(image):
    return bytearray(np.uint8(
from devil.android.sdk import version_codes
from devil.android.tools import provision_devices
from devil.android.tools import video_recorder

try:
    # devil.android.forwarder uses fcntl, which doesn't exist on Windows.
    from devil.android import forwarder
except ImportError:
    forwarder = None

try:
    from devil.android.perf import surface_stats_collector
except Exception:  # pylint: disable=broad-except
    surface_stats_collector = None

psutil = external_modules.ImportOptionalModule('psutil')

_ARCH_TO_STACK_TOOL_ARCH = {
    'armeabi-v7a': 'arm',
    'arm64-v8a': 'arm64',
}
_DEVICE_COPY_SCRIPT_FILE = os.path.abspath(
    os.path.join(os.path.dirname(__file__),
                 'efficient_android_directory_copy.sh'))
_DEVICE_COPY_SCRIPT_LOCATION = (
    '/data/local/tmp/efficient_android_directory_copy.sh')
_DEVICE_MEMTRACK_HELPER_LOCATION = '/data/local/tmp/profilers/memtrack_helper'
_DEVICE_CLEAR_SYSTEM_CACHE_TOOL_LOCATION = '/data/local/tmp/clear_system_cache'


class AndroidPlatformBackend(
Пример #3
0
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Color Histograms and implementations of functions operating on them."""

from __future__ import division

import collections

from telemetry.internal.util import external_modules

np = external_modules.ImportOptionalModule('numpy')


def HistogramDistance(hist1, hist2, default_color=None):
    """Earth mover's distance.
  http://en.wikipedia.org/wiki/Earth_mover's_distance"""
    if len(hist1) != len(hist2):
        raise ValueError('Trying to compare histograms '
                         'of different sizes, %s != %s' %
                         (len(hist1), len(hist2)))
    if len(hist1) == 0:
        return 0

    sum_func = np.sum if np is not None else sum

    n1 = sum_func(hist1)
    n2 = sum_func(hist2)
    if (n1 == 0 or n2 == 0) and default_color is None:
        raise ValueError('Histogram has no data and no default color.')
    if n1 == 0: