Reputation: 55
I've made some modifications to https://github.com/NVIDIA/video-sdk-samples/tree/master/nvEncDXGIOutputDuplicationSample to convert the desktop image to a cv mat.
I have a dx11 2d texture and I want the 640x640 center of the texture (cropping in opencv is slow). CopySubresourceRegion (https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-copysubresourceregion) works until I pass a D3D11_BOX. When I convert it to a cv mat, it's just a black screen.
my_box.left = 1600;
my_box.top = 480;
my_box.right = 1600;
my_box.bottom = 480;
Can anyone give me a hint as to what I might be missing?
Upvotes: 1
Views: 414
Reputation: 55
So there's a lot of x/y box options out there. I initially thought this was negatives. As in, you will define the area to not cap and you get the inverse. This is a very popular approach. This is a little goofier than that.
So lets say you want center. That's dimension(so w or h)/2-desired_box_size/2. The answer you get on each of these will be left and top. From here, you'll just add however much to get the box size. For a 3840 by 1600 monitor with a 640x640 crop your box looks like this:
my_box.front = 0;
my_box.back = 1;
my_box.left = 1600;
my_box.top = 480;
my_box.right = 2240;
my_box.bottom = -160;
Note front and back. The box is 3d as it says, but since we're working with a 2d text, we want to go 1 pixel deep. As stated in the docs, it's going to be back-front.
Upvotes: 1