Skip to content

Commit d456369

Browse files
committed
all: removing comments and adding section titles
1 parent 42b5f44 commit d456369

File tree

5 files changed

+87
-97
lines changed

5 files changed

+87
-97
lines changed

calibration.ipynb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,7 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"### 2-0. Set Up "
55-
]
56-
},
57-
{
58-
"cell_type": "markdown",
59-
"metadata": {},
60-
"source": [
61-
"practicing using functions from np and cv"
54+
"### 2-0. practicing using functions from np and cv"
6255
]
6356
},
6457
{
@@ -221,7 +214,7 @@
221214
"source": [
222215
"https://www.tutorialspoint.com/how-to-find-patterns-in-a-chessboard-using-opencv-python\n",
223216
"\n",
224-
"#### 2-1.1. Additional code blocks for testing since the errors have occurred while executing 2-1"
217+
"### 2-1.1. Additional code blocks for testing since the errors have occurred while executing 2-1"
225218
]
226219
},
227220
{
@@ -458,7 +451,7 @@
458451
"cell_type": "markdown",
459452
"metadata": {},
460453
"source": [
461-
"## 3. calibration "
454+
"## 3. Calibration "
462455
]
463456
},
464457
{
@@ -538,7 +531,7 @@
538531
"cell_type": "markdown",
539532
"metadata": {},
540533
"source": [
541-
"## 4. Correcting Undistortion"
534+
"## 4. Correcting distortion"
542535
]
543536
},
544537
{

calibration.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
W = 23
88
L = 31
99

10-
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
1110
objp = np.zeros((W*L, 3), np.float32)
1211
objp[:,:2] = np.mgrid[0:L,0:W].T.reshape(-1,2)
1312

14-
# Arrays to store object points and image points from all the images.
15-
objpoints = [] # 3d point in real world space
16-
imgpoints = [] # 2d points in image plane.
13+
objpoints = []
14+
imgpoints = []
1715

1816
imgname = 'camera_calib5.jpg'
1917
imgpath = f'images/{imgname}'

calibration_with_mjpeg.ipynb

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,69 +14,6 @@
1414
"- fps: 30fps\n"
1515
]
1616
},
17-
{
18-
"cell_type": "code",
19-
"execution_count": 1,
20-
"metadata": {},
21-
"outputs": [
22-
{
23-
"name": "stdout",
24-
"output_type": "stream",
25-
"text": [
26-
"True\n",
27-
"0.2789343940438358 [[459.49627036 0. 462.98078721]\n",
28-
" [ 0. 425.9391768 332.55095914]\n",
29-
" [ 0. 0. 1. ]] [[-0.13575777 0.0247265 0.00342986 0.00018729 -0.00074961]] (array([[-0.0740356 ],\n",
30-
" [ 0.00389051],\n",
31-
" [ 0.07810778]]),) (array([[-12.03832935],\n",
32-
" [-13.96143027],\n",
33-
" [ 20.05135273]]),)\n"
34-
]
35-
}
36-
],
37-
"source": [
38-
"import cv2 as cv\n",
39-
"import numpy as np\n",
40-
"\n",
41-
"criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001)\n",
42-
"\n",
43-
"W=23\n",
44-
"L=31\n",
45-
"\n",
46-
"# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)\n",
47-
"objp = np.zeros((W*L, 3), np.float32)\n",
48-
"objp[:,:2] = np.mgrid[0:L,0:W].T.reshape(-1,2)\n",
49-
"\n",
50-
"# Arrays to store object points and image points from all the images.\n",
51-
"objpoints = [] # 3d point in real world space\n",
52-
"imgpoints = [] # 2d points in image plane.\n",
53-
"\n",
54-
"# imgpath = 'images/sample.jpg'\n",
55-
"imgpath = 'images/camera_calib5.jpg'\n",
56-
"img = cv.imread(imgpath)\n",
57-
"\n",
58-
"grayscaledimg = cv.cvtColor(img, cv.COLOR_BGR2GRAY)\n",
59-
"cv.imshow(imgpath, grayscaledimg)\n",
60-
"cv.waitKey(0)\n",
61-
"ret, corners = cv.findChessboardCorners(grayscaledimg, (L,W), None)\n",
62-
"print(ret)\n",
63-
"\n",
64-
"if ret == True:\n",
65-
" objpoints.append(objp)\n",
66-
"\n",
67-
" corners2 = cv.cornerSubPix(grayscaledimg,corners, (11, 11), (-1, -1), criteria)\n",
68-
" imgpoints.append(corners2)\n",
69-
"\n",
70-
" # Draw and display the corners\n",
71-
" cv.drawChessboardCorners(img, (L, W), corners2, ret)\n",
72-
" window_name = imgpath + ' outputimg'\n",
73-
" cv.imshow(window_name, img)\n",
74-
" cv.waitKey(0)\n",
75-
"\n",
76-
" ret, mtx, dist, rvecs, tvecs = cv.calibrateCamera(objpoints, imgpoints, grayscaledimg.shape[::-1], None, None)\n",
77-
" print(ret, mtx, dist, rvecs, tvecs)"
78-
]
79-
},
8017
{
8118
"cell_type": "markdown",
8219
"metadata": {},

video_recording.ipynb

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"### Checking cv video registry and VideoCapture methods"
8+
]
9+
},
310
{
411
"cell_type": "code",
5-
"execution_count": 3,
12+
"execution_count": null,
613
"metadata": {},
714
"outputs": [
815
{
@@ -32,9 +39,14 @@
3239
"print(availableBackends)\n",
3340
"\n",
3441
"cap = cv.VideoCapture(1)\n",
35-
"print(cap.get(5), cap.get(6))\n",
36-
"\n",
37-
"\n"
42+
"print(cap.get(5), cap.get(6))"
43+
]
44+
},
45+
{
46+
"cell_type": "markdown",
47+
"metadata": {},
48+
"source": [
49+
"### Video Recording with preview "
3850
]
3951
},
4052
{
@@ -95,6 +107,13 @@
95107
"https://docs.opencv.org/4.x/dd/d43/tutorial_py_video_display.html"
96108
]
97109
},
110+
{
111+
"cell_type": "markdown",
112+
"metadata": {},
113+
"source": [
114+
"### Setting fps, width and height of the video"
115+
]
116+
},
98117
{
99118
"cell_type": "code",
100119
"execution_count": 57,
@@ -148,6 +167,13 @@
148167
"cv.destroyAllWindows()"
149168
]
150169
},
170+
{
171+
"cell_type": "markdown",
172+
"metadata": {},
173+
"source": [
174+
"#### Testing output path format"
175+
]
176+
},
151177
{
152178
"cell_type": "code",
153179
"execution_count": 26,
@@ -174,6 +200,13 @@
174200
"print(\"OUTPUT PATH: \", outputpath)"
175201
]
176202
},
203+
{
204+
"cell_type": "markdown",
205+
"metadata": {},
206+
"source": [
207+
"#### Testing assert statement"
208+
]
209+
},
177210
{
178211
"cell_type": "code",
179212
"execution_count": 32,
@@ -195,7 +228,7 @@
195228
"cell_type": "markdown",
196229
"metadata": {},
197230
"source": [
198-
"## FINAL"
231+
"## ~~FINAL~~"
199232
]
200233
},
201234
{
@@ -349,6 +382,13 @@
349382
"```"
350383
]
351384
},
385+
{
386+
"cell_type": "markdown",
387+
"metadata": {},
388+
"source": [
389+
"#### modifying sys list test"
390+
]
391+
},
352392
{
353393
"cell_type": "code",
354394
"execution_count": 13,
@@ -385,6 +425,13 @@
385425
"print(sys.path)\n"
386426
]
387427
},
428+
{
429+
"cell_type": "markdown",
430+
"metadata": {},
431+
"source": [
432+
"#### importing cv test"
433+
]
434+
},
388435
{
389436
"cell_type": "code",
390437
"execution_count": 14,
@@ -406,6 +453,13 @@
406453
"print(cv.__file__)"
407454
]
408455
},
456+
{
457+
"cell_type": "markdown",
458+
"metadata": {},
459+
"source": [
460+
"#### setting gst plugin test"
461+
]
462+
},
409463
{
410464
"cell_type": "code",
411465
"execution_count": 7,
@@ -434,6 +488,13 @@
434488
"# export cameraDebug=0\n"
435489
]
436490
},
491+
{
492+
"cell_type": "markdown",
493+
"metadata": {},
494+
"source": [
495+
"#### setting cameraDebug variable test"
496+
]
497+
},
437498
{
438499
"cell_type": "code",
439500
"execution_count": 8,
@@ -454,6 +515,13 @@
454515
"print(os.environ['cameraDebug'])"
455516
]
456517
},
518+
{
519+
"cell_type": "markdown",
520+
"metadata": {},
521+
"source": [
522+
"### Camera Recording using Gstreamer"
523+
]
524+
},
457525
{
458526
"cell_type": "code",
459527
"execution_count": 2,
@@ -537,6 +605,13 @@
537605
" break"
538606
]
539607
},
608+
{
609+
"cell_type": "markdown",
610+
"metadata": {},
611+
"source": [
612+
"### + Fixing errors"
613+
]
614+
},
540615
{
541616
"cell_type": "code",
542617
"execution_count": 1,

video_recording.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,14 @@
1414
camera_name = sys.argv[1]
1515

1616
gstreamer_str = f"icamerasrc device-name=isx031-{camera_name} ! video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1 ! videoconvert ! appsink"
17-
# ximagesource"
18-
# ximagesink: video frame into XWindow local/remote display
19-
# # gst-launch-1.0: build and run GStreamer pipeline.
20-
# icamerasrc: option for source file and in this case, it's for icamera, use 'icamersrc'
21-
# video/x-raw: unstructured and uncompressed raw video data. else: x-ffv, x-h263, x-huffyuv .... etc.
22-
# # print-fps : ** couldn't find that where the value is printed. -> deleted
23-
# video convert : one of GstVideo Convert Scale (video convert, video convert scale, video scale)
24-
25-
# cap = cv.VideoCapture(1) -> [ WARN:[email protected]] global cap_v4l.cpp:913 open VIDEOIO(V4L2:/dev/video1): can't open camera by index
26-
cap = cv.VideoCapture(gstreamer_str, cv.CAP_GSTREAMER)
2717

18+
cap = cv.VideoCapture(gstreamer_str, cv.CAP_GSTREAMER)
2819

29-
# cap.set(5, 30.0) # FPS
30-
# cap.set(3, 1920) # WIDTH
31-
# cap.set(4, 1080) # HEIGHT
3220
print("FPS: ", cap.get(5))
3321
print(cap.isOpened())
3422
# https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=get#cv2.VideoCapture.get
3523
# https://www.geeksforgeeks.org/python-assert-keyword/
3624

37-
# Define the codec and create VideoWriter object
3825
fourcc = cv.VideoWriter_fourcc(*'mp4v')
3926

4027
now = datetime.now()

0 commit comments

Comments
 (0)