Copy and Paste  -   An Application to Copy/Paste Text  

 
S.No 4830 Name tuto Date/Time 08-May-2022 07:49:22 PM

Copy text from below

STEP 1: SETTING UP THE WEBCAM

 

 

Open up the terminal and run:

 

sudo su

 

Press Enter

 

This will change to admin console

 

Now write:

 

sudo apt-get update

 

 

 

After this finishes running, we should test that the webcam works. 

 

Plug your webcam into the Raspberry PI and run:

 

sudo apt-get install fswebcam 

 

(This will install the driver for the webcam)

 

fswebcam test.jpg

 

(This will take a picture from your webcam.

 

Open the file manager and see if there is a photo.)

 

 

STEP 2: INSTALLING AND CONFIGURING MOTION

 

 

In order to turn our webcam into a motion detector, we will be using the open-source "motion" library which 

was designed just for this purpose.

 

First, install motion by running:

 

sudo apt-get install motion

 

 

After the motion is installed, we need to install a file explorer using which we can edit the motion.conf file

 

For that purpose, give the following command:

 

sudo su

 

 

 

sudo apt-get install nautilus-admin

 

 

Now in terminal, write:

 

sudo su

 

nautilus

 

This will open a file manager window

 

 

Next,open the file manager and navigate to this path:

 

 

 

/etc/motion/motion.conf

 

perform the following changes:

 

on_event_start python /home/pi/switch_on_motor.py

 

on_event_end python /home/pi/switch_off_motor.py

 

event_gap 20

 

 

////////////////// CODE FOR switch_on_motor.py ////////////////

import time

import pygame

import sys

import RPi.GPIO as GPIO

RelayPin = 37   # pin11

 

 

def relayActivate(s):

    

    if s == "ON":

        print("Relay is ON")

        GPIO.setmode(GPIO.BOARD)

        GPIO.setup(RelayPin, GPIO.OUT)

        GPIO.output(RelayPin, GPIO.HIGH)

    else:

        print("Relay is OFF")

        GPIO.setmode(GPIO.BOARD)

        GPIO.setup(RelayPin, GPIO.OUT)

        GPIO.output(RelayPin, GPIO.LOW)

        GPIO.cleanup()

 

relayActivate("ON")

 

 

 

 

 

pygame.init() #<-- initializes video

pygame.mixer.init()

pygame.mixer.music.load("/home/pi/dog_bark_long.wav")

pygame.mixer.music.play()

 

 

SONG_END = pygame.USEREVENT + 0

pygame.mixer.music.set_endevent(SONG_END)

 

 

while True:

    for event in pygame.event.get():

        if event.type == SONG_END:

            print("the song ended!")

            pygame.mixer.music.stop()

            pygame.quit()

            sys.exit()

 

///////////////////////////////////////

 

 

 

////////////////// CODE FOR switch_off_motor.py ////////////////

 

import time

import pygame

import sys

import RPi.GPIO as GPIO

RelayPin = 37   # pin11

 

 

def relayActivate(s):

    

    if s == "ON":

        print("Relay is ON")

        GPIO.setmode(GPIO.BOARD)

        GPIO.setup(RelayPin, GPIO.OUT)

        GPIO.output(RelayPin, GPIO.HIGH)

    else:

        print("Relay is OFF")

        GPIO.setmode(GPIO.BOARD)

        GPIO.setup(RelayPin, GPIO.OUT)

        GPIO.output(RelayPin, GPIO.LOW)

        GPIO.cleanup()

 

relayActivate("OFF")

 

 

////////////////////////////////////////////

 

 

After we have changed the settings,Run:

 

sudo motion

 

To kill motion, we can use following commands:

 

sudo su

 

ps -aux | grep motion

 

kill <id of motion>

 

 

Download and install VLC by opening up a new terminal and running:

 

sudo apt-get install vlc

 

Once VLC is set up, we can watch the webcam stream by running:

 

vlc http://localhost:8081/stream.mjpg

 

(NOTE:This should not be run with root(sudo su)or it will show an error)

 





comments powered by Disqus
NEW ENTRIES
S.No Name Entry Time/Date
4897 test 12 28 E 28-Jul-2022 10:59:40 AM
4896 test 11 28 E 28-Jul-2022 10:55:41 AM
4895 test 28-Jul-2022 10:55:15 AM
4894 test 8 28 Ev 28-Jul-2022 10:53:51 AM
4893 test 5 28 Ev 28-Jul-2022 10:39:27 AM
4892 test 4 28 Ev 28-Jul-2022 10:38:07 AM
4891 test 3 28 Ev 28-Jul-2022 10:32:47 AM
4890 test 2 28 Ev 28-Jul-2022 10:31:33 AM
4889 Test 1 28 Ev 28-Jul-2022 10:29:59 AM
4888 Update Kiddo 28-Jul-2022 07:56:17 AM
4887 27-Jul-2022 06:10:30 PM
4886 Test 12 28 M 27-Jul-2022 04:59:11 PM
4885 Test 11 28 M 27-Jul-2022 04:55:12 PM
4884 Test 8 28 M 27-Jul-2022 04:49:23 PM
4883 Test 5 28 M 27-Jul-2022 04:47:27 PM
4882 Test 4 28 M 27-Jul-2022 04:45:56 PM
4881 Test 3 28 M 27-Jul-2022 02:58:05 PM
4880 test 2 28 M 27-Jul-2022 02:50:57 PM
4879 test 1 28 M 27-Jul-2022 02:41:34 PM
4878 Junior H O T 27-Jul-2022 06:58:02 AM
4877 test 12 26 E 26-Jul-2022 11:19:44 AM
4876 test11 26 ev 26-Jul-2022 11:08:44 AM
4875 test 8 26 Ev 26-Jul-2022 11:06:18 AM
4874 test 6 26 ev 26-Jul-2022 10:51:04 AM
4873 test 5 26-Jul-2022 10:50:39 AM
4872 test 4 26 Ev 26-Jul-2022 10:49:16 AM
4871 test 3 26 ev 26-Jul-2022 10:44:51 AM
4870 test 2 26 ev 26-Jul-2022 10:41:19 AM
4869 test 1 26 ev 26-Jul-2022 10:40:02 AM
4868 test 2 Ev 26-Jul-2022 10:39:11 AM

[First] [Prev] 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 [Next] [Last]
 
web counter
web counter


To report any error messages or bugs, or other issues, please send email at: info@pakproject.com