Ask Your Question

LinkTheProgrammer's profile - activity

2018-11-06 10:32:27 -0600 received badge  Popular Question (source)
2015-02-26 09:25:39 -0600 commented question Image loads; Cannot put into array

this conversation is pointless now, duschendestroyer. Let's talk in IRC.

2015-02-26 09:22:14 -0600 commented question Image loads; Cannot put into array

Yes, but I need that for a BufferedImage. Here is what I see when I use the one-liner you gave me: http://prntscr.com/6a2xlr

2015-02-26 09:11:24 -0600 commented question Image loads; Cannot put into array

Well, do you know of a way for me to just copy the data using x y w h?

2015-02-26 09:05:32 -0600 commented question Image loads; Cannot put into array

Well, That converts it to BGRA, but if I load the image using Imgcodecs.imread(imgname, Imgcodecs.IMREAD_UNCHANGED), that should load unchanged, as in the actual read in data right? Also, I still need a way to efficiently copy the data in one swift move.

2015-02-26 09:00:13 -0600 answered a question [Java] How capture Webcam and show it in a Jpanel (like imshow)

One way to do this would be to use a BufferedImage as your canvas, and then draw Mats directly to the BufferedImage raster somehow. You can then just clone() the canvas to take a screenshot or you can just copy the pixels for the area that is the webcam area.

2015-02-26 08:59:27 -0600 received badge  Critic (source)
2015-02-26 08:55:44 -0600 received badge  Supporter (source)
2015-02-26 08:52:39 -0600 commented question Image loads; Cannot put into array

Or something fast enough that it isn't one line, but does not use condition statements. To clarify, the canvas can only be instantiated as new MatrixCanvas() {... TYPE_4BYTE_ABGR ...}

2015-02-26 08:51:10 -0600 commented question Image loads; Cannot put into array

That is too CPU intensive to run at 60 fps. I need a one-liner that will set the data in a BufferedImage that is the size of the JFrame it is in. Currently, your m.get(0,0,((DataBufferByte)image.getRaster().getDataBuffer()).getData()); works, but it shows up as two rows of pixels rather than an image. I need the fastest way to copy data from a Mat into what is now a TYPE_4BYTE_ABGR. I changed the type to allow alpha. I noticed the method BufferedImage.getRaster().setPixels(x, y, w, h, iArray); which sets a part or the whole thing to some pixels. Simply using setPixels(x, y, Raster) would just copy the pixels in without formation and so that is why it is two lines instead of 16x16.

2015-02-26 08:29:25 -0600 commented question Image loads; Cannot put into array

Your optimization makes it 1 line for my method. Also, it works! I mean it doesn't draw correctly, but it works! Probably a problem somewhere between types but... it works! Thanks again :)

2015-02-26 08:21:43 -0600 commented question Image loads; Cannot put into array

Yeah I probably should try byte. int didn't work. It still gives an error.

2015-02-26 07:18:38 -0600 received badge  Editor (source)
2015-02-26 07:15:50 -0600 asked a question Image loads; Cannot put into array

This loads just fine:

    private Mat m = Imgcodecs.imread("C:/Users/Link/workspace/G3DExperiment/src/imgres/stone.png");

But for some reason I can't load it into an array:

public void draw(Mat mat, int x, int y) {
    int rows = mat.rows(), cols = mat.cols(), type = CvType.channels(mat.type());
    int[] bgr = new int[rows*cols*type];
    mat.get(0, 0, bgr);
    canvas.setRGB(x, y, cols, rows, bgr, 0, width);
}

canvas is a BufferedImage of type TYPE_3BYTE_BGR and this method MatrixCanvas#draw(Mat, int, int) is used to draw a Mat directly onto the screen by covering the screen in a BufferedImage and setting the pixels on the image.

The full stacktrace reads:

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Mat data type is not compatible: 16
at org.opencv.core.Mat.get(Mat.java:2599)
at genesis.g2D.MatrixCanvas.draw(MatrixCanvas.java:158)
at g.Main.<init>(Main.java:49)
at g.Main.<init>(Main.java:42)
at g.Main$1.run(Main.java:37)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
2015-02-23 09:18:23 -0600 commented question Scale rows and/or cols of Mat

Thank you @berak.

2015-02-23 09:12:34 -0600 commented question Scale rows and/or cols of Mat

@berak scales rows and cols one by one

2015-02-23 09:06:26 -0600 asked a question Scale rows and/or cols of Mat

I am using OpenCV 3.0.0 beta and I'm wondering if there is an OpenCV method that scales individual rows and cols, or if there are methods that will help me to do this.

What I am trying to do is a 3D rotation on a 2D image in a Mat by scaling the rows or columns according to a slope. This will give it perspective.

I'm creating the fastest possible algorithms, so speed is key here, and I would prefer to use only OpenCV methods, no Java as Java would slow down the process. I'm not saying that I can't use Java, I'm saying I don't want to use anything intense like loops in Java for the purpose of this project.

Above all: is there an OpenCV method that scales individual rows and cols, or are there methods that will help me to do this?