Untitled.ipynb
3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{
"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
}