De-interlace captured video with DirectShow - c++

(Add KSPROPERTY_CAMERACONTROL_SCANMODE into KSPROPERTY_VIDCAP_CAMERACONTROL?)
Working with a webcam I'm getting an interlaced video. The access to that webcam is done with a DirectShow using videoInput library (as part of OpenCV).
I cannot find a way to control that (interlaced) mode with the currently available options/enums in the OpenCV so I diged into MSDN and found the following:
IAMCameraControl interface can be used to get/set various properties, as long as they are listed in PROPSETID_VIDCAP_CAMERACONTROL (http://msdn.microsoft.com/en-us/library/dd389145(v=vs.85).aspx#methods)
PROPSETID_VIDCAP_CAMERACONTROL lists 3 blocks of enums (one for "prior to USB video class, one for UVC, and one for Win8) and among those values there's the one I'm interested in! It's a KSPROPERTY_CAMERACONTROL_SCANMODE (http://msdn.microsoft.com/en-us/library/ff567802(v=vs.85).aspx)
I have Windows 7.a SDK installed and in the C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\strmif.h file what I see is a list of values that only covers the "original" set, which is pre-UVC, so it doesn't have the control for the interlaced mode. The enum in that file looks like this one from MSDN site: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318253(v=vs.85).aspx
Then I've found this forum where the person claims "I had to update the CameraControlProperty enumeration" to add the needed properties and it worked for him (http://sourceforge.net/p/directshownet/discussion/460697/thread/562ef6cf/)
My question is:
How? :) What does one do to add a needed value (or a bunch of values) that are supposedly supported by the system? What am I missing?
MSDN seems to be holding the cards close to its body and not revealing much, so I'm asking the good people in here for help.
I hope someone out there has figured out how to do that and can share the wisdom.
My ultimate goal is to use the OpenCV's videoInput's setVideoSettingCamera() to control the interlacing (so that the image I get doesn't have those black lines)

Related

How to get a list of available resolutions for every camera on Windows C++

I have multiple cameras in my Windows 11 system and I am wondering how to get all avaiable resolutions for them. I am not intending to make a video capture, but I am willing to just get these properties.
Also, I don't care which API to use, be it DirectShow or MMF (Microsoft Media Foundation).
I haven't used any of these before either.
I have found multiple resources doing that in C# (as in here), but similar suggested answers for C++ are hard to understand - some code is given, but what libraries and 'includes' used is not given (as in here)
I have also checked DirectShow samples in hope something would be there, but I didn't find anything.
So, I checked MMF as well (1, 2, 3) and docs, but all posts seem pretty outdated and no full code is given showing how to use certain functions alongside proper 'includes', as trying the code gives me unresolved symbols.
So I am kind of stuck at the moment, I can't find a solution to this.
I would appreciate any help.
Also, I don't care which API to use, be it DirectShow or MMF (Microsoft Media Foundation). I haven't used any of these before either.
You generally do care because the data might be different.
With Media Foundation, see How to Set the Video Capture Format
Call IMFMediaTypeHandler::GetMediaTypeCount to get the number of supported formats.
You might also want to have a look at Tanta:
Windows Media Foundation Sample Projects and sample code there.
With DirectShow, see Webcamera supported video formats in addition to links you found; you will have to sort out includes and libraries through, among SDK samples AMCap does some one this and can be built from source without additional external libraries, from original code or from this fork adopted to most recent VS.

What is the path from BITMAP[+WAVE(s)] to RTSP (Twitch) via C/C++ in Windows?

So I'm trying to get a basic tool to output video/audio(s) to Twitch. I'm new to this side (AV) of programming so I'm not even sure what to look for. I'm trying to use mainly Windows infrastructure and third party where not available.
What are the steps of getting raw bitmap and wave data into a codec and then into a rtsp client and finally showing up on Twitch? I'm not looking for code. I'm looking for concepts so I can search for as I'm not absolutely sure what to search for. I'd rather not go through OBS source code to figure it out and use that as last resort.
So I capture the monitor via Output Duplication and also the Sound on the system as a wave and the microphone as another wave. I'm trying to push this to Twitch. I know that there's Media Foundation on Windows but I don't know how far to streaming it can get as I assume there no netcode integrated in it? And also the libav* collection in FFMPEG.
What are the basic steps of sending bitmap/wave to Twitch via any of thee above libraries or even others as long as they work on Windows. Please don't add code, I just need a not very long conceptual explanation and I'll take it from there. Try to cover also how bitrate and framerate gets regulated (do I have do it or the codec does it)?
Assume absolute noob level in this area (concept-wise not code-wise).

Qt C++ video libraries

I'm looking for a video library for Qt 4 (C++/Windows) that has:
1) Basic video playback functionality
It should play all the common video formats such as DVD VOB and MP4/MKV/AVI (h264, xvid, divx). It should also be able to deinterlace the video automatically and display it in Display Aspect Ratio.
2) Cropping
It should have some basic functionality to remove black bars (user supplied arguments).
3) Snapshots
It should have functionality to take snapshots in memory.
4) Frame-by-frame seeking
It should have some basic functionality to do frame-by-frame seeking, e.g. prevFrame(), nextFrame(), jumpTo(frame) and getNumFrames().
I have tried the following and from what I could find the functionality they support:
Qt Phonon:
Yes. Plays all the needed formats and displays them correctly.
No.
No. Not implemented (returns empty image).
No.
QtFFmpegWrapper:
Partial. Does not deinterlace DVD VOBs. Does not display DVD VOBs in DAR.
No.
Yes.
Partial. Broken for MKV (h264).
Qt VLC:
Yes. Plays all the needed formats and displays them correctly.
Yes. Have not tried if it works though.
Partial. Only to disk. edit: QPixmap::grabWindow(player->videoWidget()->winId()) works.
No. Only by milliseconds.
Now I'm looking at QVision, which seems to have all of those features except for cropping. Maybe implementing cropping isn't that difficult. But I'm wondering if there's any other libraries I should look into? Or perhaps I missed something and they're possible with one of these libraries. Thanks.
You can consider Movie Player Gold SDK ActiveX 3.6 from ViscomSoft. I don't see cropping mentioned on their site but memory snapshots and frame-by-frame steps are among supported features.
I used their VideoEdit and Screen2Video SDKs in Windows Qt software, worked quite well.

