import requests
import base64
from edgeimpulse_api import Configuration, ApiClient, ProjectsApi
Configurações de acesso ao Edge Impulse
API_KEY = ‘ei_XXXX’
PROJECT_ID = ‘208326’
HMAC_KEY = ‘f3eeXXXX’
Settings
host = “https://studio.edgeimpulse.com/v1”
api_key = “ei_8b2XXXX”
Create a client object that can connect to our project
config = Configuration(host=host, api_key={“ApiKeyAuthentication”: api_key})
client = ApiClient(config)
Get info about the project
projects = ProjectsApi(client)
project_list = projects.list_projects()
print(project_list.projects[0])
Função para fazer a detecção de objetos no Edge Impulse
def detect_objects(image_path):
with open(image_path, ‘rb’) as image_file:
image_data = image_file.read()
image_base64 = base64.b64encode(image_data).decode(‘utf-8’)
headers = {
‘Content-Type’: ‘application/json’,
‘x-api-key’: API_KEY,
‘x-imp-project-id’: PROJECT_ID,
‘x-imp-hmac’: HMAC_KEY
}
payload = {
‘image’: image_base64
}
response = requests.post(‘https://ingestion.edgeimpulse.com/api/infer’, headers=headers, json=payload)
if response.status_code == 200:
return response.json()
else:
print(‘Falha na detecção de objetos:’, response.text)
return None
Caminho da imagem para detecção de objetos
imagem_path = ‘/home/anderson/Downloads/20230424_090022.jpg’
Fazer a detecção de objetos
resultados_objetos = detect_objects(imagem_path)
Error: /bin/python /home/anderson/Desktop/smartcashier.py
id=210040 name=‘smart_cashier_FOMO (Created by Samuel Alexander)’ description=‘This is your Edge Impulse project. From here you acquire new training data, design impulses and train models.’ created=datetime.datetime(2023, 4, 12, 11, 55, 59, 773000, tzinfo=datetime.timezone.utc) owner=‘Victor Hugo Silva Corsi’ last_accessed=datetime.datetime(2023, 4, 26, 11, 10, 3, 592000, tzinfo=datetime.timezone.utc) logo=None owner_user_id=None owner_organization_id=27072 owner_avatar=None owner_is_developer_profile=True collaborators=[ProjectCollaborator(id=106734, username=‘vicorsi’, name=‘Victor Hugo Silva Corsi’, photo=‘’, created=datetime.datetime(2023, 4, 12, 11, 55, 59, 773000, tzinfo=datetime.timezone.utc), last_seen=None, staff_info=StaffInfo(is_staff=False, has_sudo_rights=False, company_name=None), pending=False, last_tos_acceptance_date=None, job_title=None, is_owner=True)] labeling_method=‘object_detection’ metadata={} data_explorer_screenshot=None is_enterprise_project=False whitelabel_id=None tags=[] category=‘Object detection’ license=None tier=‘free’ has_public_version=False
Falha na detecção de objetos:
Cannot POST /api/infer
Project ID: 208326
I have a project of a standalone box using python, but my code is accusing the following error, i need end this in 5 days, im using raspberry pi 4