Untitled.ipynb 3.63 KB
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Client socket initialized\n",
      "images.jpg\n",
      "yes\n",
      "Sending...\n",
      "Sending...\n",
      "Sending...\n",
      "Sending...\n",
      "Sending...\n",
      "Sending...\n",
      "Sending...\n",
      "Sending...\n"
     ]
    }
   ],
   "source": [
    "import socket\n",
    "import sys \n",
    "import time \n",
    "\n",
    "buf = 1024\n",
    "address = ('192.168.50.1', 8080)\n",
    "\n",
    "try:\n",
    "    socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n",
    "    print('Client socket initialized')\n",
    "    file_name = input()\n",
    "    socket.sendto(file_name.encode(), address)\n",
    "    \n",
    "    f = open('./frames/{}'.format(file_name), 'rb')\n",
    "    if(f):\n",
    "        print(\"yes\")\n",
    "    data = f.read(buf)\n",
    "    while(data):\n",
    "        if(socket.sendto(data, address)):\n",
    "            print(\"Sending...\")\n",
    "            data = f.read(buf)\n",
    "except:\n",
    "    print(\"Failed to create socket\")\n",
    "    sys.exit()\n",
    "\n",
    "\n",
    "\n",
    "# while True:\n",
    "#     file_name = open('./frames/1.jpg', \"rb\")\n",
    "#     data = file_name.read(buf)\n",
    "#     if(socket.sendto(data, address)):\n",
    "#         print(\"Sending...\")\n",
    "#     else:\n",
    "#         print(\"fail\")\n",
    "#     file_name.close()\n",
    "\n",
    "# socket.close()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[[ 35  61  21]\n",
      "  [ 34  61  18]\n",
      "  [ 36  61  17]\n",
      "  ...\n",
      "  [  8  13  12]\n",
      "  [  7  11  12]\n",
      "  [  6  10  11]]\n",
      "\n",
      " [[ 69  96  53]\n",
      "  [ 68  95  51]\n",
      "  [ 68  96  50]\n",
      "  ...\n",
      "  [ 13  18  17]\n",
      "  [ 18  22  23]\n",
      "  [ 21  25  26]]\n",
      "\n",
      " [[ 68  97  51]\n",
      "  [ 68  98  49]\n",
      "  [ 67  98  47]\n",
      "  ...\n",
      "  [  8  10  10]\n",
      "  [ 16  18  19]\n",
      "  [ 22  24  25]]\n",
      "\n",
      " ...\n",
      "\n",
      " [[115 165 223]\n",
      "  [114 164 222]\n",
      "  [112 162 220]\n",
      "  ...\n",
      "  [255 255 255]\n",
      "  [255 255 255]\n",
      "  [255 255 255]]\n",
      "\n",
      " [[114 162 220]\n",
      "  [113 161 219]\n",
      "  [109 159 217]\n",
      "  ...\n",
      "  [255 255 255]\n",
      "  [255 255 255]\n",
      "  [255 255 255]]\n",
      "\n",
      " [[113 161 219]\n",
      "  [112 160 218]\n",
      "  [108 158 216]\n",
      "  ...\n",
      "  [255 255 255]\n",
      "  [255 255 255]\n",
      "  [255 255 255]]]\n"
     ]
    }
   ],
   "source": [
    "import cv2\n",
    "\n",
    "path = 'frames/images.jpg'\n",
    "img = cv2.imread(path)\n",
    "print(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}