Hello.
I'm doing a pluging which crops an image and after saves the image into a file. I've got the crop-filter.c as a basis and added saving image using opencv:
std::lock_guard<std::mutex> l(filter->texrender_mutex);
width = filter->width;
height = filter->height;
linesize = filter->linesize;
if (filter->ready && filter->data != NULL)
{
data = (uint8_t*)bzalloc(linesize * height);
memcpy(data, filter->data, linesize * height);
filter->ready = false;
}
cv::Mat image(height, width, CV_8UC4, data);
bool b = cv::imwrite("c:\\Lang\\Programs\\temp\\some.jpg", image);
It works and the result file is good until I cut the images. After the image is black or wrong.
Here is the getting image data for opencv:
uint8_t *data;
uint32_t linesize;
gs_stage_texture(filter->staging_texture, tex);
if (gs_stagesurface_map(filter->staging_texture, &data, &linesize))
{
memcpy(filter->data, data, linesize * filter->height);
filter->linesize = linesize;
filter->ready = true;
gs_stagesurface_unmap(filter->staging_texture);
}
I do it in the render function after cutting the image. What's wrong here? Why the result image is wrong when I cut it?
I'm doing a pluging which crops an image and after saves the image into a file. I've got the crop-filter.c as a basis and added saving image using opencv:
std::lock_guard<std::mutex> l(filter->texrender_mutex);
width = filter->width;
height = filter->height;
linesize = filter->linesize;
if (filter->ready && filter->data != NULL)
{
data = (uint8_t*)bzalloc(linesize * height);
memcpy(data, filter->data, linesize * height);
filter->ready = false;
}
cv::Mat image(height, width, CV_8UC4, data);
bool b = cv::imwrite("c:\\Lang\\Programs\\temp\\some.jpg", image);
It works and the result file is good until I cut the images. After the image is black or wrong.
Here is the getting image data for opencv:
uint8_t *data;
uint32_t linesize;
gs_stage_texture(filter->staging_texture, tex);
if (gs_stagesurface_map(filter->staging_texture, &data, &linesize))
{
memcpy(filter->data, data, linesize * filter->height);
filter->linesize = linesize;
filter->ready = true;
gs_stagesurface_unmap(filter->staging_texture);
}
I do it in the render function after cutting the image. What's wrong here? Why the result image is wrong when I cut it?