microwerx icon

test-cv2

microwerx | PRO | 08/04/20 07:51:41 PM UTC (Edited) | 0 ⭐ | 851 👁️ | Never ⏰ | []
text |

2.27 KB

|

None

|

0 👍

/

0 👎

{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "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.1"
    },
    "colab": {
      "name": "test-cv2.ipynb",
      "provenance": [],
      "collapsed_sections": []
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "jrUU752v4Vo5",
        "colab_type": "text"
      },
      "source": [
        "# OpenCV Image Capture\n",
        "\n",
        "This sample code uses OpenCV to capture one frame from the first camera"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "I_NsFsKO4Vo6",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import cv2"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "eg4uv7844Vo8",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "def cv2_imshow(image):\n",
        "    plt.axis(\"off\")\n",
        "    plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))\n",
        "    plt.show()"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "PMGsmDRP4Vo_",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "vid = cv2.VideoCapture(0) \n",
        "ret, frame = vid.read()\n",
        "vid.release()\n",
        "\n",
        "cv2_imshow(frame)"
      ],
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "g1S5LeOZ4VpD",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        ""
      ],
      "execution_count": null,
      "outputs": []
    }
  ]
}

Comments