Giter Site home page Giter Site logo

Comments (5)

qwonderkid avatar qwonderkid commented on August 11, 2024 1
public class GPUPixelSourceRawInput extends GPUPixelSource {
    public GPUPixelSourceRawInput() {
        if (mNativeClassID != 0) return;
        GPUPixel.getInstance().runOnDraw(new Runnable() {
            @Override
            public void run() {
                mNativeClassID = GPUPixel.nativeSourceRawInputNew();
            }
        });
    }

    public void SetRotation(int rotation)
    {
        GPUPixel.nativeSourceRawInputSetRotation(mNativeClassID, rotation);
    }

    public void uploadBytes(final int[] pixels, int width, int height, int stride) {
        GPUPixel.nativeSourceRawInputUploadBytes(mNativeClassID, pixels, width, height, stride);
        proceed(true, false);
    }

}

I think it should be

public class GPUPixelSourceRawInput extends GPUPixelSource {
    public GPUPixelSourceRawInput() {
        if (mNativeClassID != 0) return;
        mNativeClassID = GPUPixel.nativeSourceRawInputNew();
    }

    public void SetRotation(int rotation)
    {
        GPUPixel.nativeSourceRawInputSetRotation(mNativeClassID, rotation);
    }

    public void uploadBytes(final int[] pixels, int width, int height, int stride) {
        GPUPixel.nativeSourceRawInputUploadBytes(mNativeClassID, pixels, width, height, stride);
        proceed(true, false);
    }

}
extern "C" jlong Java_com_pixpark_gpupixel_GPUPixel_nativeSourceRawInputNew(
    JNIEnv* env,
    jclass) {
  return 0;
};

--->

extern "C" jlong Java_com_pixpark_gpupixel_GPUPixel_nativeSourceRawInputNew(
    JNIEnv* env,
    jclass) {
  return SourceRawDataInput();
};

I tried to make edits on it, but the uploadBytes function isn't working.

It sounds like GPUPixelContext::getInstance()->runSync is supposed to create an eglContext if needed, but when I call this method, I encounter a rendering thread error.

If you encounter a rendering thread error with that function, you may try manually setup GL. I managed to run it on windows.
void InitIO()
{
window = GPUPixelContext::getInstance()->GetGLContext();

if (window == NULL) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return;
}

glfwMakeContextCurrent(window);

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout << "Failed to initialize GLAD" << std::endl;
return;
}

GPUPixelContext::getInstance()->runSync([&] {
face_reshape_filter_ = FaceReshapeFilter::create();
beauty_face_filter_ = BeautyFaceFilter::create();
source_raw_input = SourceRawDataInput::create();
target_raw_data_output = TargetRawDataOutput::create();

source_raw_input->RegLandmarkCallback([=](std::vector<float> landmarks) {
  face_reshape_filter_->SetFaceLandmarks(landmarks);
});
source_raw_input->addTarget(face_reshape_filter_)
    ->addTarget(target_raw_data_output);

});
target_raw_data_output->setPixelsCallbck(
[=](const uint8_t* data, int width, int height, int64_t timestamp) {
cv::Mat output(height, width, CV_8UC4, (void*)data);
showmat = output;
std::cout << "target output callback" << endl;
});
}

from gpupixel.

qwonderkid avatar qwonderkid commented on August 11, 2024

Raw data can be obtained through readPixelsWithPBO and rawOutputCallback

Seems that the TargetRawOutput class has not been implemented yet, could you provide some reference or examples?

from gpupixel.

qwonderkid avatar qwonderkid commented on August 11, 2024

Raw data can be obtained through readPixelsWithPBO and rawOutputCallback

Seems that the TargetRawOutput class has not been implemented yet, could you provide some reference or examples?

sourceRawDataInput->uploadBytes(width, height, dataY, strideY, dataU, strideUV, dataV, strideUV, timestamp);
isExpect=true;
targetRawDataOutput->readPixelsWithPBO(width,height);
……
……
……
void rawOutputCallback(const uint8_t* data, int width, int height, int64_t ts)
{
     if(!isExpect){
     return;
     }
    //obtain yuv data
}

Yeah I know how to use it in c++, but not good at writing jni and android codes. The example provided by GPUPixel has not implemented targetrawdataoutput class in jni and java, that's the problem. Anyway, thanks for the answer.

from gpupixel.

buiduylinh avatar buiduylinh commented on August 11, 2024
public class GPUPixelSourceRawInput extends GPUPixelSource {
    public GPUPixelSourceRawInput() {
        if (mNativeClassID != 0) return;
        GPUPixel.getInstance().runOnDraw(new Runnable() {
            @Override
            public void run() {
                mNativeClassID = GPUPixel.nativeSourceRawInputNew();
            }
        });
    }

    public void SetRotation(int rotation)
    {
        GPUPixel.nativeSourceRawInputSetRotation(mNativeClassID, rotation);
    }

    public void uploadBytes(final int[] pixels, int width, int height, int stride) {
        GPUPixel.nativeSourceRawInputUploadBytes(mNativeClassID, pixels, width, height, stride);
        proceed(true, false);
    }

}

I think it should be

public class GPUPixelSourceRawInput extends GPUPixelSource {
    public GPUPixelSourceRawInput() {
        if (mNativeClassID != 0) return;
        mNativeClassID = GPUPixel.nativeSourceRawInputNew();
    }

    public void SetRotation(int rotation)
    {
        GPUPixel.nativeSourceRawInputSetRotation(mNativeClassID, rotation);
    }

    public void uploadBytes(final int[] pixels, int width, int height, int stride) {
        GPUPixel.nativeSourceRawInputUploadBytes(mNativeClassID, pixels, width, height, stride);
        proceed(true, false);
    }

}
extern "C" jlong Java_com_pixpark_gpupixel_GPUPixel_nativeSourceRawInputNew(
    JNIEnv* env,
    jclass) {
  return 0;
};

--->

extern "C" jlong Java_com_pixpark_gpupixel_GPUPixel_nativeSourceRawInputNew(
    JNIEnv* env,
    jclass) {
  return SourceRawDataInput();
};

I tried to make edits on it, but the uploadBytes function isn't working.

It sounds like GPUPixelContext::getInstance()->runSync is supposed to create an eglContext if needed, but when I call this method, I encounter a rendering thread error.

from gpupixel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.