wko/wko-09.ipynb
2023-01-30 13:54:58 +01:00

2240 lines
74 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"source": [
"# Load the Drive helper and mount\n",
"from google.colab import drive\n",
"drive.mount('/content/drive')"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "XMhear0qzu8f",
"outputId": "faf23eb1-d714-45a9-861b-49e6b62688cf"
},
"id": "XMhear0qzu8f",
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Mounted at /content/drive\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"path_to_file = \"/content/wko\"\n",
"path_to_output = \"/content/drive/MyDrive/wko\""
],
"metadata": {
"id": "65fjKiP4zyIS"
},
"id": "65fjKiP4zyIS",
"execution_count": 2,
"outputs": []
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"id": "lVbA5V_Qz6A1"
},
"id": "lVbA5V_Qz6A1"
},
{
"cell_type": "markdown",
"source": [
"# To drive"
],
"metadata": {
"id": "cJiwBNCO0cuO"
},
"id": "cJiwBNCO0cuO"
},
{
"cell_type": "code",
"source": [
"import shutil\n",
"\n",
"\n",
"shutil.make_archive(path_to_output, 'zip', path_to_file)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
"id": "s5Pp_uxtzzz2",
"outputId": "be14c2e3-7b55-4f63-95c2-a6bfd0e5276a"
},
"id": "s5Pp_uxtzzz2",
"execution_count": 4,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'/content/drive/MyDrive/wko.zip'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 4
}
]
},
{
"cell_type": "markdown",
"source": [
"# To content"
],
"metadata": {
"id": "Zw64JOfo0i5T"
},
"id": "Zw64JOfo0i5T"
},
{
"cell_type": "code",
"source": [
"import zipfile\n",
"with zipfile.ZipFile(path_to_output + \".zip\",\"r\") as zip_ref:\n",
" zip_ref.extractall(path_to_file)"
],
"metadata": {
"id": "qexyVQz2z1X-"
},
"id": "qexyVQz2z1X-",
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!git clone https://git.wmi.amu.edu.pl/s444417/wko"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "QZW4MUd51L6Z",
"outputId": "5e000be4-4776-41c9-8d1c-c8a05b3f0e12"
},
"id": "QZW4MUd51L6Z",
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'wko'...\n",
"remote: Enumerating objects: 102, done.\u001b[K\n",
"remote: Counting objects: 100% (102/102), done.\u001b[K\n",
"remote: Compressing objects: 100% (100/100), done.\u001b[K\n",
"remote: Total 102 (delta 2), reused 102 (delta 2)\u001b[K\n",
"Receiving objects: 100% (102/102), 126.67 MiB | 476.00 KiB/s, done.\n",
"Resolving deltas: 100% (2/2), done.\n",
"Checking out files: 100% (97/97), done.\n"
]
}
]
},
{
"cell_type": "markdown",
"id": "80377b3b",
"metadata": {
"id": "80377b3b"
},
"source": [
"![Logo 1](img/aitech-logotyp-1.jpg)\n",
"<div class=\"alert alert-block alert-info\">\n",
"<h1> Widzenie komputerowe </h1>\n",
"<h2> 09. <i>Metody głębokiego uczenia (1)</i> [laboratoria]</h2> \n",
"<h3>Andrzej Wójtowicz (2021)</h3>\n",
"</div>\n",
"\n",
"![Logo 2](img/aitech-logotyp-2.jpg)"
]
},
{
"cell_type": "markdown",
"id": "07159136",
"metadata": {
"id": "07159136"
},
"source": [
"W poniższym materiale zobaczymy w jaki sposób korzystać z metod głębokiego uczenia sieci neuronowych w pakiecie OpenCV.\n",
"\n",
"Na początku załadujmy niezbędne biblioteki:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b2e906f0",
"metadata": {
"id": "b2e906f0"
},
"outputs": [],
"source": [
"import cv2 as cv\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "f4348bc5",
"metadata": {
"id": "f4348bc5"
},
"source": [
"OpenCV wspiera [wiele](https://github.com/opencv/opencv/wiki/Deep-Learning-in-OpenCV) bibliotek i modeli sieci neuronowych. Modele trenuje się poza OpenCV - bibliotekę wykorzystuje się tylko do predykcji, aczkolwiek sama w sobie ma całkiem sporo możliwych optymalizacji w porównaniu do źródłowych bibliotek neuronowych, więc predykcja może być tutaj faktycznie szybsza.\n",
"\n",
"Pliki z modelami i danymi pomocniczymi będziemy pobierali z sieci i będziemy je zapisywali w katalogu `dnn`:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "42b85f55",
"metadata": {
"id": "42b85f55"
},
"outputs": [],
"source": [
"!mkdir -p dnn"
]
},
{
"cell_type": "markdown",
"id": "ac09b098",
"metadata": {
"id": "ac09b098"
},
"source": [
"# Klasyfikacja obrazów\n",
"\n",
"Spróbujemy wykorzystać sieć do klasyfikacji obrazów wyuczonej na zbiorze [ImageNet](https://www.image-net.org/). Pobierzmy plik zawierający opis 1000 możliwych klas:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "85b1b68c",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "85b1b68c",
"outputId": "0f00a7e8-4d88-4436-ed74-1de4038ca01d"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n",
"100 21675 100 21675 0 0 52103 0 --:--:-- --:--:-- --:--:-- 52103\n"
]
}
],
"source": [
"!wget -o dnn/classification_classes_ILSVRC2012.txt https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt "
]
},
{
"cell_type": "markdown",
"id": "fd0c577b",
"metadata": {
"id": "fd0c577b"
},
"source": [
"Spójrzmy na pierwsze pięć klas w pliku:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "fb0d0546",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "fb0d0546",
"outputId": "69ff98eb-aa41-4a5e-dbe4-46cc9a8c4443"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"1000 ['tench, Tinca tinca', 'goldfish, Carassius auratus', 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', 'tiger shark, Galeocerdo cuvieri', 'hammerhead, hammerhead shark']\n"
]
}
],
"source": [
"with open('dnn/classification_classes_ILSVRC2012.txt', 'r') as f_fd:\n",
" classes = f_fd.read().splitlines()\n",
" \n",
"print(len(classes), classes[:5])"
]
},
{
"cell_type": "markdown",
"id": "5b0ee6ff",
"metadata": {
"id": "5b0ee6ff"
},
"source": [
"Do klasyfikacji użyjemy sieci [DenseNet](https://arxiv.org/abs/1608.06993). Pobierzemy jedną z mniejszych [reimplementacji](https://github.com/shicai/DenseNet-Caffe), która jest hostowana m.in. na Google Drive (musimy doinstalować jeden pakiet):"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "fb2bf2a1",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "fb2bf2a1",
"outputId": "19e1b29b-6362-49bc-dedb-4d208838c706"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Requirement already satisfied: gdown in /usr/local/lib/python3.8/dist-packages (4.4.0)\n",
"Requirement already satisfied: filelock in /usr/local/lib/python3.8/dist-packages (from gdown) (3.9.0)\n",
"Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.8/dist-packages (from gdown) (4.6.3)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.8/dist-packages (from gdown) (4.64.1)\n",
"Requirement already satisfied: requests[socks] in /usr/local/lib/python3.8/dist-packages (from gdown) (2.25.1)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.8/dist-packages (from gdown) (1.15.0)\n",
"Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.8/dist-packages (from requests[socks]->gdown) (4.0.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.8/dist-packages (from requests[socks]->gdown) (2022.12.7)\n",
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.8/dist-packages (from requests[socks]->gdown) (2.10)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.8/dist-packages (from requests[socks]->gdown) (1.24.3)\n",
"Requirement already satisfied: PySocks!=1.5.7,>=1.5.6 in /usr/local/lib/python3.8/dist-packages (from requests[socks]->gdown) (1.7.1)\n"
]
}
],
"source": [
"!pip3 install --user --disable-pip-version-check gdown"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "27996509",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 105
},
"id": "27996509",
"outputId": "8be12cd1-0138-40a8-9b30-30abb52ae725"
},
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"Downloading...\n",
"From: https://drive.google.com/uc?id=0B7ubpZO7HnlCcHlfNmJkU2VPelE\n",
"To: /content/dnn/DenseNet_121.caffemodel\n",
"100%|██████████| 32.3M/32.3M [00:01<00:00, 29.4MB/s]\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"'dnn/DenseNet_121.caffemodel'"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
}
},
"metadata": {},
"execution_count": 10
}
],
"source": [
"import gdown\n",
"\n",
"url = 'https://drive.google.com/uc?id=0B7ubpZO7HnlCcHlfNmJkU2VPelE'\n",
"output = 'dnn/DenseNet_121.caffemodel'\n",
"gdown.download(url, output, quiet=False)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "648ec9c9",
"metadata": {
"id": "648ec9c9"
},
"outputs": [],
"source": [
"!wget -o dnn/DenseNet_121.prototxt https://raw.githubusercontent.com/shicai/DenseNet-Caffe/master/DenseNet_121.prototxt"
]
},
{
"cell_type": "markdown",
"id": "f7294c54",
"metadata": {
"id": "f7294c54"
},
"source": [
"Konkretne biblioteki neuronowe posiadają dedykowane funkcje do ładowania modeli, np. [`readNetFromCaffe()`](https://docs.opencv.org/4.5.3/d6/d0f/group__dnn.html#ga29d0ea5e52b1d1a6c2681e3f7d68473a) lub [`readNetFromTorch()`](https://docs.opencv.org/4.5.3/d6/d0f/group__dnn.html#ga65a1da76cb7d6852bdf7abbd96f19084), jednak można też użyć ogólnej [`readNet()`](https://docs.opencv.org/4.5.3/d6/d0f/group__dnn.html#ga3b34fe7a29494a6a4295c169a7d32422):"
]
},
{
"cell_type": "code",
"source": [
"!pip install opencv-python==4.5.5.62"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 314
},
"id": "P3FhiU02278Z",
"outputId": "926d0b1a-c672-4678-f08f-22adab12a33c"
},
"id": "P3FhiU02278Z",
"execution_count": 18,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting opencv-python==4.5.5.62\n",
" Downloading opencv_python-4.5.5.62-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.4 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m60.4/60.4 MB\u001b[0m \u001b[31m11.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.8/dist-packages (from opencv-python==4.5.5.62) (1.21.6)\n",
"Installing collected packages: opencv-python\n",
" Attempting uninstall: opencv-python\n",
" Found existing installation: opencv-python 4.6.0.66\n",
" Uninstalling opencv-python-4.6.0.66:\n",
" Successfully uninstalled opencv-python-4.6.0.66\n",
"Successfully installed opencv-python-4.5.5.62\n"
]
},
{
"output_type": "display_data",
"data": {
"application/vnd.colab-display-data+json": {
"pip_warning": {
"packages": [
"cv2"
]
}
}
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6fd2d6b3",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 235
},
"id": "6fd2d6b3",
"outputId": "1e4a8309-7f81-4f13-d265-3c339d27c327"
},
"outputs": [
{
"output_type": "error",
"ename": "error",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31merror\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-3-38d16ae567b3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdnn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadNet\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'dnn/DenseNet_121.prototxt'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'dnn/DenseNet_121.caffemodel'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mframework\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'Caffe'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31merror\u001b[0m: OpenCV(4.5.5) /io/opencv/modules/dnn/src/caffe/caffe_io.cpp:1162: error: (-2:Unspecified error) FAILED: ReadProtoFromTextFile(param_file, param). Failed to parse NetParameter file: dnn/DenseNet_121.prototxt in function 'ReadNetParamsFromTextFileOrDie'\n"
]
}
],
"source": [
"model = cv.dnn.readNet(model='dnn/DenseNet_121.prototxt', config='dnn/DenseNet_121.caffemodel', framework='Caffe')"
]
},
{
"cell_type": "markdown",
"id": "fe22fd6f",
"metadata": {
"id": "fe22fd6f"
},
"source": [
"Spróbujemy sklasyfikować poniższy obraz:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ace4606",
"metadata": {
"id": "6ace4606"
},
"outputs": [],
"source": [
"image = cv.imread('img/flamingo.jpg')\n",
"plt.figure(figsize=[5,5])\n",
"plt.imshow(image[:,:,::-1]);"
]
},
{
"cell_type": "markdown",
"id": "e51db3ac",
"metadata": {
"id": "e51db3ac"
},
"source": [
"Aby móc przepuścić obraz przez sieć musimy zmienić jego formę reprezentacji poprzez funkcję [`blobFromImage()`](https://docs.opencv.org/4.5.3/d6/d0f/group__dnn.html#ga29f34df9376379a603acd8df581ac8d7). Aby uzyskać sensowne dane musimy ustawić parametry dotyczące preprocessingu (informacje o tym są zawarte na [stronie modelu](https://github.com/shicai/DenseNet-Caffe)):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d4e945ae",
"metadata": {
"id": "d4e945ae"
},
"outputs": [],
"source": [
"image_blob = cv.dnn.blobFromImage(image=image, scalefactor=0.017, size=(224, 224), mean=(104, 117, 123), \n",
" swapRB=False, crop=False)"
]
},
{
"cell_type": "markdown",
"id": "625aebdd",
"metadata": {
"id": "625aebdd"
},
"source": [
"Ustawiamy dane wejściowe w naszej sieci i pobieramy obliczone wartości:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "753333a1",
"metadata": {
"id": "753333a1"
},
"outputs": [],
"source": [
"model.setInput(image_blob)\n",
"outputs = model.forward()[0]"
]
},
{
"cell_type": "markdown",
"id": "34316ddb",
"metadata": {
"id": "34316ddb"
},
"source": [
"Wyliczamy która klasa jest najbardziej prawdopodobna:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "13423a6d",
"metadata": {
"id": "13423a6d"
},
"outputs": [],
"source": [
"outputs = outputs.reshape(1000, 1)\n",
"\n",
"label_id = np.argmax(outputs)\n",
"\n",
"probs = np.exp(outputs) / np.sum(np.exp(outputs))"
]
},
{
"cell_type": "markdown",
"id": "874c1b1d",
"metadata": {
"id": "874c1b1d"
},
"source": [
"Wynik:"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "ec75a3c5",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 200
},
"id": "ec75a3c5",
"outputId": "b0479455-5052-44c6-94be-6d5145572723"
},
"outputs": [
{
"output_type": "error",
"ename": "TypeError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-16-52d75d665f1d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimshow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimage\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtitle\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclasses\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mlabel_id\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"{:.2f} %\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprobs\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0;36m100.0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable"
]
}
],
"source": [
"plt.imshow(image[:,:,::-1])\n",
"plt.title(classes[label_id])\n",
"print(\"{:.2f} %\".format(np.max(probs) * 100.0))"
]
},
{
"cell_type": "markdown",
"id": "3808c42c",
"metadata": {
"id": "3808c42c"
},
"source": [
"# Wykrywanie twarzy\n",
"\n",
"Do wykrywania twarzy użyjemy sieci bazującej na [SSD](https://github.com/weiliu89/caffe/tree/ssd):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c0df387",
"metadata": {
"id": "3c0df387"
},
"outputs": [],
"source": [
"!curl -o dnn/res10_300x300_ssd_iter_140000_fp16.caffemodel https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20180205_fp16/res10_300x300_ssd_iter_140000_fp16.caffemodel\n",
"!curl -o dnn/res10_300x300_ssd_iter_140000_fp16.prototxt https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt"
]
},
{
"cell_type": "markdown",
"id": "c6142f6e",
"metadata": {
"id": "c6142f6e"
},
"source": [
"Ładujemy model:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "60d41efb",
"metadata": {
"id": "60d41efb"
},
"outputs": [],
"source": [
"model = cv.dnn.readNet(model='dnn/res10_300x300_ssd_iter_140000_fp16.prototxt', config='dnn/res10_300x300_ssd_iter_140000_fp16.caffemodel', framework='Caffe')"
]
},
{
"cell_type": "markdown",
"id": "ad612cc6",
"metadata": {
"id": "ad612cc6"
},
"source": [
"Będziemy chcieli wykryć twarze na poniższym obrazie:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b404d8c4",
"metadata": {
"id": "b404d8c4"
},
"outputs": [],
"source": [
"image = cv.imread('img/people.jpg')\n",
"plt.figure(figsize=[7,7])\n",
"plt.imshow(image[:,:,::-1]);"
]
},
{
"cell_type": "markdown",
"id": "a77f8e64",
"metadata": {
"id": "a77f8e64"
},
"source": [
"Znajdujemy twarze i oznaczamy je na zdjęciu (za próg przyjęliśmy 0.5; zob. informacje o [preprocessingu](https://github.com/opencv/opencv/tree/master/samples/dnn#face-detection)):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d16f230",
"metadata": {
"id": "1d16f230"
},
"outputs": [],
"source": [
"height, width, _ = image.shape\n",
"\n",
"image_blob = cv.dnn.blobFromImage(image, scalefactor=1.0, size=(300, 300), mean=[104, 177, 123], \n",
" swapRB=False, crop=False)\n",
"\n",
"model.setInput(image_blob)\n",
"\n",
"detections = model.forward()\n",
"\n",
"image_out = image.copy()\n",
"\n",
"for i in range(detections.shape[2]):\n",
" confidence = detections[0, 0, i, 2]\n",
" if confidence > 0.5:\n",
"\n",
" box = detections[0, 0, i, 3:7] * np.array([width, height, width, height])\n",
" (x1, y1, x2, y2) = box.astype('int')\n",
"\n",
" cv.rectangle(image_out, (x1, y1), (x2, y2), (0, 255, 0), 6)\n",
" label = '{:.3f}'.format(confidence)\n",
" label_size, base_line = cv.getTextSize(label, cv.FONT_HERSHEY_SIMPLEX, 3.0, 1)\n",
" cv.rectangle(image_out, (x1, y1 - label_size[1]), (x1 + label_size[0], y1 + base_line), \n",
" (255, 255, 255), cv.FILLED)\n",
" cv.putText(image_out, label, (x1, y1), cv.FONT_HERSHEY_SIMPLEX, 3.0, (0, 0, 0))\n",
" \n",
"plt.figure(figsize=[12,12])\n",
"plt.imshow(image_out[:,:,::-1]);"
]
},
{
"cell_type": "markdown",
"id": "590841cd",
"metadata": {
"id": "590841cd"
},
"source": [
"## Punkty charakterystyczne twarzy\n",
"\n",
"W OpenCV jest możliwość wykrywania punktów charakterystycznych twarzy (ang. *facial landmarks*). Użyjemy zaimplementowanego [modelu](http://www.jiansun.org/papers/CVPR14_FaceAlignment.pdf) podczas Google Summer of Code przy użyciu [`createFacemarkLBF()`](https://docs.opencv.org/4.5.3/d4/d48/namespacecv_1_1face.html#a0bec73a729ed878430c2feb9ce65bc2a):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8534a399",
"metadata": {
"id": "8534a399"
},
"outputs": [],
"source": [
"!curl -o dnn/lbfmodel.yaml https://raw.githubusercontent.com/kurnianggoro/GSOC2017/master/data/lbfmodel.yaml"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2971f10",
"metadata": {
"id": "c2971f10"
},
"outputs": [],
"source": [
"landmark_detector = cv.face.createFacemarkLBF()\n",
"landmark_detector.loadModel('dnn/lbfmodel.yaml')"
]
},
{
"cell_type": "markdown",
"id": "761dbc15",
"metadata": {
"id": "761dbc15"
},
"source": [
"Ograniczamy nasze poszukiwania do twarzy:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "39215601",
"metadata": {
"id": "39215601"
},
"outputs": [],
"source": [
"faces = []\n",
"\n",
"for detection in detections[0][0]:\n",
" if detection[2] >= 0.5:\n",
" left = detection[3] * width\n",
" top = detection[4] * height\n",
" right = detection[5] * width\n",
" bottom = detection[6] * height\n",
"\n",
" face_w = right - left\n",
" face_h = bottom - top\n",
"\n",
" face_roi = (left, top, face_w, face_h)\n",
" faces.append(face_roi)\n",
"\n",
"faces = np.array(faces).astype(int)\n",
"\n",
"_, landmarks_list = landmark_detector.fit(image, faces)"
]
},
{
"cell_type": "markdown",
"id": "56aa90c9",
"metadata": {
"id": "56aa90c9"
},
"source": [
"Model generuje 68 punktów charakterycznych, które możemy zwizualizować:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d3ab726",
"metadata": {
"id": "6d3ab726"
},
"outputs": [],
"source": [
"image_display = image.copy()\n",
"landmarks = landmarks_list[0][0].astype(int)\n",
"\n",
"for idx, landmark in enumerate(landmarks):\n",
" cv.circle(image_display, landmark, 2, (0,255,255), -1)\n",
" cv.putText(image_display, str(idx), landmark, cv.FONT_HERSHEY_SIMPLEX, 0.35, (0, 255, 0), 1, \n",
" cv.LINE_AA)\n",
"\n",
"plt.figure(figsize=(10,10))\n",
"plt.imshow(image_display[700:1050,500:910,::-1]);"
]
},
{
"cell_type": "markdown",
"id": "7cee8969",
"metadata": {
"id": "7cee8969"
},
"source": [
"Jeśli nie potrzebujemy numeracji, to możemy użyć prostszego podejścia, tj. funkcji [`drawFacemarks()`](https://docs.opencv.org/4.5.3/db/d7c/group__face.html#ga318d9669d5ed4dfc6ab9fae2715310f5):"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1039e253",
"metadata": {
"id": "1039e253"
},
"outputs": [],
"source": [
"image_display = image.copy()\n",
"for landmarks_set in landmarks_list:\n",
" cv.face.drawFacemarks(image_display, landmarks_set, (0, 255, 0))\n",
"\n",
"plt.figure(figsize=(10,10))\n",
"plt.imshow(image_display[500:1050,500:1610,::-1]);"
]
},
{
"cell_type": "markdown",
"id": "db16a1bf",
"metadata": {
"id": "db16a1bf"
},
"source": [
"# Zadanie 1\n",
"\n",
"W katalogu `vid` znajdują się filmy `blinking-*.mp4`. Napisz program do wykrywania mrugnięć. Opcjonalnie możesz użyć *eye aspect ratio* z [tego artykułu](http://vision.fe.uni-lj.si/cvww2016/proceedings/papers/05.pdf) lub zaproponować własne rozwiązanie."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7da9d29f",
"metadata": {
"id": "7da9d29f"
},
"outputs": [],
"source": [
"from scipy.spatial import distance as dist\n",
"from imutils.video import FileVideoStream\n",
"from imutils.video import VideoStream\n",
"from imutils import face_utils\n",
"import numpy as np\n",
"import argparse\n",
"import imutils\n",
"import time\n",
"import dlib\n",
"import cv2"
]
},
{
"cell_type": "code",
"source": [
"! pip install opencv-contrib-python-headless==4.2.0.32\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "25CbAeBb8c1Q",
"outputId": "fa76374f-2af2-46c3-cfc1-7ecbf75fe144"
},
"id": "25CbAeBb8c1Q",
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Collecting opencv-contrib-python-headless==4.2.0.32\n",
" Using cached opencv_contrib_python_headless-4.2.0.32-cp38-cp38-manylinux1_x86_64.whl (27.7 MB)\n",
"Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.8/dist-packages (from opencv-contrib-python-headless==4.2.0.32) (1.21.6)\n",
"Installing collected packages: opencv-contrib-python-headless\n",
"Successfully installed opencv-contrib-python-headless-4.2.0.32\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"! yes Y | pip uninstall opencv-python\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "794ELS7yBGuy",
"outputId": "7e87ccda-f35a-41f3-a9c9-ff738651fcbe"
},
"id": "794ELS7yBGuy",
"execution_count": 8,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[33mWARNING: Skipping opencv-python as it is not installed.\u001b[0m\u001b[33m\n",
"\u001b[0m"
]
}
]
},
{
"cell_type": "code",
"source": [
"! pip install imutils"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Y0VuwXy-9k5E",
"outputId": "b36723f9-00cf-4651-eb7a-af1c6760c163"
},
"id": "Y0VuwXy-9k5E",
"execution_count": 15,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
"Requirement already satisfied: imutils in /usr/local/lib/python3.8/dist-packages (0.5.4)\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"! pip install dlib"
],
"metadata": {
"id": "bw7P-K569n7M"
},
"id": "bw7P-K569n7M",
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 5,
"id": "90ab8fb8",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "90ab8fb8",
"outputId": "3eb08f49-9ab0-4cbb-9112-a56fc2c60f61"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[INFO] loading facial landmark predictor...\n",
"[INFO] starting video stream thread...\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"Traceback (most recent call last):\n",
" File \"/content/wko/blink_detection_lab8.py\", line 136, in <module>\n",
" cv2.destroyAllWindows()\n",
"cv2.error: OpenCV(4.2.0) /io/opencv/modules/highgui/src/window.cpp:645: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows'\n",
"\n"
]
}
],
"source": [
"!python3 /content/wko/blink_detection_lab8.py -v /content/wko/vid/blinking-man.mp4 -p /content/wko/shape_predictor_68_face_landmarks.dat "
]
},
{
"cell_type": "code",
"source": [
"!python3 /content/wko/blink_detection_lab8.py -v /content/wko/vid/blinking-woman1.mp4 -p /content/wko/shape_predictor_68_face_landmarks.dat "
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "waCay1tdD4Ly",
"outputId": "50e5e2c3-1a44-4946-882c-16c8c087fda0"
},
"id": "waCay1tdD4Ly",
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[INFO] loading facial landmark predictor...\n",
"[INFO] starting video stream thread...\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 5\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 6\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 7\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 8\n",
"BLINKS COUNT: 9\n",
"BLINKS COUNT: 9\n",
"BLINKS COUNT: 9\n",
"BLINKS COUNT: 9\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 10\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 11\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"BLINKS COUNT: 12\n",
"Traceback (most recent call last):\n",
" File \"/content/wko/blink_detection_lab8.py\", line 136, in <module>\n",
" cv2.destroyAllWindows()\n",
"cv2.error: OpenCV(4.2.0) /io/opencv/modules/highgui/src/window.cpp:645: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows'\n",
"\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!python3 /content/wko/blink_detection_lab8.py -v /content/wko/vid/blinking-woman2.mp4 -p /content/wko/shape_predictor_68_face_landmarks.dat "
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_m0olI-HD9Dc",
"outputId": "e496e977-cc24-4c88-8fa9-057efef3ad94"
},
"id": "_m0olI-HD9Dc",
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[INFO] loading facial landmark predictor...\n",
"[INFO] starting video stream thread...\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 0\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 1\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 2\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 3\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"BLINKS COUNT: 4\n",
"Traceback (most recent call last):\n",
" File \"/content/wko/blink_detection_lab8.py\", line 136, in <module>\n",
" cv2.destroyAllWindows()\n",
"cv2.error: OpenCV(4.2.0) /io/opencv/modules/highgui/src/window.cpp:645: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows'\n",
"\n"
]
}
]
}
],
"metadata": {
"author": "Andrzej Wójtowicz",
"email": "andre@amu.edu.pl",
"kernelspec": {
"display_name": "widzenie_komputerowe",
"language": "python",
"name": "python3"
},
"lang": "pl",
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 05:35:01) [MSC v.1916 64 bit (AMD64)]"
},
"subtitle": "09. Wykrywanie i rozpoznawanie tekstu [laboratoria]",
"title": "Widzenie komputerowe",
"vscode": {
"interpreter": {
"hash": "6ac7fc53e11b5e853f03d2492fedb08fce658edca143f79fa3d2748d3b63b777"
}
},
"year": "2021",
"colab": {
"provenance": []
}
},
"nbformat": 4,
"nbformat_minor": 5
}