Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading webcam resolution
05-12-2014, 09:02 PM
Post: #4
RE: Reading webcam resolution
A little update... Before I posted this question I had sent Boian an Emil asking almost the same question. He pointed me to VLDSCapture1->VideoModes which I was able to figure out and worked great.

Below is the code I ended up with, it populates a TComboBox I named ResolPickBox and stores the actual height and width numbers in a struct. I was only interested in 640x480 and above with an aspect of 1.33.

The aspect was converted to a string to provide consistent truncation of the decimal places for a comparison to what I was looking for.

One thing I didn't (and still don't) understand is without the line that looks for a duplicate entry I get two sets of identical resolution numbers. I looked at the other data fields returned in TVLVideoModeFormat and couldn't find anything that was different between the duplicate listings. For example, Format returned vfRGB24 in all cases.

Code:
void TCamera::GetCamResolutions(void)
{
float w, h, a;
int index, i;
String str;
char resol[41];
typedef struct WcResStruct {
        int WcHeight;
        int WcWidth;
        }WcResol;

    WcResol WcRes[10];
    index = 0;
    for(i = 0; i < VLDSCapture1->VideoModes->Count; i++) {
        h = VLDSCapture1->VideoModes->Items[i]->Height;
        w = VLDSCapture1->VideoModes->Items[i]->Width;
        a = w / h; // Get aspect
        str = str.FloatToStrF(a, AnsiString::sffFixed, 4, 2);
        if(str == "1.33"){ // Have aspect we are looking for
            if(w >= 640){  // Not interested in anything below 640x480
                if(index > 0 && WcRes[index - 1].WcHeight > VLDSCapture1->VideoModes->Items[i]->Height)
                    break;  // Only get first set of numbers
                WcRes[index].WcHeight = VLDSCapture1->VideoModes->Items[i]->Height;
                WcRes[index].WcWidth = VLDSCapture1->VideoModes->Items[i]->Width;
                sprintf(resol, "%d X %d", WcRes[index].WcWidth, WcRes[index].WcHeight);
                ResolPickBox->Items->Add(resol);
                index++;
            }
        }
    }
Quote this message in a reply
Post Reply 


Messages In This Thread
Reading webcam resolution - BReeves - 05-03-2014, 09:14 PM
RE: Reading webcam resolution - Dave - 05-04-2014, 01:06 AM
RE: Reading webcam resolution - BReeves - 05-06-2014, 08:40 PM
RE: Reading webcam resolution - BReeves - 05-12-2014 09:02 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)