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
4717 q3 18-Dec-2021 02:17:14 PM
4716 a2 18-Dec-2021 01:57:57 PM
4715 azaz 18-Dec-2021 01:50:06 PM
4714 aa 17-Dec-2021 05:50:08 PM
4713 P 16-Dec-2021 12:09:01 PM
4712 16-Dec-2021 10:15:42 AM
4711 JSofShahbaz 15-Dec-2021 04:11:42 PM
4710 Shahbaz 15-Dec-2021 03:59:25 PM
4709 multi-cb 15-Dec-2021 11:05:56 AM
4708 multi_file_u 15-Dec-2021 11:00:13 AM
4707 fetchapi 14-Dec-2021 11:34:15 AM
4706 jimy 07-Dec-2021 04:32:44 PM
4705 html ,php 05-Dec-2021 10:57:44 AM
4704 Golston 03-Dec-2021 08:47:12 AM
4703 abbas 30-Nov-2021 11:04:10 PM
4702 a 30-Nov-2021 09:06:16 PM
4701 Calculator 30-Nov-2021 05:49:53 PM
4700 js calculato 30-Nov-2021 05:22:43 PM
4699 js_calc 30-Nov-2021 04:34:27 PM
4698 Nidascode 28-Nov-2021 12:31:34 AM
4697 Nida 27-Nov-2021 10:10:10 PM
4696 aasas 26-Nov-2021 04:14:17 PM
4695 form valid 23-Nov-2021 04:30:46 PM
4694 QUANTUMUNIVE 20-Nov-2021 11:53:26 AM
4693 Shahbaz 14-Nov-2021 11:27:23 AM
4692 azaz 13-Nov-2021 02:04:21 PM
4691 ABU 09-Nov-2021 08:43:25 PM
4690 name regex 09-Nov-2021 03:59:46 PM
4689 regexp 04-Nov-2021 04:21:36 PM
4688 asdf 29-Oct-2021 05:24:55 PM

[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