Skip to content

Commit dfccc6b

Browse files
committed
updated
1 parent 373d57e commit dfccc6b

File tree

4 files changed

+29
-45
lines changed

4 files changed

+29
-45
lines changed

image_proc01.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,14 @@
569569
},
570570
{
571571
"cell_type": "code",
572-
"execution_count": 18,
572+
"execution_count": 20,
573573
"metadata": {},
574574
"outputs": [
575575
{
576576
"name": "stdout",
577577
"output_type": "stream",
578578
"text": [
579-
"hsv -> 104 114 112\n"
579+
"hsv -> 0 0 0\n"
580580
]
581581
}
582582
],

image_proc02.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88
"This is a follow up and advancement of the first tutorial on image processing. \n",
99
"\n",
1010
"#### Disclaimer:\n",
11-
"If by following this second tutorial you feel like:\n",
12-
"\n",
13-
"<img src=\"data/wtf.gif\" width=\"500\">\n",
14-
"\n",
1511
"You can always refer to **the first tutorial** anytime.\n",
1612
"\n",
1713
"But if you have understood all that was described in the first, **congrats on your first research!**\n",
14+
"\n",
1815
"<img src=\"data/research.gif\" width=\"500\">"
1916
]
2017
},
@@ -131,7 +128,7 @@
131128
},
132129
{
133130
"cell_type": "code",
134-
"execution_count": 5,
131+
"execution_count": 6,
135132
"metadata": {},
136133
"outputs": [],
137134
"source": [

image_proc03.ipynb

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"outputs": [],
5858
"source": [
5959
"def euclidean_distance(x,y):\n",
60-
" eud = math.sqrt((x[0]-y[0])**2 + (x[1]-y[1])**2)\n",
61-
" return eud"
60+
" eud = math.sqrt((x[0]-y[0])**2 + (x[1]-y[1])**2)\n",
61+
" return eud"
6262
]
6363
},
6464
{
@@ -122,7 +122,7 @@
122122
},
123123
{
124124
"cell_type": "code",
125-
"execution_count": 7,
125+
"execution_count": 5,
126126
"id": "1441a0e2-c044-4550-9f1f-1fe900bb3b0c",
127127
"metadata": {},
128128
"outputs": [],
@@ -138,7 +138,7 @@
138138
},
139139
{
140140
"cell_type": "code",
141-
"execution_count": 8,
141+
"execution_count": 6,
142142
"id": "b228ba22-f80d-423c-b95b-5d12e1fb316c",
143143
"metadata": {},
144144
"outputs": [
@@ -148,7 +148,7 @@
148148
"82.81924421854173"
149149
]
150150
},
151-
"execution_count": 8,
151+
"execution_count": 6,
152152
"metadata": {},
153153
"output_type": "execute_result"
154154
}
@@ -168,20 +168,26 @@
168168
},
169169
{
170170
"cell_type": "code",
171-
"execution_count": 9,
171+
"execution_count": 7,
172172
"id": "8883e4db-acc0-4d5c-85db-e864757f4b5d",
173173
"metadata": {},
174174
"outputs": [
175175
{
176-
"ename": "AttributeError",
177-
"evalue": "'NoneType' object has no attribute 'shape'",
178-
"output_type": "error",
179-
"traceback": [
180-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
181-
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
182-
"\u001b[0;32m/tmp/ipykernel_271863/4086475475.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mim\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcv2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mimread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'samples/obt.png'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m#im = cv2.resize(im, (600,480))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mheight\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mwidth\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0m_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mim\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mim_cx\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mim_cy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwidth\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mheight\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mim_cx\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mim_cy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
183-
"\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'shape'"
176+
"name": "stdout",
177+
"output_type": "stream",
178+
"text": [
179+
"319 238\n"
184180
]
181+
},
182+
{
183+
"data": {
184+
"text/plain": [
185+
"113"
186+
]
187+
},
188+
"execution_count": 7,
189+
"metadata": {},
190+
"output_type": "execute_result"
185191
}
186192
],
187193
"source": [
@@ -200,7 +206,7 @@
200206
"res = cv2.GaussianBlur(res, (1,1), 0)\n",
201207
"res_gray = cv2.cvtColor(res, cv2.COLOR_BGR2GRAY)\n",
202208
"_, threshold = cv2.threshold(res_gray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)\n",
203-
"_, contours, _ = cv2.findContours(threshold, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\n",
209+
"contours, _ = cv2.findContours(threshold, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\n",
204210
"min_area = 30**2\n",
205211
"for contour in contours:\n",
206212
" area = cv2.contourArea(contour)\n",
@@ -257,33 +263,14 @@
257263
},
258264
{
259265
"cell_type": "code",
260-
"execution_count": 11,
266+
"execution_count": 8,
261267
"id": "ccb6f227-8abb-4975-99dc-1da2ba06e729",
262268
"metadata": {},
263-
"outputs": [
264-
{
265-
"name": "stderr",
266-
"output_type": "stream",
267-
"text": [
268-
"[ WARN:0] global /tmp/pip-req-build-h45n7_hz/opencv/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video0): can't open camera by index\n"
269-
]
270-
},
271-
{
272-
"ename": "AttributeError",
273-
"evalue": "'NoneType' object has no attribute 'shape'",
274-
"output_type": "error",
275-
"traceback": [
276-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
277-
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
278-
"\u001b[0;32m/tmp/ipykernel_271863/154838433.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mwhile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcap\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0misOpened\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 6\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mframe\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcap\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\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;32m----> 7\u001b[0;31m \u001b[0mheight\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mwidth\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0m_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mframe\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0mim_cx\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mim_cy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwidth\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mheight\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
279-
"\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'shape'"
280-
]
281-
}
282-
],
269+
"outputs": [],
283270
"source": [
284271
"cap = cv2.VideoCapture(0)\n",
285-
"cap.set(cv2.CAP_PROP_FRAME_WIDTH, 2000)\n",
286-
"cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 2000)\n",
272+
"# cap.set(cv2.CAP_PROP_FRAME_WIDTH, 2000)\n",
273+
"# cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 2000)\n",
287274
"min_area = 50**2\n",
288275
"while(cap.isOpened):\n",
289276
" _,frame = cap.read()\n",

samples/obt.png

394 KB
Loading

0 commit comments

Comments
 (0)