Exchange the X and Y axis ...

Hello,

Maybe it is a dumb question … :laughing: Is there any method to map the X axis to the Y and the Y to the X of the image object?

My application needs to see more on the vertical field so I rotate the camera by 90 degree. It works fine except that the X axis now becomes the vertical and Y becomes horizontal. I am thinking if the output of the sensor can have the X and Y exchanged, then everything will become “native”. Is there any simple method to do that? Thanks!

Regards,
CM Cheng

Do you need to rotate the image ? See replace and transpose:

http://docs.openmv.io/library/omv.image.html?highlight=transpose#image.image.replace

Thanks for the reply. I tried the transpose and it works. However, it seems that there is some significant fps drop. I used the default code to test. Changed it to GRAYSCALE so the fps is larger and any changes to it is easier to notice.

The fps of the original code is over 50.
With the first “replace” it reduces the fps to 30.
With the two “replace” the fps drops to 24.

I am thinking if there is any method that do this in lower / hardware level. It is “native” so there is no fps drop. Like “QVGA” is not by software scaling down the “VGA”.

Best regards,
CM Cheng

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot()
    img.replace(transpose=True)
    img.replace(hmirror=True)
    print(clock.fps())

Hi, you can do both operations with the same call:

img.replace(transpose=True, hmirror=True)

The only way to do this faster is to turn on hmirror on the camera sensor. The camera sensor doesn’t support transpose however. The camera sensor does support hmirror and vflip however.

If you want fast transpose you have to modify this C code: https://github.com/openmv/openmv/blob/master/src/omv/sensor.c#L793

This method is what takes pixels from DMA and puts them into the image. It’s called when lines from the camera come in. So, it’s done while reviving the image. Adding a feature to transpose while it’s running doesn’t seem like a big deal.

img.replace(transpose=True, hmirror=True): The result is different if I put them into two instructions.

For changing the C code, I think it is too difficult to me :confused: I just want to know if there is a simple (and fast) method to do the transpose that I could have missed from the documents. If there is not, I can “mentally transpose” the axis when writing the code. :laughing:

Thank you very much for your input.

Best regards,
CM Cheng

Hi, if the result is different then that just means you need to do another operation instead.

img.replace(transpose=True, hmirror=True, vflip=True)

Cycle through all eight possible values of True/False above until you get the one you want.

Hello Nyamekye,

It is off topic. I have connection problem with my PC before ( OpenMV connection problem - OpenMV Products - OpenMV Forums ). The recent update seems fixed it. Thanks!!

CM Cheng