Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Simple example on how to test OpenCV library
- * It loads an image (loaded as grayscale) and converts it to a Matrix.
- * The matrix is transposed and read each pixel.
- * Author: A.Lepe (dev@alepe.com)
- *
- * To compile: valac --pkg opencv opencv.vala
- */
- using OpenCV;
- void main (string[] args) {
- IPL.Image img = new IPL.Image.load("/var/www/test/image.jpg", IPL.Image.LoadType.GRAYSCALE);
- stdout.printf("Width: %d\n", img.width);
- stdout.printf("Height: %d\n", img.height);
- Matrix mat = new Matrix(img.height, img.width, OpenCV.Type.FC32_1);
- OpenCV.Array.convert(img, mat);
- Matrix matt = new Matrix(img.width, img.height, OpenCV.Type.FC32_1);
- mat.transpose(matt);
- for(int x = 0; x < img.width - 1; x++) {
- for(int y = 0; y < img.height - 1; y++) {
- stdout.printf("%d ", (int)matt.get(x,y));
- }
- stdout.printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement