Skip to content

Commit

Permalink
add set camera input resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybreckon committed Jan 20, 2025
1 parent 74f8db6 commit 2b40a65
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 17 additions & 1 deletion harris.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Author : Toby Breckon, [email protected]

# Copyright (c) 2015 School of Engineering & Computing Science,
# Copyright (c) 2015-2024 Engineering & Computing Science,
# Durham University, UK
# License : LGPL - http://www.gnu.org/licenses/lgpl.html

Expand Down Expand Up @@ -39,6 +39,12 @@
type=float,
help="rescale image by this factor",
default=1.0)
parser.add_argument(
"-s",
"--set_resolution",
type=int,
nargs=2,
help='override default camera resolution as H W')
parser.add_argument(
'video_file',
metavar='video_file',
Expand Down Expand Up @@ -100,6 +106,16 @@ def nothing(x):
15,
nothing)

# override default camera resolution

if (args.set_resolution is not None):
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, args.set_resolution[1])
cap.set(cv2.CAP_PROP_FRAME_WIDTH, args.set_resolution[0])

print("INFO: input resolution : (",
int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), "x",
int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)), ")")

while (keep_processing):

# if video file successfully open then read frame from video
Expand Down
18 changes: 17 additions & 1 deletion sift_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Author : Toby Breckon, [email protected]

# Copyright (c) 2016-2021 Toby Breckon
# Copyright (c) 2016-2024 Toby Breckon
# Computer Science, Durham University, UK
# License : LGPL - http://www.gnu.org/licenses/lgpl.html

Expand Down Expand Up @@ -63,6 +63,12 @@ def extraOpenCVModulesPresent():
type=float,
help="rescale image by this factor",
default=1.0)
parser.add_argument(
"-s",
"--set_resolution",
type=int,
nargs=2,
help='override default camera resolution as H W')
parser.add_argument(
'video_file',
metavar='video_file',
Expand Down Expand Up @@ -212,6 +218,16 @@ def on_mouse(event, x, y, flags, params):
else:
matcher = cv2.BFMatcher()

# override default camera resolution

if (args.set_resolution is not None):
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, args.set_resolution[1])
cap.set(cv2.CAP_PROP_FRAME_WIDTH, args.set_resolution[0])

print("INFO: input resolution : (",
int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), "x",
int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)), ")")

while (keep_processing):

# if video file successfully open then read frame from video
Expand Down

0 comments on commit 2b40a65

Please sign in to comment.