12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Emgu.CV;
- using Emgu.CV.Structure;
- namespace bbiwarg.InputProviders
- {
- class InputFrame
- {
- private int width;
- private int height;
- private int widthRawColor;
- private int heightRawColor;
- private Int16[] depthData;
- private Int16[] confidenceData;
- private float[] uvData;
- private byte[] rawColorData;
- public InputFrame(int width, int height, int widthRawColor, int heightRawColor, Int16[] depthData, Int16[] confidenceData, float[] uvData, byte[] rawColorData) {
- this.width = width;
- this.height = height;
- this.widthRawColor = widthRawColor;
- this.heightRawColor = heightRawColor;
- this.depthData = depthData;
- this.confidenceData = confidenceData;
- this.uvData = uvData;
- this.rawColorData = rawColorData;
- }
- public int getWidth() {
- return width;
- }
- public int getHeight() {
- return height;
- }
- public Int16 getDepthAt(int x, int y) {
- return depthData[y * width + x];
- }
- public Int16 getConfidenceAt(int x, int y) {
- return confidenceData[y * width + x];
- }
- public float getUAt(int x, int y)
- {
- return uvData[2 * (y * width + x) + 0];
- }
- public float getVAt(int x, int y)
- {
- return uvData[2 * (y * width + x) + 1];
- }
- public Color getColorAt(int x, int y) {
- float u = getUAt(x, y);
- float v = getVAt(x, y);
- if (u < 0 || v < 0)
- return Color.Black;
- int xInColorImage = (int)(u * widthRawColor) % widthRawColor;
- int yInColorImage = (int)(v * heightRawColor) % heightRawColor;
- return getRawColorAt(x,y);
- }
- public Color getRawColorAt(int x, int y) {
- int offset = 4 * (y * widthRawColor + x);
- byte alpha = rawColorData[offset + 3];
- byte red = rawColorData[offset + 2];
- byte green = rawColorData[offset + 1];
- byte blue = rawColorData[offset + 0];
- return Color.FromArgb(alpha, red, green, blue);
- }
- }
- }
|