theblackplague / dynosharp Goto Github PK
View Code? Open in Web Editor NEWPlay Chrome's "No Internet" Dino Game using Computer Vision.
License: MIT License
Play Chrome's "No Internet" Dino Game using Computer Vision.
License: MIT License
The object has been closed.
at Windows.Graphics.Capture.Direct3D11CaptureFrame.get_Surface()
DynoSharp/DynoSharp/FramePool.cs
Line 56 in ad11029
DynoSharp/DynoSharp/FramePool.cs
Lines 181 to 214 in 0272773
Above is the function used to convert a Direct3DCaptureFrame
to a opencvsharp::Mat
. The point of this is so Dyno# can use the frame with the popular Computer Vision library, OpenCV.
The process for conversion is as follows: Direct3DCaptureFrame
-> SharpDX::Texture2D
-> byte[]
which is then referenced by the Mat.
I don't believe anything is going wrong with converting it into a Texture2D
, although you're welcome to read the conversion method for that here:
DynoSharp/DynoSharp/FramePool.cs
Lines 42 to 86 in 0272773
But I do believe something is going wrong in the conversion to a byte[]
from Texture2D
. The conversation is done using memcpy
, by literally using pointers to copy the memory into the byte[]
.
I first map the memory then set relevant pointers to both the mapped memory and byte[]
. The capture format is B8G8R8A8_UNorm
(1 byte per 4 values) so I believe a stride of the width * 4
would work best, correct me if I'm wrong. Afterwards, I loop over the height, copying memory across into a byte[]
. To parallelize the process, I use some math here (which is probably where something is going wrong, so if you can recheck it, please do).
Mapping memory:
DynoSharp/DynoSharp/FramePool.cs
Lines 134 to 135 in 0272773
Establishing byte[]
:
DynoSharp/DynoSharp/FramePool.cs
Line 144 in 0272773
Copying memory:
DynoSharp/DynoSharp/FramePool.cs
Lines 159 to 168 in 0272773
and
DynoSharp/DynoSharp/FramePool.cs
Lines 88 to 117 in 0272773
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.