As the title states, I cannot get the SDK to connect to the camera. I’m using sony SDK v1.12.0 and a sony ILX-LR1. The Connect() function is throwing error code 32768 which when put to hexadecimal is 0x8000 which the source files for the SDK say is a generic error (with no additional context). I can get the camera info but not the device handle. I’ve made sure I have the right usb serial number, i’ve tried different ports, and I’ve tried casting to different types.
Any help would be greatly appreciated…
Here is my code:
#pragma once
#include "pch.h"
#include "CameraRemote_SDK.h"
#include "CrCommandData.h"
#include "CrDefines.h"
#include "CrTypes.h"
#include "CrImageDataBlock.h"
#include "ICrCameraObjectInfo.h"
#include "CrError.h"
#include "CrDeviceProperty.h"
#include "IDeviceCallback.h"
#include <cstring> // for memcpy
#include <memory> // for std::unique_ptr
#include <iostream> // for std::cerr
using namespace SCRSDK;
void MyDeviceCallback::OnConnected(SCRSDK::DeviceConnectionVersioin version) {
// Implementation of the callback
DeviceConnectionVersioin ver = version;
std::cout << "Device connected with version: " << version << std::endl;
}
void ConnectCamera(SCRSDK::ICrCameraObjectInfo *cam_info) {
MyDeviceCallback *cb = new MyDeviceCallback();
CrDeviceHandle hDev = NULL;
/*hDev = NULL;*/
std::cout << &cam_info << std::endl;
std::cout << cb << std::endl;
std::cout << hDev << std::endl;
CrError err = SCRSDK::Connect(cam_info, cb, &hDev);
if (err != SCRSDK::CrError_None) {
std::cerr << "Failed to connect camera: Error code " << err << std::endl;
}
else {
std::cout << "Connected to camera" << std::endl;
}
}
void InitSDK() {
bool ret = Init(0);
if (!ret) {
std::cerr << "Failed to initialize SDK" << std::endl;
}
}
void CreateUSBObject() {
unsigned char serial_ch[] = "D516000F44E5";
unsigned char* serialNum = &serial_ch[0];
std::cout << (unsigned char*)serialNum << std::endl;
SCRSDK::ICrCameraObjectInfo* pCam = nullptr;
CrError err = SCRSDK::CreateCameraObjectInfoUSBConnection(
&pCam,
SCRSDK::CrCameraDeviceModel_ILX_LR1,
(unsigned char*)serialNum);
if (pCam == nullptr) {
std::cout << "pcam is null" << std::endl;
return;
}
if (err != SCRSDK::CrError_None || pCam == nullptr) {
std::cerr << "Failed to create camera object info: Error code " << err << std::endl;
return;
}
ConnectCamera(pCam);
}
void setupCamera() {
// Setup
InitSDK();
CreateUSBObject();
}
void Terminate() {
SCRSDK::Release();
}