Hi, I am having trouble doing lens correction on a cropped image.
Because I need the camera quite close to my object, I am using a wide angle lens (160 deg HFOV according to the manufacturer) mounted on my OpenMV Cam H7 R2. I also need high resolution, so I’ve set my sensor frame size to sensor.WXGA, and I don’t need color so I’m using grayscale. When doing image.lens_corr(), I get the error “MemoryError: Out of fast Frame Buffer Stack Memory!”, so I am using sensor.set_windowing() per this thread, which resolved the error.
However, since the windowing I need is off-center, the image.lens_corr() function is wrong since it does the correction assuming I’m centered. I tried to use x_corr and y_corr, but it just turned the Frame Buffer all black. I also tried using sensor.set_lens_correction() thinking it could correct before windowing, but that function doesn’t seem to be doing anything. Thank you in advance for the help!
Here are some pictures showing what I mean:
import sensor, image
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to grayscale
sensor.set_framesize(sensor.WXGA)
sensor.set_windowing((200,350,300,300)) # window to bottom left corner due to memoryerror
sensor.set_contrast(3) # adjust contrast -3 to +3
sensor.set_vflip(True) # flip vertically
sensor.set_hmirror(True) # mirror horizontally
#sensor.set_lens_correction(True, 200, 10) # doesn't do anything
sensor.skip_frames(time = 2000) # Wait for settings take effect.
while(True):
img = sensor.snapshot() # Take a picture and return the image.
img.lens_corr(strength =2, zoom = 1) # exaggerated strength to show incorrect effect on windowed image
pyb.delay(500)