from picamera import PiCamera
import time
import json
import pybase64
import datetime
import requests
//CAPTURING A PICTURE AND SAVING IT//
camera = PiCamera()
camera.start_preview()
time.sleep(0.5)
camera.capture("/home/pi/Desktop/rasppi/images/image2.jpg")
camera.stop_preview()
//CONVERTING INTO BASE64 STRING//
with open("/home/pi/Desktop/rasppi/images/image2.jpg", "rb") as file:
string = pybase64.b64encode(file.read())
file.close()
url = "192.168.139.87:9000/upload"
payload = string
//USING POST REQUEST TO UPLOAD IMAGE ON URL//
response = requests('post', url, data = payload)
now = datetime.datetime.now()
time = str(now)
obj = json.loads(response.text)
id = ["emp_id"]
var = "Identified person is : " + id
print(var)
print(time)
It generates following error:
Traceback (most recent call last):
File "get_image.py", line 22, in <module>
response = requests('post', url, data = payload)
TypeError: 'module' object is not callable
Этот код имеет дело с программой для захвата изображения с помощью Raspberry Pi и затем поместите его в URL. Команда запроса POST показывает некоторую ошибку.