int main(int argc, char *argv[]) { SamplesDesctiptors descriptors = ParseDescriptors(TRAIN_IMAGES + GENDERS_FILENAME); cv::Mat features(descriptors.size(), THUMBNAIL_SIZE.width * THUMBNAIL_SIZE.height, CV_32FC1); cv::Mat targets(descriptors.size(), 1, CV_32SC1); std::cout << "Parsing data" << std::endl; MakeData(descriptors, &features, &targets); CvSVM svm; std::cout << "Learning" << std::endl; Learn(features, targets, &svm); std::cout << "Saving model" << std::endl; svm.save(GENDERMODEL_FILENAME); // std::cout << QFoldTest(features, targets, 10) << std::endl; return 0; }
bool USBDevice::InitDevice() { BYTE configDescriptorBuffer[4096]; ULONG lengthTransferred; m_deviceMutex = CreateMutex(NULL, FALSE, "Global\\ASIOUAC2"); if(GetLastError() == ERROR_ALREADY_EXISTS) { #ifdef _DEBUG debugPrintf("ASIOUAC: Can't start device! Device already used!\n"); #endif if(m_deviceMutex) { CloseHandle(m_deviceMutex); m_deviceMutex = NULL; m_errorCode = ERROR_BUSY; } return FALSE; } FreeDevice(); InitDescriptors(); m_usbDeviceHandle = FindDevice(); if(m_usbDeviceHandle == NULL) return FALSE; lengthTransferred = sizeof(configDescriptorBuffer); if(!UsbK_QueryDeviceInformation( m_usbDeviceHandle, DEVICE_SPEED, &lengthTransferred, configDescriptorBuffer)) { m_errorCode = GetLastError(); #ifdef _DEBUG debugPrintf("ASIOUAC: UsbK_QueryDeviceInformation failed. ErrorCode: %08Xh\n", m_errorCode); #endif UsbK_Free(m_usbDeviceHandle); m_usbDeviceHandle = NULL; return FALSE; } m_deviceSpeed = (int)configDescriptorBuffer[0]; #ifdef _DEBUG if(m_deviceSpeed == HighSpeed) debugPrintf("ASIOUAC: Device speed: high\n"); else debugPrintf("ASIOUAC: Device speed: low/full\n"); #endif if(!UsbK_GetDescriptor(m_usbDeviceHandle, USB_DESCRIPTOR_TYPE_DEVICE, 0, 0, configDescriptorBuffer, sizeof(configDescriptorBuffer), &lengthTransferred)) { m_errorCode = GetLastError(); #ifdef _DEBUG debugPrintf("ASIOUAC: Get device descriptor failed. ErrorCode: %08Xh\n", m_errorCode); #endif UsbK_Free(m_usbDeviceHandle); m_usbDeviceHandle = NULL; return FALSE; } memcpy(&m_deviceDescriptor, configDescriptorBuffer, sizeof(USB_DEVICE_DESCRIPTOR)); if(SendUsbControl(BMREQUEST_DIR_DEVICE_TO_HOST, BMREQUEST_TYPE_STANDARD, BMREQUEST_RECIPIENT_DEVICE, USB_REQUEST_GET_DESCRIPTOR, (USB_DESCRIPTOR_TYPE_CONFIGURATION << 8), 0, configDescriptorBuffer, sizeof(configDescriptorBuffer), &lengthTransferred)) { ParseDescriptors(configDescriptorBuffer, lengthTransferred); return m_usbDeviceHandle != NULL; } else { m_errorCode = GetLastError(); #ifdef _DEBUG debugPrintf("ASIOUAC: Get config descriptor failed. ErrorCode: %08Xh\n", m_errorCode); #endif UsbK_Free(m_usbDeviceHandle); m_usbDeviceHandle = NULL; return FALSE; } }