Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'numpy.ndarray' object has no attribute '_get_object_id' #21

Open
tlp19 opened this issue Feb 2, 2023 · 4 comments
Open

Comments

@tlp19
Copy link

tlp19 commented Feb 2, 2023

Hi, I am encountering the following error AttributeError: 'numpy.ndarray' object has no attribute '_get_object_id'.

I am using PyBoof 0.41 on Python 3.9.2, with numpy 1.24.1.

I am trying to run the following code on a Rasberry Pi 4B (Raspbian):

import cv2
import numpy as np
import pyboof as pb

cam = cv2.VideoCapture(0)
detector = pb.FactoryFiducial(np.uint8).qrcode()

while(True):
    success, frame = cam.read()
    if not success:
        break
    else:
        detector.detect(frame)
        print("Detected a total of {} QR Codes".format(len(detector.detections)))

But I get the following error from the line detector.detect(frame):
AttributeError: 'numpy.ndarray' object has no attribute '_get_object_id'

What am I doing wrong here?

@tlp19
Copy link
Author

tlp19 commented Feb 2, 2023

I have tried converting the np.array frame to a BoofCV image before passing it to the detector, as follows:

detector.detect(pb.ndarray_to_boof(frame))

But I now get a BufferError: memoryview: underlying buffer is not C-contiguous

@tlp19
Copy link
Author

tlp19 commented Feb 2, 2023

Actually, I believe that this error was cause by me slicing/cropping the frame before converting it to a BoofCV image:

while(True):
    success, frame = cam.read()
    if not success:
        break
    else:
        # frame = my_crop_function(frame)                 # I had this line here that I omitted to mention
        
        boof_img = pb.ndarray_to_boof(frame).
        detector.detect(boof_img)
        print("Detected a total of {} QR Codes".format(len(detector.detections)))

I am not sure why this caused an error, but this is most likely an issue with NumPy.
I just removed the line to fix the error (cropping the image was not essential for me, so I can do without).

I am now facing another issue however, this time with Py4J:

py4j.protocol.Py4JError: An error occurred while calling o38.process. Trace:
py4j.Py4JException: Method process([class boofcv.struct.image.InterleavedU8]) does not exist

which comes from the line

detector.detect(boof_img)

Am I still doing something wrong here?

@lessthanoptimal
Copy link
Owner

Sorry for taking so long to get back. That looks like a python <-> Java issue. The path should exist. I'm wondering if somehow the classpath is messed up. Can you provide an image that triggers this issue and I will try to replicate it?

@tlp19
Copy link
Author

tlp19 commented Feb 16, 2023

Hey, thanks for getting back to me.

It appears than just a blank image created with

frame = np.zeros([512,512,3], dtype=np.uint8)

causes the error above.

Could there perhaps be something wrong with my installation of Java? I have installed both the default-jre and the default-jdk using sudo apt install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants