Skip to content

Commit d8e1947

Browse files
committed
run_calibrate_camera: add an option '--no_gst' to disable gstreamer
If specified '--no_gst', then the camera device just be used by opencv without any gstreamer components. Signed-off-by: JoshWu <[email protected]>
1 parent 31413c4 commit d8e1947

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

run_calibrate_camera.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def main():
5050
parser.add_argument("-flip", "--flip", default=0, type=int,
5151
help="flip method of the camera")
5252

53+
parser.add_argument("--no_gst", action="store_true",
54+
help="set true if not use gstreamer for the camera capture")
55+
5356
args = parser.parse_args()
5457

5558
if not os.path.exists(TARGET_DIR):
@@ -70,7 +73,9 @@ def main():
7073

7174
device = args.input
7275
cap_thread = CaptureThread(device_id=device,
73-
flip_method=args.flip)
76+
flip_method=args.flip,
77+
use_gst=not args.no_gst,
78+
)
7479
buffer_manager = MultiBufferManager()
7580
buffer_manager.bind_thread(cap_thread, buffer_size=8)
7681
if cap_thread.connect_camera():

surround_view/capture_thread.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def __init__(self,
1414
drop_if_full=True,
1515
api_preference=cv2.CAP_GSTREAMER,
1616
resolution=None,
17+
use_gst=True,
1718
parent=None):
1819
"""
1920
device_id: device number of the camera.
@@ -26,6 +27,7 @@ def __init__(self,
2627
super(CaptureThread, self).__init__(parent)
2728
self.device_id = device_id
2829
self.flip_method = flip_method
30+
self.use_gst = use_gst
2931
self.drop_if_full = drop_if_full
3032
self.api_preference = api_preference
3133
self.resolution = resolution
@@ -71,8 +73,11 @@ def run(self):
7173
qDebug("Stopping capture thread...")
7274

7375
def connect_camera(self):
74-
options = gstreamer_pipeline(cam_id=self.device_id, flip_method=self.flip_method)
75-
self.cap.open(options, self.api_preference)
76+
if self.use_gst:
77+
options = gstreamer_pipeline(cam_id=self.device_id, flip_method=self.flip_method)
78+
self.cap.open(options, self.api_preference)
79+
else:
80+
self.cap.open(self.device_id)
7681
# return false if failed to open camera
7782
if not self.cap.isOpened():
7883
qDebug("Cannot open camera {}".format(self.device_id))

0 commit comments

Comments
 (0)