PhotonVision doesn't find targets on code

Our team is planning to use a Raspberry Pi 3 + PhotonVision + LifeCam 3000 to detect AprilTags. We’ve configured the static IP of the coprocessor and the connection with the RoboRIO worked normally. However, when I call the hasTargets() or getTargets(), it returns nothing. I created a ntcore.getDefault() instance to pass into the PhotonCamera constructor, but still not working.

The PhotonVision UI detects all tags without problems. I can access it from my browser using the 10.TE.AM.11:5800 without an Ethernet cable connected to my computer (directly from Radio).

We’re using RobotPy, but I believe that’s not a problem related to it.

Any tips to resolve this?

Code link? The default ntcore thjng seems suspect but much quicker if I can just look at the code.

1 Like
import wpilib
import photonvision
import ntcore

class PhotonVisionTest(wpilib.TimedRobot):
    def robotInit(self) -> None:
        self.camera = photonvision.PhotonCamera('Microsoft_LifeCam_HD-3000')
        self.result = self.camera.getLatestResult()

    def robotPeriodic(self) -> None:
        if self.result.hasTargets():
            print('it worked!')
        else:
            print('it didn't work')
        #print(self.result.getTargets())
       
if __name__ == '__main__':
    wpilib.run(PhotonVisionTest)

And yes, I’m testing with print

From what I’m reading you only get results one time? And then never again after init ?

2 Likes

woops… :sweat_smile:
I put the function in periodic here and it worked.

thanks!