Convert Movie to OpenNI *.oni video

The Kinect OpenNI library uses a custom video file format to store videos that contain rgb+d information. These videos have the extension *.oni. I am unable to find any information or documentation whatsoever on the ONI video format.
I'm looking for a way to convert a conventional rgb video to a *.oni video. The depth channel can be left blank (ie zeroed out). For example purposes, I have a MPEG-4 encoded .mov file with audio and video channels.
There are no restrictions on how this conversion must be made, I just need to convert it somehow! Ie, imagemagick, ffmpeg, mencoder are all ok, as is custom conversion code in C/C++ etc.
So far, all I can find is one C++ conversion utility in the OpenNI sources. From the looks of it, I this converts from one *.oni file to another though. I've also managed to find a C++ script by a phd student that converts images from a academic database into a *.oni file. Unfortunately the code is in spanish, not one of my native languages.
Any help or pointers much appreciated!
EDIT: As my usecase is a little odd, some explanation may be in order. The OpenNI Drivers (in my case I'm using the excellent Kinect for Matlab library) allow you to specify a *.oni file when creating the Kinect context. This allows you to emulate having a real Kinect attached that is receiving video data - useful when you're testing / developing code (you don't need to have the Kinect attached to do this). In my particular case, we will be using a Kinect in the production environment (process control in a factory environment), but during development all I have is a video file :) Hence wanting to convert to a *.oni file. We aren't using the Depth channel at the moment, hence not caring about it.
I don't have a complete answer for you, but take a look at the NiRecordRaw and NiRecordSynthetic examples in OpenNI/Samples. They demonstrate how to create an ONI with arbitrary or modified data. See how MockDepthGenerator is used in NiRecordSynthetic -- in your case you will need MockImageGenerator.
For more details you may want to ask in the openni-dev google group.
Did you look into this command and its associated documentation
NiConvertXToONI --
NiConvertXToONI opens any recording, takes every node within it, and records it to a new ONI recording. It receives both the input file and the output file from the command line.

how to use DirectShow to render audio in C++

I am just starting to learn DirectShow with C++. I need to use DirectShow to record the audio and write it to a WAV file on the disk. I heard from other people that Win 7 does not allow for rendering audio using DirectShow.
In addition, I would like to know how should I start with recoding audio using DirectShow with C++? If there is sample source, it would be great.
Thanks in advance.
I think you may have misunderstood these other people. Windows Media Foundation is aimed to be the successor of DirectShow, but DirectShow is still a very valid technology on Windows 7.
The easiest thing to accomplish what you want to do, is to get it right using the GraphEdit tool first ( I assume you want to do this programmatically).
Create a graph that contains your audio device, a WavDestFilter, and a file writer.
Source -> WavDest -> File Writer
Play the graph. Stop the graph and you should have created a .wav file with the recorded audio. If you can get this right, then you need to do the whole thing programmatically.
There are a couple of samples in the SDK that show you how to programmatically add filters to a graph and connect them, that should enable you to get started.
WRT the WavDestFilter, IIRC it might not be in all versions of the SDK, you'll have to find an appropriate one. You also need to build it, and regsvr32 it, so that it will show up in your list of available filters in GraphEdit.
If this all seems a bit much, I would read through the DirectShow documentation on MSDN to at least get an overview of DirectShow.