microwerx

test-cv2

Aug 4th, 2020 (edited)
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. {
  2. "nbformat": 4,
  3. "nbformat_minor": 0,
  4. "metadata": {
  5. "kernelspec": {
  6. "display_name": "Python 3",
  7. "language": "python",
  8. "name": "python3"
  9. },
  10. "language_info": {
  11. "codemirror_mode": {
  12. "name": "ipython",
  13. "version": 3
  14. },
  15. "file_extension": ".py",
  16. "mimetype": "text/x-python",
  17. "name": "python",
  18. "nbconvert_exporter": "python",
  19. "pygments_lexer": "ipython3",
  20. "version": "3.7.1"
  21. },
  22. "colab": {
  23. "name": "test-cv2.ipynb",
  24. "provenance": [],
  25. "collapsed_sections": []
  26. }
  27. },
  28. "cells": [
  29. {
  30. "cell_type": "markdown",
  31. "metadata": {
  32. "id": "jrUU752v4Vo5",
  33. "colab_type": "text"
  34. },
  35. "source": [
  36. "# OpenCV Image Capture\n",
  37. "\n",
  38. "This sample code uses OpenCV to capture one frame from the first camera"
  39. ]
  40. },
  41. {
  42. "cell_type": "code",
  43. "metadata": {
  44. "id": "I_NsFsKO4Vo6",
  45. "colab_type": "code",
  46. "colab": {}
  47. },
  48. "source": [
  49. "import numpy as np\n",
  50. "import matplotlib.pyplot as plt\n",
  51. "import cv2"
  52. ],
  53. "execution_count": null,
  54. "outputs": []
  55. },
  56. {
  57. "cell_type": "code",
  58. "metadata": {
  59. "id": "eg4uv7844Vo8",
  60. "colab_type": "code",
  61. "colab": {}
  62. },
  63. "source": [
  64. "def cv2_imshow(image):\n",
  65. " plt.axis(\"off\")\n",
  66. " plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))\n",
  67. " plt.show()"
  68. ],
  69. "execution_count": null,
  70. "outputs": []
  71. },
  72. {
  73. "cell_type": "code",
  74. "metadata": {
  75. "id": "PMGsmDRP4Vo_",
  76. "colab_type": "code",
  77. "colab": {}
  78. },
  79. "source": [
  80. "vid = cv2.VideoCapture(0) \n",
  81. "ret, frame = vid.read()\n",
  82. "vid.release()\n",
  83. "\n",
  84. "cv2_imshow(frame)"
  85. ],
  86. "execution_count": null,
  87. "outputs": []
  88. },
  89. {
  90. "cell_type": "code",
  91. "metadata": {
  92. "id": "g1S5LeOZ4VpD",
  93. "colab_type": "code",
  94. "colab": {}
  95. },
  96. "source": [
  97. ""
  98. ],
  99. "execution_count": null,
  100. "outputs": []
  101. }
  102. ]
  103. }
Add Comment
Please, Sign In to add comment