commit
4f2f793b60
|
@ -18,7 +18,7 @@ import argparse
|
||||||
|
|
||||||
|
|
||||||
# Capture images
|
# Capture images
|
||||||
def capture(buf, z1, t1, z2, t2, device, nx, ny, nz, tend):
|
def capture(buf, z1, t1, z2, t2, device, nx, ny, nz, tend, live):
|
||||||
# Array flag
|
# Array flag
|
||||||
first = True
|
first = True
|
||||||
|
|
||||||
|
@ -41,6 +41,11 @@ def capture(buf, z1, t1, z2, t2, device, nx, ny, nz, tend):
|
||||||
# Store buffer
|
# Store buffer
|
||||||
z = gray
|
z = gray
|
||||||
|
|
||||||
|
# Display Frame
|
||||||
|
if live is True:
|
||||||
|
cv2.imshow("Capture", gray)
|
||||||
|
cv2.waitKey(1)
|
||||||
|
|
||||||
# Store results
|
# Store results
|
||||||
if first:
|
if first:
|
||||||
z1[i] = z
|
z1[i] = z
|
||||||
|
@ -153,12 +158,14 @@ if __name__ == '__main__':
|
||||||
# Read commandline options
|
# Read commandline options
|
||||||
conf_parser = argparse.ArgumentParser(description='Capture and compress' +
|
conf_parser = argparse.ArgumentParser(description='Capture and compress' +
|
||||||
' live video frames.')
|
' live video frames.')
|
||||||
conf_parser.add_argument("-c", "--conf_file",
|
conf_parser.add_argument('-c', '--conf_file',
|
||||||
help="Specify configuration file. If no file" +
|
help="Specify configuration file. If no file" +
|
||||||
" is specified 'configuration.ini' is used.",
|
" is specified 'configuration.ini' is used.",
|
||||||
metavar="FILE")
|
metavar="FILE")
|
||||||
conf_parser.add_argument('--test', action='store_true',
|
conf_parser.add_argument('-t', '--test', action='store_true',
|
||||||
help='Testing mode - Start capturing immediately')
|
help='Testing mode - Start capturing immediately')
|
||||||
|
conf_parser.add_argument('-l', '--live', action='store_true',
|
||||||
|
help='Display live image while capturing')
|
||||||
|
|
||||||
args = conf_parser.parse_args()
|
args = conf_parser.parse_args()
|
||||||
|
|
||||||
|
@ -175,6 +182,12 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
testing = False
|
testing = False
|
||||||
|
|
||||||
|
# Live mode
|
||||||
|
if args.live:
|
||||||
|
live = True
|
||||||
|
else:
|
||||||
|
live = False
|
||||||
|
|
||||||
# Get device id
|
# Get device id
|
||||||
devid = cfg.getint('Camera', 'device_id')
|
devid = cfg.getint('Camera', 'device_id')
|
||||||
|
|
||||||
|
@ -256,7 +269,7 @@ if __name__ == '__main__':
|
||||||
# Set processes
|
# Set processes
|
||||||
pcapture = multiprocessing.Process(target=capture,
|
pcapture = multiprocessing.Process(target=capture,
|
||||||
args=(buf, z1, t1, z2, t2, device,
|
args=(buf, z1, t1, z2, t2, device,
|
||||||
nx, ny, nz, tend.unix))
|
nx, ny, nz, tend.unix, live))
|
||||||
pcompress = multiprocessing.Process(target=compress,
|
pcompress = multiprocessing.Process(target=compress,
|
||||||
args=(buf, z1, t1, z2, t2, nx, ny,
|
args=(buf, z1, t1, z2, t2, nx, ny,
|
||||||
nz, tend.unix, path))
|
nz, tend.unix, path))
|
||||||
|
@ -274,4 +287,6 @@ if __name__ == '__main__':
|
||||||
pcompress.terminate()
|
pcompress.terminate()
|
||||||
|
|
||||||
# Release device
|
# Release device
|
||||||
|
if live is True:
|
||||||
|
cv2.destroyAllWindows()
|
||||||
device.release()
|
device.release()
|
||||||
|
|
Loading…
Reference in New Issue