Biking is a enjoyable solution to keep match, take pleasure in nature, and join with pals and acquaintances. Nonetheless, using is changing into more and more harmful, particularly in conditions the place cyclists and vehicles share the highway. In response to the NHTSA, in the USA a mean of 883 individuals on bicycles are killed in visitors crashes, with a mean of about 45,000 injury-only crashes reported yearly. Whereas whole bicycle fatalities solely account for simply over 2% of all visitors fatalities in the USA, as a bicycle owner, it’s nonetheless terrifying to be pushed off the highway by a big SUV or truck. To raised shield themselves, many cyclists are beginning to journey with cameras mounted to the entrance or again of their bicycle. On this weblog publish, I’ll display a machine studying resolution that cyclists can use to raised establish shut calls.
Many US states and international locations all through the world have some kind of 3-feet legislation. A 3-feet legislation requires motor automobiles to supply about 3 ft (1 meter) of distance when passing a bicycle. To advertise security on the highway, cyclists are more and more recording their rides, and in the event that they encounter a harmful scenario the place they aren’t given an applicable protected distance, they’ll present a video of the encounter to native legislation enforcement to assist right conduct. Nonetheless, discovering a single encounter in a recording of a multi-hour journey is time consuming and infrequently requires specialised video abilities to generate a brief clip of the encounter.
To unravel a few of these issues, I’ve developed a easy resolution utilizing Amazon Rekognition video evaluation. Amazon Rekognition can detect labels (primarily objects) and the timestamp of when that object is detected in a video. Amazon Rekognition can be utilized to rapidly discover any automobiles that seem within the video of a recorded journey.
If a bicycle owner’s digicam data a passing automobile, it should then decide if the automobile is simply too near the bicycle—in different phrases, if the automobile is throughout the 3-foot vary set by legislation. Whether it is, then I wish to generate a clip of the encounter, which might be offered to the related authorities. The next determine reveals the view from a bicycle owner’s digicam with bounding containers that establish a automobile that’s passing too near the bicycle. A field on the backside of the picture reveals the approximate 3-foot space across the bicycle.
Answer overview
The structure of the answer is proven within the following determine.
The steps of the answer are:
- When a bicycle owner completes a journey, they add their MP4 movies from the journey into an Amazon Easy Storage Service (Amazon S3)
- The bucket has been configured with an S3 occasion notification that sends object created notifications to an AWS Lambda
- The Lambda perform kicks off an AWS Step Capabilities workflow that begins by calling the StartLabelDetection API as a part of Amazon Rekognition movies. The
StartLabelDetection
API is configured to detectBus
,Automotive
,Fireplace Truck
,Pickup Truck
,Truck
,Limo
, andTransferring Van
as labels. It ignores different associated non-vehicle labels likeLicense Plate
,Wheel
,Tire
, andAutomotive Mirror
. - The Amazon Rekognition API returns a set of JSON figuring out the chosen labels and timestamps of detected objects.
- This JSON result’s despatched to a Lambda perform to carry out the geometry math to find out if a automobile field overlapped with the bicycle protected space.
- Any detected encounters are generated and handed off to AWS Elemental MediaConvert, which may create snippets of video akin to the detected encounters, utilizing the
CreateJob
API - MediaConvert creates these movies and uploads them to an S3 bucket.
- One other Lambda perform is known as to generate pre-signed URLs of the movies. This enables the movies to be briefly downloaded by anybody with the pre-signed URL.
- Amazon Easy Notification Service (Amazon SNS) sends an e-mail message with hyperlinks to the pre-signed URLs.
Stipulations
To make use of the answer outlined on this publish, it’s essential to have:
- An AWS account with applicable permissions to permit you to deploy AWS CloudFormation stacks
- A video recording in MP4 format with the .MP4 extension utilizing the H.264 codec. The video must be from a entrance or rear-facing digicam, from any off-the-shelf vendor (for instance GoPro, DJI, or Cycliq). The utmost file dimension is 10 GB.
Deploying the answer
- Deploy this resolution in your surroundings or choose Launch Stack. This resolution will deploy within the AWS US East (N. Virginia) us-east-1 AWS Area.
- The Create stack web page from the CloudFormation dashboard seems. On the backside of the web page, select Subsequent.
- On the Specify stack particulars web page, enter the e-mail tackle the place you’d prefer to obtain notifications. Select Subsequent.
- Choose the field that claims I acknowledge that AWS CloudFormation would possibly create IAM sources and Select Subsequent. Select Submit and the set up will start. The answer takes about 5 minutes to be put in.
- You’ll obtain an e-mail confirming your Amazon SNS subscription. You’ll not obtain emails from the answer until you affirm your subscription.
- After the stack completes, choose the Outputs tab and be aware of the bucket identify listed beneath InputBucket.
Utilizing the answer
To check the answer, I’ve a pattern video the place I requested a stunt driver to drive very carefully to me.
To start the video processing, I add the video to the S3 bucket (the InputBucket from the Outputs tab). The bucket has encryption enabled, so beneath Properties, I select Specify an encryption key and choose Use bucket settings for default encryption. Selecting Add begins the add course of, as proven within the following determine.
After a second, the step perform begins processing. After a couple of minutes, you’ll obtain an e-mail with hyperlinks to any encounters recognized, as proven within the following determine.
In my case, it recognized two encounters. Within the first encounter recognized, I rode too near a parked automotive. Nonetheless, within the second encounter recognized, it reveals a harmful encounter that I skilled with my stunt driver.
Had this been an precise harmful encounter, the video clip may very well be offered to the suitable authorities to assist change conduct and make the highway safer for everybody.
Pricing
As a result of this can be a absolutely serverless resolution, you solely pay for what you utilize. With Amazon Rekognition, you pay for the minutes of video which can be processed. With MediaConvert, you pay for normalized minutes of video processed, which is every minute of video output with multipliers that apply primarily based on options used. The answer’s use of Lambda, Step Capabilities, and SNS are minimal and can possible fall beneath the free tier for many customers.
Clear up
To delete the sources created as a part of this resolution, go to the CloudFormation console, choose the stack that was deployed, and select Delete.
Conclusion
On this instance I demonstrated learn how to use Amazon Rekognition video evaluation in a singular state of affairs. Amazon Rekognition is a robust laptop imaginative and prescient instrument that lets you get insights out of photos or video with out the overhead of constructing or managing a machine studying mannequin. After all, Amazon Rekognition may deal with extra superior use instances than the one I demonstrated right here.
On this instance I demonstrated how utilizing Amazon Rekognition with different serverless providers can yield a serverless video processing workflow that—on this case—may also help enhance the security of cyclists. Whilst you won’t be an avid bicycle owner, the answer demonstrated right here might be prolonged to a wide range of use instances and industries. For instance, this resolution may very well be prolonged to detect wildlife on nature cameras or you may use Amazon Rekognition streaming video occasions to detect individuals and packages in safety video.
Get began as we speak by utilizing Amazon Rekognition in your laptop imaginative and prescient use case.
In regards to the Creator
Mike George is a Principal Options Architect at Amazon Net Providers (AWS) primarily based in Salt Lake Metropolis, Utah. He enjoys serving to clients remedy their expertise issues. His pursuits embrace software program engineering, safety, synthetic intelligence (AI), and machine studying (ML).