Getting 32×32 grayscale image using Openmv cam m7

OpenMV related project discussion.
uzair mazhar awan
Posts: 7
Joined: Tue Jul 18, 2017 4:27 am

Getting 32×32 grayscale image using Openmv cam m7

Postby uzair mazhar awan » Tue Jul 18, 2017 4:35 am

Hi!
I am using openmv cam for my project but i am unable to get the image of desired resolution. Can anyone help me in this.
Also if someone have sample code of image capturing and resizing, please share it.
Thanks in advance.
User avatar
kwagyeman
Posts: 1761
Joined: Sun May 24, 2015 2:10 pm

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby kwagyeman » Tue Jul 18, 2017 12:20 pm

Hi, we don't have a general purpose image resize but you can set the resolution to qqqvga for a 80x60 image and then you can set the image windowing for 32x32 pixels. See the docs sensor docs on this. It should be possible to do what you need.
Nyamekye,
uzair mazhar awan
Posts: 7
Joined: Tue Jul 18, 2017 4:27 am

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby uzair mazhar awan » Wed Jul 19, 2017 3:46 am

Hi!
Can you please elaborate this windowing algorithm or suggest some manual or tutorial for openmv ide so that i can do my desired task
User avatar
kwagyeman
Posts: 1761
Joined: Sun May 24, 2015 2:10 pm

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby kwagyeman » Wed Jul 19, 2017 11:06 am

Set the resolution to qqqvga. The do sensor.set_windowing((32, 32)). This command is documented in the docs under sensor.
Nyamekye,
uzair mazhar awan
Posts: 7
Joined: Tue Jul 18, 2017 4:27 am

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby uzair mazhar awan » Mon Jul 24, 2017 2:39 am

ok thanks . i am gonna try this and will get back to you if i need any further assistance.
uzair mazhar awan
Posts: 7
Joined: Tue Jul 18, 2017 4:27 am

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby uzair mazhar awan » Mon Jul 24, 2017 5:03 am

One more question.When we read image in Matlab then image is in 2D array form.
In open MV "image = sensor.snapshot()" , can you please tell me in which form this image data will be and if its not same as in matlab then also mention the method through which i can convert this data into 2D array form.
Please see the attachment for better understanding of my question.
Attachments
Test.JPG
Test.JPG (59.94 KiB) Viewed 2018 times
User avatar
kwagyeman
Posts: 1761
Joined: Sun May 24, 2015 2:10 pm

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby kwagyeman » Mon Jul 24, 2017 2:02 pm

The OpenMV Cam doesn't run MatLab code. It has nothing to do with MatLab. Our image data is stored in a 2d array as grayscale 8bit pixel values or rgb565 16bit pixel values.

If you'd like to save an image for use with matab do img.save. See snapshot examples scripts for how to save images.
Nyamekye,
uzair mazhar awan
Posts: 7
Joined: Tue Jul 18, 2017 4:27 am

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby uzair mazhar awan » Mon Jul 24, 2017 2:11 pm

and that array number starts from zero or 1 ?
User avatar
kwagyeman
Posts: 1761
Joined: Sun May 24, 2015 2:10 pm

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby kwagyeman » Mon Jul 24, 2017 3:53 pm

The image array is zero indexed. Just do img[] to access the array. In grayscale each value is 8 bits, 0 to 255. The array is 2d but accessed as a 1d array so you need to manually do row and column indexing. E.g. "(y * w) + x".
Nyamekye,
uzair mazhar awan
Posts: 7
Joined: Tue Jul 18, 2017 4:27 am

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby uzair mazhar awan » Tue Jul 25, 2017 2:18 am

Can you plz elaborate this 1D array access concept and please define these variables. I'll be very grateful.
User avatar
kwagyeman
Posts: 1761
Joined: Sun May 24, 2015 2:10 pm

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby kwagyeman » Tue Jul 25, 2017 2:42 am

X, Y = pixel location.

img[(Y * img.width()) + X]

This is how you access arrays in standard programming and what a 2d array access boils down into...
Nyamekye,
User avatar
kwagyeman
Posts: 1761
Joined: Sun May 24, 2015 2:10 pm

Re: Getting 32×32 grayscale image using Openmv cam m7

Postby kwagyeman » Tue Jul 25, 2017 2:44 am

I highly recommend you read up on 1d and 2d arrays in C and python. Google is your friend.
Nyamekye,

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest