def object_count(): print("Object Count Started") end_time = datetime.now() + timedelta(seconds=10) Inventory_count_object = cv2.VideoCapture('/dev/v4l/by-path/platform-3f980000.usb-usb-0:1.2:1.0-video-index0') ## Inventory_count_object.set(3, 480) ## Inventory_count_object.set(4, 320) #while datetime.now()< end_time: q=[0,0,0] _, frame = Inventory_count_object.read() hsv_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) # hammer low_yellow = np.array([110, 50, 50]) ##100, 130 high_yellow = np.array([130, 255, 255]) red_mask = cv2.inRange(hsv_frame, low_yellow, high_yellow) _, contours, _ = cv2.findContours(red_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours = sorted(contours, key=lambda x:cv2.contourArea(x), reverse=True) if len(contours)>0: q[0] = 1 else: q[0] = 0 # wrench low_red = np.array([170, 120, 70]) ##100, 130 high_red = np.array([180, 255, 255]) red_mask = cv2.inRange(hsv_frame, low_red, high_red) _, contours, _ = cv2.findContours(red_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours = sorted(contours, key=lambda x:cv2.contourArea(x), reverse=True) if len(contours)>0: q[1] = 1 else: q[1] = 0 low_green = np.array([25, 100, 120]) ##100, 130 high_green = np.array([30, 255, 255]) red_mask = cv2.inRange(hsv_frame, low_green, high_green) _, contours, _ = cv2.findContours(red_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) contours = sorted(contours, key=lambda x:cv2.contourArea(x), reverse=True) if len(contours)>0: q[2] = 1 else: q[2] = 0 print("q ", q) ## cv2.imshow("Frame", frame) ## ## key = cv2.waitKey(1) ## if key == 27: ## break if q[0]==0: print("first one missing") player=OMXPlayer("the_hammer_is_missing_from_the_inventory.mp3") return_value=0 else: print("All tools available") return_value=3 player=OMXPlayer("please_find_the_tools_required_for_the.mp3") return return_value
math.sqrt(abs(audioop.avg(cur_data, 4))) for x in range(num_samples) ] values = sorted(values, reverse=True) r = sum(values[:int(num_samples * 0.2)]) / int(num_samples * 0.2) #print (' Average audio intensity is r', int(r)) time.sleep(.1) stream.close() p.terminate() return r if (__name__ == '__main__'): VIDEO_PATH = "/home/pi/Desktop/rasto.mp4" player = OMXPlayer(VIDEO_PATH, args=['--no-osd', '--loop', '-b']) player.set_aspect_mode('fill') player.set_alpha(0) while (True): r = audio_int() # To measure your mic levels if r > 5000: alpha = alpha + 10 if alpha > 255: alpha = 255 else: alpha = alpha - 10 if alpha < 0: alpha = 0 print(alpha)
#!/usr/bin/env python3 ####################################### ## Video player mark II ####################################### from omxplayer.player import OMXPlayer from pathlib import Path VIDEO_PATH = Path("/opt/vc/src/hello_pi/hello_video/test.h264") player = OMXPlayer(VIDEO_PATH)
def playUrl(self, url): if not self.player: self.player = OMXPlayer(url, args=self.args) else: self.player.load(url)
#!/usr/bin/env python3 from omxplayer.player import OMXPlayer from time import sleep STREAM_URI = 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov' player = OMXPlayer(STREAM_URI) sleep(8) player.quit()
def play_it(file): path = Path(file) player = OMXPlayer(path) #player.set_aspect_mode("stretch") sleep(player.duration())
#./omxplayer -p -o hdmi test.mkv print('Playing movie ' + datas[1]) foundMovie = True logging.info('Playing movie ' + barcode) try: player.quit() except: print("") movie = ("./movies/" + datas[1]) try: #OMXPlayer(movie, args='--pos 0:10:00') #Start position (hh:mm:ss) player = OMXPlayer(movie) except: print("Error while playing movie") #set_position # no available barcode if foundMovie == False: pygame.mixer.music.load('./sounds/sad_trombone.mp3') pygame.mixer.music.play(0) print('Error with barcode') listing.close()
import time import gaugette.gpio import gaugette.rotary_encoder import os from omxplayer.player import OMXPlayer # from pathlib import Path import sys player = OMXPlayer("./output.mov", args=[]) player.set_alpha(150) player.set_rate(0.5) rate = 0.5 print(player.minimum_rate()) print(player.rate()) A_PIN = 1 B_PIN = 16 gpio = gaugette.gpio.GPIO() encoder = gaugette.rotary_encoder.RotaryEncoder(gpio, A_PIN, B_PIN) encoder.start() #FIXME: weird issue where, while only comparing to delta of 1, decrease function somehow manages to decrease speed below 0.25 - possibly a timing issue? try: while True: delta = encoder.get_cycles() if delta != 0: print "rotate %d" % delta print "rate: " + str(rate) if delta >= 5 and rate <= 1: player.action(2) rate = rate + 0.125 else:
def __init__(self, videoPath): self.videoPath = videoPath self.classPlayer = OMXPlayer(self.videoPath) sleep(0.2) self.classPlayer.pause()
def ON(): print("ON") path = Path('../julia4.mp4') omx.player = OMXPlayer(path) return "ON"
return process.communicate()[0] def main(): """ Insert 'python3 <YOUR_PATH>/LivingPortraitFaceDetection.py &' to /etc/rc.local in order for the script to run during boot. """ try: sleep(30) # Allow plenty of time for everything to load if not CASCADE_PATH.exists() or not VIDEO_PATH.exists(): print("{0}|{1} File(s) not found!" \ .format(CASCADE_PATH.name, VIDEO_PATH.name)) exit(2) faceCascade = cv2.CascadeClassifier(CASCADE_PATH._str) player = OMXPlayer(VIDEO_PATH, args=OMX_PLAYER_ARGS) sleep(1) player.set_position(0.0) player.pause() sleep(1) # sudo modprobe bcm2835-v4l2 you may need to run this command # or add bcm2835-v4l2 to /etc/modules, then reboot capture = cv2.VideoCapture(0) sleep(1) #capture.set(3,640) # set Width #capture.set(4,480) # set Height capture.set(cv2.CAP_PROP_BUFFERSIZE, 3) face_detected = False face_detected_count = 0
def __init__(self): path = Path('../julia4.mp4') self.player = OMXPlayer(path)
video_Num = num def upload_Stone(img_Path): my_files = {'file': open(img_Path, 'rb')} values = {'folder': 'Photos/incoming/left/'} # values = {'folder':'Photos/incoming/right/'} r = requests.post(config['captrue']['http_Add'], files=my_files, data=values) #load white background # dpSubprocess.load_background_image(image = 'black.jpg') blackBG = subprocess.Popen(black, shell=True) player = OMXPlayer(VIDEO_PATH + VIDEO_FILE_IDLE, args='--loop') player.exitEvent += lambda _, exit_code: playerExit(exit_code, 'SCANNING') sleep(3) player.play() while True: try: # if GPIO.input(gpioPin): if keyboard.is_pressed('a'): player.quit() whiteBG = subprocess.Popen(white, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) whiteBG_pid = os.getpgid(whiteBG.pid) stone_CAP_State = queue.Queue() stone_CAP = thread_with_trace(target=catchStone,
# sleep(0.1) # # gpio event setup, uncomment for gpio # GPIO.add_event_detect(13, GPIO.RISING, bouncetime=300) # GPIO.add_event_detect(21, GPIO.RISING, bouncetime=300) # GPIO.add_event_callback(21, playcb) # GPIO.add_event_callback(13, nextcb) # keyboard setup keyboard.add_hotkey('p', lambda: playcb(21)) keyboard.add_hotkey('n', lambda: nextcb(13)) # start player print('loading ' + videoFile + ' duration ' + str(durations[durationIndex])) player = OMXPlayer(videoFile, args=['--loop'], dbus_name='org.mpris.MediaPlayer2.omxplayer1') sleep(5) print(player.position()) # player.set_aspect_mode('stretch') player.set_position(0.00) # print(player.position()) # player.seek(10) sleep(preroll) # print(player.position()) player.pause() # player.action(16) print('ready') # main
from time import sleep GPIO.setmode(GPIO.BCM) # button on GPIO 21 GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP) # indication LED on GPIO 13 GPIO.setup(13, GPIO.OUT) # DEBUG button on GPIO 24 #GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP) VIDEO_PATH = Path("/home/pi/mu_code/videos/SampleVideo_1280x720_10mb.mp4") if len(sys.argv) > 1: VIDEO_PATH = Path(sys.argv[1]) player = OMXPlayer(VIDEO_PATH, args='--no-osd --no-keys -b -o hdmi') def playerExit(code): player.quit() print('exit',code) os._exit(0) last_state1 = True input_state1 = True quit_video = False timer = 0 playing = False # set variable for length of video videoLength = player.duration() - 0.1
def with_just_sound(): logger.info("demande de jouer le son") path = Path(json_datas["music_path"]) OMXPlayer(path) logger.info("jouer le son fini")
def play_it(file): path = Path(file) player = OMXPlayer(path) sleep(player.duration()) player.quit()
def with_sound_and_led(): logger.info("jouer le son et animer les lumières demandé") path = Path(json_datas["music_path"]) OMXPlayer(path) light.animation(5, json_datas["leds_handlers"]) logger.info("jouer le son et animer les lumières fini")
button = 2 GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set GPIO2 as input and interl pull up is activated(button) print("------------------") print(" OMXPlayer + GPIO ") print("------------------") print("--------------") print(GPIO.input(button)) print("--------------") VIDEO_PATH = Path("cam_3d.mp4") BLACK_PATH = Path("black_screen.mp4") player_log = logging.getLogger("Player 1") player_action = OMXPlayer(VIDEO_PATH, dbus_name='org.mpris.MediaPlayer2.omxplayer1') player_stop = OMXPlayer(BLACK_PATH, dbus_name='org.mpris.MediaPlayer2.omxplayer2') # it takes about this long for omxplayer to warm up and start displaying a picture on a rpi3 player_action.pause() sleep(2.5) player_stop.pause() try: while True: # Button was pressed if ( GPIO.input(button) == GPIO.LOW ): sleep(1) try:
#!/usr/bin/env python3 from omxplayer.player import OMXPlayer from pathlib import Path from time import sleep import logging logging.basicConfig(level=logging.INFO) VIDEO_1_PATH = "/home/pirate/test/lushtest1.mlp" #SUBTITLE_1_PATH = "/home/pirate/test/lushtest1.srt" #VIDEO_1_PATH = "/home/pirate/test/lushtest2.mp4" player_log = logging.getLogger("Player 1") player = OMXPlayer(VIDEO_1_PATH, dbus_name='org.mpris.MediaPlayer2.omxplayer1') player.playEvent += lambda _: player_log.info("Play") player.pauseEvent += lambda _: player_log.info("Pause") player.stopEvent += lambda _: player_log.info("Stop") #player.select_subtitle(SUBTITLE_1_PATH) print(dir(player)) #print(player.list_subtitles()) # it takes about this long for omxplayer to warm up and start displaying a picture on a rpi3 sleep(2.5) player.set_position(5) player.pause() sleep(2)
def play_video(self, filename): if self.check_active_player(): self.player.quit() print "Playing " + filename VIDEO_PATH = Path("" + filename + "") self.player = OMXPlayer(VIDEO_PATH, args=['-b'])
def play_mp3_by_link(self, song_link, song_name, song_size, song_time): if song_link: self.omxplayer = OMXPlayer(song_link, ['-o', 'both']) else: self.omxplayer = None
from omxplayer.player import OMXPlayer from sys import argv from time import sleep VIDEO_FILE = argv[1] player = OMXPlayer(VIDEO_FILE, args=['--no-osd'], pause=True) VIDEO_LOCATION = [0, 0, player.width(), player.height()] print VIDEO_LOCATION import curses stdscr = curses.initscr() curses.cbreak() stdscr.keypad(1) stdscr.addstr(0, 10, "Hit 'q' to quit") stdscr.refresh() key = '' while key != ord('q'): key = stdscr.getch() stdscr.addch(20, 25, key) stdscr.refresh() stdscr.addstr(2, 20, ', '.join(str(x) for x in VIDEO_LOCATION)) stdscr.addstr(10, 20, ' ') if key == ord('m'):
def setup_player_two(self): self.player2 = OMXPlayer(self.video_playlist[self.index + 1].path, args='--win 0,0,1920,1080 --layer 1', dbus_name='orb.mpris.MediaPlayer2.omxplayer2', pause = True) self.player2.playEvent += lambda _: self.player_log.info(" 2 Play") self.player2.pauseEvent += lambda _: self.player_log.info("2 Pause") self.player2.stopEvent += lambda _: self.player_log.info("2 Stop")
def on(self): self.play = True print("playing {}".format(self.stations[self.station_index][0])) self.player = OMXPlayer(self.stations[self.station_index][1]) return self.play
from time import sleep import RPi.GPIO as GPIO import Adafruit_ADS1x15 import os # close all previous omxplayer instances os.system('killall omxplayer.bin') adc = Adafruit_ADS1x15.ADS1115() GAIN = 2 # this video is used only to mantain a black screen VIDEO_PATH00 = Path( "/home/pi/Miac/Video/staticNoise.mp4") #"/home/pi/Miac/Video/01.mp4") player00 = OMXPlayer(VIDEO_PATH00, args=['--layer', '2', '-loop', '-b'], dbus_name='org.mpris.MediaPlayer2.omxplayer1') ##player00.pause() ##player00.hide_video() sleep(1) VIDEO_PATHS = [ Path("/home/pi/Miac/Video/01.mp4"), Path("/home/pi/Miac/Video/02.mp4"), Path("/home/pi/Miac/Video/03.mp4"), Path("/home/pi/Miac/Video/04.mp4") ] NOISE_PATH = Path( "/home/pi/Miac/Video/staticNoise.mp4") #non più lungo di 1 secondo! #initialization of players
import logging logging.basicConfig(level=logging.INFO) video_playlist = [] player1 = None player2 = None video_playlist = [ VideoFile(1, "/media/pi/TOSHIBA1/Apocalyptic.mp4"), VideoFile(2, "/media/pi/TOSHIBA1/ledtime.mp4") ] player_log = logging.getLogger("Player") player1 = OMXPlayer(video_playlist[0].path, args='--win 0,0,1920,1080 --layer 2', bus_address_finder=None, Connection=None, dbus_name='orb.mpris.MediaPlayer2.omxplayer1', pause=True) player1.set_alpha(200) player2 = OMXPlayer(video_playlist[1].path, args='--win 0,0,1920,1080 --layer 1', bus_address_finder=None, Connection=None, dbus_name='orb.mpris.MediaPlayer2.omxplayer2', pause=True) player1.play() sleep(player1.duration() - 1) alpha1 = 200
import time import gaugette.gpio import gaugette.rotary_encoder import os from omxplayer.player import OMXPlayer # from pathlib import Path import sys player = OMXPlayer("./vid.mp4", args=[]) player.set_alpha(50) player.set_rate(0.5) rate = 0.5 print(player.minimum_rate()) print(player.rate()) A_PIN = 1 B_PIN = 16 gpio = gaugette.gpio.GPIO() encoder = gaugette.rotary_encoder.RotaryEncoder(gpio, A_PIN, B_PIN) encoder.start() #FIXME: weird issue where, while only comparing to delta of 1, decrease function somehow manages to decrease speed below 0.25 - possibly a timing issue? try: while True: delta = encoder.get_cycles() print(delta) time.sleep(0.1) except KeyboardInterrupt: player.quit() sys.exit()
#!/usr/bin/env python3 from omxplayer.player import OMXPlayer from pathlib import Path from time import sleep VIDEO_PATH_OPENING = Path("./assets/opening.mp4") VIDEO_PATH_BATTLE = Path("./assets/battle-test.mp4") player_opening = OMXPlayer(VIDEO_PATH_OPENING, args=['--no-osd'], pause=True) #player_battle = OMXPlayer(VIDEO_PATH_BATTLE) #player_battle.pause() sleep(5) player_opening.play() sleep(3) player_opening.stop() player_opening.quit() print("quit opening player") #sleep(3) #print("creating new player instance for the battle") #player_battle = OMXPlayer(VIDEO_PATH_BATTLE) #sleep(5)
video_lengths = [5, 102, 5] #[9,102] video_timestamps = [0, 10, 0] current_video = 0 next_video_to_play = 1 number_of_videos = 3 #counter for videos last_button_state = False local_button_state = False # DOM: declare this here quit_video = True player = False buttonPress = False playing = False player = OMXPlayer(movie1, args=['--no-osd', '-b']) button_thread = threading.Thread( target=button_thread_function, args=() ) # DOM: no parentheses after the function name. if you have parentheses then you're alling thr function in the main thread, not in the new thread. button_thread.start() while running: time.sleep(0.0005) if (current_video == 0): try: button_lock.acquire() # DOM: acquire, not aquire local_button_state = button_state finally: button_lock.release()