from common.streamer import TCPStreamer
from imutils.video import VideoStream
from common.logger import Logger
import asyncio
import time

# We could also use 127.0.0.1 or localhost' but in my experience, on Debian it
# works most of the times better by putting 0.0.0.0 (all loopback addresses)
ADDRESS = "0.0.0.0"
PORT = 5000

logger = Logger("streamer")

# The new logger logs all of the "registered" functions. In this case a simple
# line stating the frame number and the number of objects detected
logger.register(lambda bsent, **kw: str(bsent), logfile="bw.log")

# async def log(interval):
# 	while True:
# 		try:
# 			data = {"bsent": streamer.bytes_sent}
# 			logger.write_log(data)
# 			streamer.bytes_sent = 0
# 			await asyncio.sleep(interval)
# 		except asyncio.CancelledError:
# 			# break
# 			raise

videostream = VideoStream(usePiCamera=True, name="CameraThread").start()
time.sleep(0.1)
Example #2
0
parser.add_argument("--fps", help="Emulated FPS of video", type=float, default=20)
args = parser.parse_args()

# class LiveVideoSim(VideoReq, HOGDetector):
# 	"""docstring for LiveVideoSim"""
# 	def __init__(self, **kw):
# 		super().__init__(**kw)

# req = FileVideoStream(args.video).start()
req = VideoReq(video=args.video, resize=False)
detector = HOGDetector(scaleFactor=args.scale, winStride=args.winstride)
logger = Logger()

# The new logger logs all of the "registered" functions. In this case a simple
# line stating the frame number and the number of objects detected
logger.register(lambda frame, detected: str(frame) + "," + str(detected))

# videosim = LiveVideoSim(video=args.video, scaleFactor=args.scale, winStride=args.winstride)

run_loop = True
fps = args.fps
shutter_time = 1 / fps
start = datetime.now()
extra_reads = 0
# The loop will add "1" to the counter and we want to start at the 0th frame
frame_ctr = -1

try:
	while run_loop:
		# Dummy reads to simulate lost frames
		for _ in range(extra_reads):
                    default="raspberrypi2")
args = parser.parse_args()

# class LiveVideoSim(VideoReq, HOGDetector):
# 	"""docstring for LiveVideoSim"""
# 	def __init__(self, **kw):
# 		super().__init__(**kw)

# req = FileVideoStream(args.video).start()
req = TCPReq(hostname=args.host)
detector = HOGDetector(scaleFactor=args.scale, winStride=args.winstride)
logger = Logger("experiment1")

# The new logger logs all of the "registered" functions. In this case a simple
# line stating the frame number and the number of objects detected
logger.register(lambda frame, detected, **kw: str(frame) + "," + str(detected))
logger.register(lambda fps, **kw: str(fps))
logger.register(lambda breceived, **kw: str(breceived))
# logger.register(lambda bstreamed: str(bstreamed))
logger.register(logger.log_cpu)

# videosim = LiveVideoSim(video=args.video, scaleFactor=args.scale, winStride=args.winstride)

run_loop = True
fps = args.fps
shutter_time = 1 / fps
start = datetime.now()
extra_reads = 0
# The loop will add "1" to the counter and we want to start at the 0th frame
frame_ctr = -1
width = 300
Example #4
0
args = parser.parse_args()

req = TCPReq(hostname=args.host)

if args.detector == "hog":
    detector = HOGDetector(scaleFactor=args.scale, winStride=args.winstride)
elif args.detector == "cascade":
    detector = CascadeDetector(args.descriptor)

if args.log is not None:
    logger = Logger(args.log)
    # The new logger logs all of the "registered" functions. In this case a simple
    # line stating the frame number and the number of objects detected
    msg = "{0:.2f}, {1}"
    # logger.register(lambda frame, detected, **kw: msg.format(frame, detected), "accuracy.csv")
    logger.register(lambda fps, breceived, **kw: msg.format(fps, breceived),
                    "experiment1_meas.csv")
    # logger.register(lambda bstreamed: str(bstreamed))
    logger.register(logger.log_cpu)

# videosim = LiveVideoSim(video=args.video, scaleFactor=args.scale, winStride=args.winstride)

run_loop = True
fps = args.fps
shutter_time = 1 / fps
start = datetime.now()
extra_reads = 0
# The loop will add "1" to the counter and we want to start at the 0th frame
frame_ctr = -1
width = 300

try: