int main(int argc, char **argv) { if (argc != 2) { printf("Usage: %s [video device index]\n", argv[0]); return 0; } gtk_init(&argc, &argv); if (atoi(argv[1]) < 0) { ScreenDevice dev; dev.Init(1); CGui gui(dev); gui.CreateWindow(); return 0; } CamAbstractionLayerV4L cam; cam.Init(atoi(argv[1])); CDevice *pDevice = cam.GetDevice(); if (!pDevice) { printf("Cannot get device!\n"); return 0; } std::string deviceName = pDevice->GetDevId(); printf("device: %s selected\n", deviceName.c_str()); printDevCapabilities(deviceName); std::deque<DeviceInput> inputList; cam.GetInputList(inputList); printf("\n"); printf("This device has %u inputs\n", inputList.size()); printf("\n"); for (int index=0; index<inputList.size(); index++) printf("index: %u - name: %s\n", inputList[index].index, inputList[index].name.c_str()); printf("\n"); int selectedInput = 0; if (inputList.size() > 1) { printf("\n"); char szInput[10]; printf("\n"); printf("Choose input:\n"); printf("\n"); printf("Input: "); scanf("%s", szInput); selectedInput = atoi(szInput); cam.SelectInput(selectedInput); } printf("\"%s\" selected\n", inputList[selectedInput].name.c_str()); std::deque<PixFmt> pixFmtList; std::deque<FrameDimension> dimensionList; std::string pixFmtDesc; pDevice->GetSupportedPixelFmt(pixFmtList); printf("\n"); printf("This device supports %u types of pixel format\n", pixFmtList.size()); printf("We list them below:\n"); printf("\n"); unsigned uMenuItem = 0; for (unsigned i=0; i < pixFmtList.size(); i++) { pDevice->GetSupportedDimensions(pixFmtList[i], dimensionList); GetPixFmtDesc(pixFmtList[i], pixFmtDesc); for (unsigned j=0; j < dimensionList.size(); j++) printf("%u. %s - %ux%u\n", ++uMenuItem, pixFmtDesc.c_str(), dimensionList[j].uWidth, dimensionList[j].uHeight); printf("\n"); } unsigned standardsCount=0; cam.GetAnagStdCount(standardsCount); printf("\n"); printf("This device has %u standards\n", standardsCount); printf("\n"); if (standardsCount) { int stdCounter=0; std::deque<AnagVideoStd> allAvailableStds; for (int i=0; i<standardsCount; i++) { printf("Index: %u\n", i); std::deque<AnagVideoStd> videoStdList; cam.EnumAnagStd(i, videoStdList); for (int j=0; j<videoStdList.size(); j++) { printf("%u -", stdCounter); printStandardInfo(videoStdList[j]); allAvailableStds.push_back(videoStdList[j]); stdCounter++; } printf("\n"); } unsigned selectedStd=0; char szSelectedStd[10]; printf("\n"); printf("Choose analog video format: (0 - %u)\n", stdCounter-1); printf("\n"); printf("Format: "); scanf("%s", szSelectedStd); selectedStd = atoi(szSelectedStd); printf("You selected: "); printStandardInfo(allAvailableStds[selectedStd]); printf("\n"); cam.SelectAnagStd(allAvailableStds[selectedStd]); } char szWidth[10], szHeight[10]; unsigned uWidth = 0, uHeight = 0; printf("\n"); printf("Choose capture frame dimensions:\n"); printf("\n"); printf("Width: "); scanf("%s", szWidth); printf("Height: "); scanf("%s", szHeight); uWidth = atoi(szWidth); uHeight = atoi(szHeight); if ( (uWidth > 0) && (uWidth < MAX_FRAME_DIMENSION) && (uHeight > 0) && (uHeight < MAX_FRAME_DIMENSION)) { cam.SelectFormat(uWidth, uHeight, RGB24); cam.StartCapture(); CGui gui(cam); gui.CreateWindow(); cam.StopCapture(); cam.Close(); } else printf("Error: Width and Height should be in range 0 - %u\n", MAX_FRAME_DIMENSION); return 0; }