i'm using Google Cloud Vision API to detect a captured image taken from pi camera and if the picture detected as an animal, it will delete the picture and if it's not, it will running another function called: takePicture(image_name). My script works absolutely well, but most times i have a weird problem called Segmentation Fault and when this happened it doesn't interrupt my python program but my 4x4 keypad (connected to RPi) stop working and also automatically create another loop process of python program which is still running even with "keyboard interrupt".
def detectImage(self, image_name):
path = '/home/pi/homesecurity/pictures/' + image_name
max_results=1
with open(path, 'rb') as image_file:
content = image_file.read()
image = vision.types.Image(content=content)
objects = client.object_localization(image=image,max_results=max_results).localized_object_annotations
for object_ in objects:
if (object_.name == 'Animal' or object_.name == 'Cat' or object_.name == 'Dog' or object_.name == 'Bird' or object_.name == 'Insect'):
print ('False Alarm: This is an animal!')
os.remove('/home/pi/homesecurity/pictures/' + image_name) #Deletes the taken picture.
print 'File', image_name, 'has beeen deleted'
break
else:
Process(target=interact().takePicture(image_name)).start()
print('Not an animal!')
Is it possible of the old hardware ? because i'm using Raspberry Pi Model B and python 2.7
pi@raspberrypi:~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 000e
Serial : 0000000095fec982
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"