cvtColor/resize with deque

Hi, I have trouble getting my head around image processing and containers
I basically use threads to capture screen/process images(color/resize)
and use deque containers to stock images !

I basically dequeVar.pushfront and popback when the container exceed 25
and I just basically want to use cvtColor/resize

cvtColor(mat1_buffer.front(), mat1processed_buffer.front(), COLOR_BGRA2BGR);
and it just don’t work idk why !

Could anyone explain what is the best way to exchange resources between threads
and a way to turn off logging would be really great

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/core/utility.hpp>
#include <iostream>
#include <Windows.h>
#include <thread>
#include <deque>
#include <mutex>
#include <condition_variable>
#include <opencv2/core/utils/logger.hpp>

using namespace std;
using namespace cv;

// mat1 = background mat2 = target
Mat ore_mat = imread(R"(C:\Users\Ethernel\Desktop\iron_ore.png)", IMREAD_UNCHANGED);
deque<Mat> mat1_buffer, mat1processed_buffer;

// Global State Vars
mutex mutexVar;
condition_variable condVar;
bool isBuffer_ready = false;
bool isBuffer_main_ready = false;

cv::Mat getMat(HWND hWND){
    HDC deviceContext = GetDC(hWND);
    HDC memoryDeviceContext = CreateCompatibleDC(deviceContext);
    RECT windowRect;
    GetClientRect(hWND, &windowRect);
    int height = windowRect.bottom;
    int width = windowRect.right;
    HBITMAP bitmap = CreateCompatibleBitmap(deviceContext, width, height);
    SelectObject(memoryDeviceContext, bitmap);
    BitBlt(memoryDeviceContext, 0, 0, width, height, deviceContext, 0, 0, SRCCOPY);
    bi.biSize = sizeof(BITMAPINFOHEADER);
    bi.biWidth = width;
    bi.biHeight = -height;
    bi.biPlanes = 1;
    bi.biBitCount = 32;
    bi.biCompression = BI_RGB;
    bi.biSizeImage = 0; //because no compression
    bi.biXPelsPerMeter = 1;
    bi.biYPelsPerMeter = 2;
    bi.biClrUsed = 3;
    bi.biClrImportant = 4;
    Mat mat = Mat(height, width, CV_8UC4); // 8 bit unsigned ints 4 Channels -> RGBA
    //transform data and store into
    GetDIBits(memoryDeviceContext, bitmap, 0, height,, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
    //clean up!
    DeleteDC(memoryDeviceContext); //delete not release!
    ReleaseDC(hWND, deviceContext);
    return mat;

void getScreen(){
        isBuffer_ready = true;
        cvtColor(mat1_buffer.front(), mat1processed_buffer.front(), COLOR_BGRA2BGR);

void cvtColorMat(){
        while(isBuffer_main_ready == true){
            cvtColor(mat1_buffer.front(), mat1processed_buffer.front(), COLOR_BGRA2BGR);

void printDebug(){
        cout << "[MAT1CONTAINER]            Size: " << mat1_buffer.size() << endl;
        cout << "[MAT1PROCESSEDCONTAINER]   Size: " << mat1processed_buffer.size() << endl;

void clearBuffer(){
        while(mat1_buffer.size() > 25){

int main(int argc, char** argv) {

    thread getScreen_t = thread(getScreen);
    isBuffer_main_ready = true;
    if(mat1_buffer.size() > 10){
        thread printDebug_t = thread(printDebug);
        thread clearBuffer_t = thread(clearBuffer);


what makes you think it didn’t work? do not ever wait to be asked, just deliver the relevant information immediately. please review [mre].

this isn’t a forum for general programming. if you need help using threads and communication primitives (queues), that’s out of scope for this forum.

a little hint though: think about what you wrote in your main() function…

I forgot to start the threads, I didn’t realize that It was an older copy-paste
But still it would be really helpful about this
#include <opencv2/core/utils/logger.hpp>
“Unknown type name ‘setLogLevel’”

that’s a namespace problem:

LogLevel 	cv::utils::logging::setLogLevel (LogLevel logLevel)

not a namespace problem.

that’s OP trying to write a function call outside of any function… right below the includes. the compiler only expects definitions there (types, global vars, functions, classes, …) but not actual function calls. OP needs to go back to reviewing basic C++ programming.

Basically, I’m i’ve been using C++ for 5days so yeah I’m learning

Okey, after retrying with cv::resize
I’m trying to get the processed image from cvtColor/resize to my deque container
I just can’t find a way