[PYTHON] Try fishing for smelt with Raspberry Pi

WHY I just got angry, and now I'm reflecting on it. image

WHAT It is a method of fishing smelt using Raspberry Pi. Smelt fishing is that of making a hole in the ice and catching a fish.

Overview

--A camera and a motor are attached to the Raspberry Pi --When the image processing can detect the attack on the tip of the rod, the motor is turned. --Automated invitation (movement to invite fish by moving a little) --Atari used a tracking algorithm called a particle filter

Handicraft

I've never done electronic work, so I've only made the minimum preparations. Basically, the Raspberry Pi just comes with:

--Power supply: The trouble is that there is no power supply on the ice, so I use the battery for charging the smartphone. --Camera: An ordinary WEB camera for about 1000 yen --Wifi adapter ――The trouble is that Wifi doesn't fly on the ice. -Create an ad-hoc network Communicate with mac --Display the camera image with SSH -X and test it.

no_fish_big.jpg

Turn the motor

By switching the GPIO output (0, 1), it is possible to rotate clockwise or counterclockwise. Install rpi.gpio to control it from python. sudo apt-get install python-rpi.gpio

Test code that rotates clockwise for 2 seconds → rotates counterclockwise for 2 seconds.

import RPi.GPIO as GPIO
import time

def init_gpio():
    GPIO.setmode(GPIO.BCM)
    
    channel_list = [14, 15, 18]
    GPIO.setup(channel_list, GPIO.OUT)

def stop():
    GPIO.output(14, False)
    GPIO.output(15, False)
    GPIO.output(18, False)

def rotate_right(duration):
    stop()
    GPIO.output(14, True)
    GPIO.output(15, False)
    GPIO.output(18, True)
    time.sleep(duration)
    stop()

def rotate_left(duration):
    stop()
    GPIO.output(14, False)
    GPIO.output(15, True)
    GPIO.output(18, True)
    time.sleep(duration)
    stop()

def cleanup():
    GPIO.cleanup()


init_gpio()

rotate_right(2)

rotate_left(2)

cleanup()

no_fish_big.jpg

It seems that I can somehow turn the thread.

Detect Atari

The camera alone must detect small movements at the tip of the rod. This time I tried using a particle filter. The particle filter is an algorithm that randomly generates a large number of particles, selects particles that are close to the desired state, and repeatedly tracks them. Since it is difficult to detect only the tip of the rod, this time we implemented a painstaking solution of ** putting green paper on the tip of the rod **.

sky.jpg

Taking it seriously, the algorithm is as follows.

--In the initial mode, move the rod in attract mode --When the shaking of the rod has subsided, the next step is to switch to detect mode. ――If ――If there is a strong shaking of the rod, raise it in fish mode and switch to wait mode. --Wait until the s key is pressed in standby mode --If there is no detection for a certain period of time, it shifts to the initial attract mode. Repeat this

A python script mainly built on ice. https://github.com/tan-z-tan/raspi_fishing/blob/master/src/RaspiFishing.py Skip GUI with SSH -X It is written on the assumption.

Invitation (move a little)

This is all because I implemented it on ice without thinking about anything.

motor.rotate_left(0.53)
motor.rotate_right(0.7)

Constants like 0.53 and 0.7 are warm constants for craftsmen who have taken the time and effort. This is due to the fact that the rotation angle is slightly different even if the number of seconds is the same for winding and lowering the motor.

I tried it on the ice

I was able to catch it. The appearance of a poor smelt caught by a machine. I'm happy.

IMG_20160213_103856.jpg

About 4 hours of fishing

** Raspberry Pi: 2 animals ** ** Human average: 6.75 animals ** image

** Conclusion: You can catch better if you do it **

When I wrote it seriously, there were too few fish on the whole and I could hardly do a test. When it is time to catch 100 smelts, it is a mechanical task just to put them in and raise them, so mechanization will be effective. .. .. Should be.

I want to hold a Raspberry Pi Fishing contest.

Recommended Posts

Try fishing for smelt with Raspberry Pi
Try L Chika with raspberry pi
Try moving 3 servos with Raspberry Pi
Try Object detection with Raspberry Pi 4 + Coral
GPGPU with Raspberry Pi
DigitalSignage with Raspberry Pi
Media programming with Raspberry Pi (preparation for audio)
Try debugging Python on Raspberry Pi with Visual Studio.
Update Python for Raspberry Pi to 3.7 or later with pyenv
I made a resource monitor for Raspberry Pi with a spreadsheet
[Raspberry Pi] Stepping motor control with Raspberry Pi
Use vl53l0x with Raspberry Pi (python)
Servo motor control with Raspberry Pi
Serial communication with Raspberry Pi + PySerial
OS setup with Raspberry Pi Imager
Raspberry pi initial setting (for myself)
Try using ArUco on Raspberry Pi
VPN server construction with Raspberry Pi
Using a webcam with Raspberry Pi
Measure SIM signal strength with Raspberry Pi
Pet monitoring with Rekognition and Raspberry pi
Hello World with Raspberry Pi + Minecraft Pi Edition
Build a Tensorflow environment with Raspberry Pi [2020]
Programming normally with Node-RED programming on Raspberry Pi 3
Improved motion sensor made with Raspberry Pi
Power SG-90 servo motor with raspberry pi
Working with sensors on Mathematica on Raspberry Pi
Use PIR motion sensor with raspberry Pi
Make a wash-drying timer with a Raspberry Pi
Infer Custom Vision model with Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Create a car meter with raspberry pi
[For beginners] Try web scraping with Python
Inkbird IBS-TH1 value logged with Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Try tweeting arXiv's RSS feed on twitter from Raspberry Pi with python
Discord bot with python raspberry pi zero with [Notes]
Try using a QR code on a Raspberry Pi
I tried L-Chika with Raspberry Pi 4 (Python edition)
Raspberry Pi backup
Enjoy electronic work with GPIO on Raspberry Pi
MQTT RC car with Arduino and Raspberry Pi
Power on / off your PC with raspberry pi
Use Majoca Iris elongated LCD with Raspberry Pi
CSV output of pulse data with Raspberry Pi (CSV output)
Observe the Geminids meteor shower with Raspberry Pi 4
Get CPU information of Raspberry Pi with Python
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
[For beginners] I made a motion sensor with Raspberry Pi and notified LINE!
Play with your Ubuntu desktop on your Raspberry Pi 4
I tried to create a button for Slack with Raspberry Pi + Tact Switch
Try to detect an object with Raspberry Pi ~ Part 1: Comparison of detection speed ~
Get temperature and humidity with DHT11 and Raspberry Pi
Try building an environment for MayaPython with VisualStudioCode
Stock investment analysis app made with Raspberry Pi
Logging Inkbird IBS-TH1 mini values with Raspberry Pi
Try to use up the Raspberry Pi 2's 4-core CPU with Parallel Python
Connect to MySQL with Python on Raspberry Pi
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Measure CPU temperature of Raspberry Pi with Python
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby