Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to make an array from a screen capture for avi

I have used the info in this link. To build the base of the screen capture tool. https://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat/14167433#14167433

I have the imshow working fine along with imwrite. I added the codec for the video write. The understanding is: videowriter processes frames. The src is returned as the "frame". I tried using video.write(InputArray(src)); but that also didn't work. Using python numpy builds the array frame that write reads from. Would it be possible to add src to the Video Capture?

How to make an array from a screen capture for avi

I have used the info in this link. To build the base of the screen capture tool. https://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat/14167433#14167433

I have the imshow working fine along with imwrite. I added the codec for the video write. The understanding is: videowriter processes frames. The src is returned as the "frame". I tried using video.write(InputArray(src)); but that also didn't work. Using python numpy builds the array frame that write reads from. Would it be possible to add src to the Video Capture?

How to make an array from a screen capture for aviavi for c++

I have used the info in this link. To build the base of the screen capture tool. https://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat/14167433#14167433

I have the imshow working fine along with imwrite. I added the codec for the video write. The understanding is: videowriter processes frames. The src is returned as the "frame". I tried using video.write(InputArray(src)); but that also didn't work. Using python numpy builds the array frame that write reads from. Would it be possible to add src to the Video Capture?

int main(int argc, char** argv)
{
std::cout << "Starting Script" << std::endl;
HWND hwndDesktop = GetDesktopWindow(); //FindWindowEx();
namedWindow("output", WINDOW_NORMAL);
int key = 0;
Mat src = hwnd2mat(hwndDesktop); // src =frame
VideoWriter video("out.avi", cv::VideoWriter::fourcc('X', 'V', 'I', 'D'), 10, Size(src.size()), true); // ctlHeight, ctlWidth
int count = 0;
//video.open();
while (key != 27)
//for(;;)
{

    // InputArray img = src;
    video.write(src);
    //count++;
    //imwrite("outer.jpg", src);
    imshow("output", src);
    key = waitKey(60); // you can change wait time
}
exception();
//ReleaseCapture();
//video.release();
//destroyAllWindows();
return 0;
}

The above is how I am trying to make the capture into a video.

In python to create the array that is passed to the VideoWriter::Write(); looks like the following:

 while(True):
    img = ImageGrab.grab(bbox=(0, 0, width, height))#testSpec: bbox=(0, 0, 800, 1000)
    img_np = np.array(img)

I have tried using the InputArray() included in opencv so the write looks more like:

video.write(InputArray(src));

Which should be similar to

video.write(img_np)

Either way, the above imshow() works perfectly. The Imwrite() works perfectly. but the AVI will not write anything. It creates the file but it is empty.

How to make an array from a screen capture for avi for c++

I have used the info in this link. To build the base of the screen capture tool. https://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat/14167433#14167433

I have the imshow working fine along with imwrite. I added the codec for the video write. The understanding is: videowriter processes frames. The src is returned as the "frame". I tried using video.write(InputArray(src)); but that also didn't work. Using python numpy builds the array frame that write reads from. Would it be possible to add src to the Video Capture?

int main(int argc, char** argv)
{
std::cout << "Starting Script" << std::endl;
HWND hwndDesktop = GetDesktopWindow(); //FindWindowEx();
namedWindow("output", WINDOW_NORMAL);
int key = 0;
Mat src = hwnd2mat(hwndDesktop); // src =frame
VideoWriter video("out.avi", cv::VideoWriter::fourcc('X', 'V', 'I', 'D'), 10, Size(src.size()), true); // ctlHeight, ctlWidth
int count = 0;
//video.open();
while (key != 27)
//for(;;)
{

    // InputArray img = src;
    video.write(src);
    //count++;
    //imwrite("outer.jpg", src);
    imshow("output", src);
    key = waitKey(60); // you can change wait time
}
exception();
//ReleaseCapture();
//video.release();
//destroyAllWindows();
return 0;
}

The above is how I am trying to make the capture into a video.

In python to create the array that is passed to the VideoWriter::Write(); looks like the following:

 while(True):
    img = ImageGrab.grab(bbox=(0, 0, width, height))#testSpec: bbox=(0, 0, 800, 1000)
    img_np = np.array(img)

I have tried using the InputArray() included in opencv so the write looks more like:

