Hi again, Update on the issue.
The problem was that I had the picamera2 instance installed in the venv but did not have access to the picamera2.devices.IMX500 modul. there are to imports in the ai_camera that raised the same error text. and since the picamera2 was installed without the IMX500 extention I missed that it was to diffrent import errors.
@staticmethod
def initiate_picamera2():
try:
from picamera2 import Picamera2
return Picamera2()
except ImportError:
raise ImportError(
"""
picamera2 is not installed. Please install picamera2 to use the AiCamera device.\n\n
For a raspberry pi with picamera2 installed. Enable in virtual env using:
`python -m venv .venv --system-site-packages`\n
"""
)
@staticmethod
def get_imx500_model(model_path):
try:
from picamera2.devices import IMX500
return IMX500(os.path.abspath(model_path))
except ImportError:
raise ImportError(
"""
picamera2 is not installed. Please install picamera2 to use the AiCamera device.\n\n
For a raspberry pi with picamera2 installed. Enable in virtual env using:
`python -m venv .venv --system-site-packages`\n
"""
)
-----------------------------------------------------------------------------------
Now when I run a isolated example.py script:
from unify.devices import AiCamera
from unify.models import COLOR_FORMAT, MODEL_TYPE, Model
from unify.models.post_processors import pp_cls
import sys
print(sys.path)
class MobilenetV2(Model):
def __init__(self):
super().__init__(
model_file="./imx500_network_mobilenet_v2.rpk",
model_type=MODEL_TYPE.PACKAGED,
color_format=COLOR_FORMAT.RGB,
preserve_aspect_ratio=True
)
def post_process(self, output_tensors):
return pp_cls(output_tensors)
device = AiCamera()
model = MobilenetV2()
device.deploy(model)
with device as stream:
for frame in stream:
print(frame.detections)
frame.display()
-----------------------------------------------------------------------------------
it works fine. but still haveing the same issue with the ./dist/run.sh for the bigger program.
I have gone over all the .venv and with the activated I could confirm they are importing the IMX500 from system. So I must be missing som venv somewhere. Any sugestions?
The problem was that I had the picamera2 instance installed in the venv but did not have access to the picamera2.devices.IMX500 modul. there are to imports in the ai_camera that raised the same error text. and since the picamera2 was installed without the IMX500 extention I missed that it was to diffrent import errors.
@staticmethod
def initiate_picamera2():
try:
from picamera2 import Picamera2
return Picamera2()
except ImportError:
raise ImportError(
"""
picamera2 is not installed. Please install picamera2 to use the AiCamera device.\n\n
For a raspberry pi with picamera2 installed. Enable in virtual env using:
`python -m venv .venv --system-site-packages`\n
"""
)
@staticmethod
def get_imx500_model(model_path):
try:
from picamera2.devices import IMX500
return IMX500(os.path.abspath(model_path))
except ImportError:
raise ImportError(
"""
picamera2 is not installed. Please install picamera2 to use the AiCamera device.\n\n
For a raspberry pi with picamera2 installed. Enable in virtual env using:
`python -m venv .venv --system-site-packages`\n
"""
)
-----------------------------------------------------------------------------------
Now when I run a isolated example.py script:
from unify.devices import AiCamera
from unify.models import COLOR_FORMAT, MODEL_TYPE, Model
from unify.models.post_processors import pp_cls
import sys
print(sys.path)
class MobilenetV2(Model):
def __init__(self):
super().__init__(
model_file="./imx500_network_mobilenet_v2.rpk",
model_type=MODEL_TYPE.PACKAGED,
color_format=COLOR_FORMAT.RGB,
preserve_aspect_ratio=True
)
def post_process(self, output_tensors):
return pp_cls(output_tensors)
device = AiCamera()
model = MobilenetV2()
device.deploy(model)
with device as stream:
for frame in stream:
print(frame.detections)
frame.display()
-----------------------------------------------------------------------------------
it works fine. but still haveing the same issue with the ./dist/run.sh for the bigger program.
I have gone over all the .venv and with the activated I could confirm they are importing the IMX500 from system. So I must be missing som venv somewhere. Any sugestions?
Statistics: Posted by sverkerevefall — Sat Nov 16, 2024 9:06 am