Image is not getting saved when camera is enabled

asked 2020-03-09 01:56:15 -0600

updated 2020-03-09 22:08:49 -0600

supra56 gravatar image

We are unable to save image.webcam get enable but after click on space bar, image is not getting captured and showing below warning:

[ WARN:1] global C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

Please assist us to resolve this issue.

edit retag flag offensive close merge delete

Comments

1

add your code to the question, please

berak gravatar imageberak ( 2020-03-09 02:10:36 -0600 )edit
1
capture image gravatar imagecapture image ( 2020-03-09 06:49:07 -0600 )edit
1

It is very unreasonable to expect anyone to browse a repository and look for code that handles pressing of space bar and saving.

If you have visited here before (and you should have), you have noticed that people post a relevant portion of their code here, often after request.

mvuori gravatar imagemvuori ( 2020-03-10 01:18:59 -0600 )edit

Yes..i understood your concern but there is dependency of code on each other so for that reason i have share the entire repository.

capture image gravatar imagecapture image ( 2020-03-13 02:01:27 -0600 )edit

Please refer below code snippet:

private static BufferedImage matToBufferedImage(Mat original)
    {
        // init
        BufferedImage image = null;
        int width = original.width(), height = original.height(), channels = original.channels();
        byte[] sourcePixels = new byte[width * height * channels];
        original.get(0, 0, sourcePixels);

        if (original.channels() > 1)
        {
            image = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
        }
        else
        {
            image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
        }
        final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
        System.arraycopy(sourcePixels, 0, targetPixels, 0, sourcePixels.length);

        return imag
capture image gravatar imagecapture image ( 2020-03-13 02:14:38 -0600 )edit

Kindly help to resolve this issue.Please update.

capture image gravatar imagecapture image ( 2020-03-18 08:07:25 -0600 )edit

sorry to say so, but your question is "all garbage", and the code you show seems unrelated.

berak gravatar imageberak ( 2020-03-18 08:55:40 -0600 )edit