video.write(InputArray(src));

Which should be similar to

video.write(img_np)

Either way, the above imshow() works perfectly. The Imwrite() works perfectly. but the AVI will not write anything. It creates the file but it is empty.

I also get the error of: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): out.avi in function 'cv::icvExtractPattern

How to make an array from a screen capture for avi for c++

I have used the info in this link. To build the base of the screen capture tool. https://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat/14167433#14167433

I have the imshow working fine along with imwrite. I added the codec for the video write. The understanding is: videowriter processes frames. The src is returned as the "frame". I tried using video.write(InputArray(src)); but that also didn't work. Using python numpy builds the array frame that write reads from. Would it be possible to add src to the Video Capture?

int main(int argc, char** argv)
{
std::cout << "Starting Script" << std::endl;
HWND hwndDesktop = GetDesktopWindow(); //FindWindowEx();
namedWindow("output", WINDOW_NORMAL);
int key = 0;
Mat src = hwnd2mat(hwndDesktop); // src =frame
VideoWriter video("out.avi", cv::VideoWriter::fourcc('X', 'V', 'I', 'D'), 10, Size(src.size()), true); // ctlHeight, ctlWidth
int count = 0;
//video.open();
while (key != 27)
//for(;;)
{

    // InputArray img = src;
    video.write(src);
    //count++;
    //imwrite("outer.jpg", src);
    imshow("output", src);
    key = waitKey(60); // you can change wait time
}
exception();
//ReleaseCapture();
//video.release();
//destroyAllWindows();
return 0;
}

The above is how I am trying to make the capture into a video.

In python to create the array that is passed to the VideoWriter::Write(); looks like the following:

 while(True):
    img = ImageGrab.grab(bbox=(0, 0, width, height))#testSpec: bbox=(0, 0, 800, 1000)
    img_np = np.array(img)

I have tried using the InputArray() included in opencv so the write looks more like:

video.write(InputArray(src));

Which should be similar to

video.write(img_np)

Either way, the above imshow() works perfectly. The Imwrite() works perfectly. but the AVI will not write anything. It creates the file but it is empty.

I also get the error of: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): out.avi in function 'cv::icvExtractPattern

Windows10 vcpkg install 4.1.1

How to make an array from a screen capture for avi for c++

I have used the info in this link. To build the base of the screen capture tool. https://stackoverflow.com/questions/14148758/how-to-capture-the-desktop-in-opencv-ie-turn-a-bitmap-into-a-mat/14167433#14167433

I have the imshow working fine along with imwrite. I added the codec for the video write. The understanding is: videowriter processes frames. The src is returned as the "frame". I tried using video.write(InputArray(src)); but that also didn't work. Using python numpy builds the array frame that write reads from. Would it be possible to add src to the Video Capture?

int main(int argc, char** argv)
{
std::cout << "Starting Script" << std::endl;
HWND hwndDesktop = GetDesktopWindow(); //FindWindowEx();
namedWindow("output", WINDOW_NORMAL);
int key = 0;
Mat src = hwnd2mat(hwndDesktop); // src =frame
VideoWriter video("out.avi", cv::VideoWriter::fourcc('X', 'V', 'I', 'D'), 10, Size(src.size()), true); // ctlHeight, ctlWidth
int count = 0;
//video.open();
while (key != 27)
//for(;;)
{

    // InputArray img = src;
    video.write(src);
    //count++;
    //imwrite("outer.jpg", src);
    imshow("output", src);
    key = waitKey(60); // you can change wait time
}
exception();
//ReleaseCapture();
//video.release();
//destroyAllWindows();
return 0;
}

The above is how I am trying to make the capture into a video.

In python to create the array that is passed to the VideoWriter::Write(); looks like the following:

 while(True):
    img = ImageGrab.grab(bbox=(0, 0, width, height))#testSpec: bbox=(0, 0, 800, 1000)
    img_np = np.array(img)

I have tried using the InputArray() included in opencv so the write looks more like:

video.write(InputArray(src));

Which should be similar to

video.write(img_np)

Either way, the above imshow() works perfectly. The Imwrite() works perfectly. but the AVI will not write anything. It creates the file but it is empty.

I also get the error of: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): out.avi in function 'cv::icvExtractPattern

Windows10 vcpkg install 4.1.1