Go to Post Chuck Norris can be the human player and throw a Poof ball into the 3 point goal and it counts. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-08-2016, 22:03
Technologyman00's Avatar
Technologyman00 Technologyman00 is offline
Registered User
AKA: Collin
FRC #1792 (Round Table Robotics)
Team Role: Mechanical
 
Join Date: Nov 2015
Rookie Year: 2015
Location: Oak Creek WI
Posts: 23
Technologyman00 is an unknown quantity at this point
Simulate a Webcam with Pictures (Or IP Camera)

Does anyone know of an easy way or some free software that you can run on the RPI (Raspberry Pi) to simulate a webcam or make a IP camera with sets of pictures that are in a folder?
Reply With Quote
  #2   Spotlight this post!  
Unread 09-08-2016, 03:28
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 52
calcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nice
Re: Simulate a Webcam with Pictures (Or IP Camera)

You could use gstreamer to do that. The following script will run an MJPEG server on localhost port 8080 using JPEG images from the current directory that match the name pattern. They will be served in a loop until the server is killed.

Code:
#!/bin/bash
gst-launch-1.0 multifilesrc location="img.%04d.jpg" index=0 \
    caps="image/jpeg,framerate=\(fraction\)12/1" loop=true ! jpegdec ! \
    videoconvert ! videorate ! jpegenc ! queue ! multipartmux ! \
    tcpserversink host=127.0.0.1 port=8080
%04d represents an integer padded on the left with zeroes to four digits. I used the following script to rename all .jpg files in the current directory to the form the gstreamer command accepts.

Code:
#!/bin/bash
count=0
for file in *.jpg; do
  new=$(printf "img.%04d.jpg" "$count")
  mv -- "$file" "$new"
  let count=count+1
done
Reply With Quote
  #3   Spotlight this post!  
Unread 09-08-2016, 06:39
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Simulate a Webcam with Pictures (Or IP Camera)

The key thing to remember about webcams is they just send a series of still JPG images with some header information. It's nothing more complex than that. It wouldn't take much to write your own streaming service.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-08-2016, 10:30
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,381
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Simulate a Webcam with Pictures (Or IP Camera)

It will depend on what you are using to open those images for processing on the Pi.
If you use OpenCV, it is as simple as using one command line to open an image vs another to grab a frame from a video stream.
I'm certain most other image processing code works almost identically.

For example, to grab a video frame, you could do this:
Code:
camera = cv2.VideoCapture(0)
# Later followed by this to grab the frame
(grabbed, frame) = camera.read()
To open a image file instead:
Code:
frame = cv2.imread(PathToImageFile)
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
Reply With Quote
  #5   Spotlight this post!  
Unread 09-08-2016, 13:23
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,086
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Simulate a Webcam with Pictures (Or IP Camera)

mjpg-streamer can send a stream from a directory of jpeg files.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:56.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi