|
|
|
@ -24,12 +24,15 @@
|
|
|
|
|
#include <sys/system_properties.h>
|
|
|
|
|
#include <media/NdkImage.h>
|
|
|
|
|
#include <mat.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#ifdef USING_HDRPLUS
|
|
|
|
|
#include <hdrplus/hdrplus_pipeline.h>
|
|
|
|
|
#include <hdrplus2/include/HDRPlus.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "netcamera/netcamera.h"
|
|
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <cstdio>
|
|
|
|
@ -1405,8 +1408,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
mPath = path;
|
|
|
|
|
mOsds = osds;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USING_N938
|
|
|
|
|
if (photoInfo.mediaType == 0) {
|
|
|
|
|
// CameraPhotoCmd(time(NULL), channel, MOVE_PRESETNO, 0, type);
|
|
|
|
@ -1418,52 +1419,56 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
return true;
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
NdkCamera::CAMERA_PARAMS params;
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
|
|
|
|
|
params.sceneMode = mPhotoInfo.sceneMode;
|
|
|
|
|
params.autoFocus = mPhotoInfo.autoFocus;
|
|
|
|
|
params.autoExposure = mPhotoInfo.autoExposure;
|
|
|
|
|
params.focusTimeout = mPhotoInfo.focusTimeout * 1000;
|
|
|
|
|
params.exposureTime = mPhotoInfo.exposureTime;
|
|
|
|
|
params.sensitivity = mPhotoInfo.sensitivity;
|
|
|
|
|
params.compensation = mPhotoInfo.compensation;
|
|
|
|
|
params.orientation = mPhotoInfo.orientation;
|
|
|
|
|
params.zoom = mPhotoInfo.zoom;
|
|
|
|
|
params.zoomRatio = mPhotoInfo.zoomRatio;
|
|
|
|
|
params.requestTemplate = mPhotoInfo.requestTemplate;
|
|
|
|
|
params.awbMode = mPhotoInfo.awbMode;
|
|
|
|
|
params.wait3ALocked = mPhotoInfo.wait3ALocked;
|
|
|
|
|
params.burstRawCapture = mPhotoInfo.usingRawFormat;
|
|
|
|
|
params.burstCaptures = mPhotoInfo.burstCaptures;
|
|
|
|
|
if (params.requestTemplate <= 0 || params.requestTemplate > 5)
|
|
|
|
|
{
|
|
|
|
|
params.requestTemplate = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
if (photoInfo.ldrEnabled)
|
|
|
|
|
{
|
|
|
|
|
if (GpioControl::getLightAdc() > 1400)
|
|
|
|
|
{
|
|
|
|
|
params.autoExposure = 0;
|
|
|
|
|
params.exposureTime = 1200000000;
|
|
|
|
|
params.sensitivity = 1200;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
|
|
|
|
|
|
if (photoInfo.usbCamera)
|
|
|
|
|
if (photoInfo.cameraType == CAM_TYPE_USB || photoInfo.cameraType == CAM_TYPE_NET)
|
|
|
|
|
{
|
|
|
|
|
TurnOnOtg(NULL);
|
|
|
|
|
}
|
|
|
|
|
if (photoInfo.cameraType == CAM_TYPE_NET)
|
|
|
|
|
{
|
|
|
|
|
GpioControl::set12VEnable(true);
|
|
|
|
|
}
|
|
|
|
|
TurnOnCameraPower(NULL);
|
|
|
|
|
|
|
|
|
|
res = true;
|
|
|
|
|
if (mPhotoInfo.mediaType == 0 && mPhotoInfo.usingSysCamera == 0)
|
|
|
|
|
{
|
|
|
|
|
if ((mPhotoInfo.mediaType == 0) && ((mPhotoInfo.cameraType == CAM_TYPE_MIPI) || (mPhotoInfo.cameraType == CAM_TYPE_USB)))
|
|
|
|
|
{
|
|
|
|
|
NdkCamera::CAMERA_PARAMS params;
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
|
|
|
|
|
params.sceneMode = mPhotoInfo.sceneMode;
|
|
|
|
|
params.autoFocus = mPhotoInfo.autoFocus;
|
|
|
|
|
params.autoExposure = mPhotoInfo.autoExposure;
|
|
|
|
|
params.focusTimeout = mPhotoInfo.focusTimeout * 1000;
|
|
|
|
|
params.exposureTime = mPhotoInfo.exposureTime;
|
|
|
|
|
params.sensitivity = mPhotoInfo.sensitivity;
|
|
|
|
|
params.compensation = mPhotoInfo.compensation;
|
|
|
|
|
params.orientation = mPhotoInfo.orientation;
|
|
|
|
|
params.zoom = mPhotoInfo.zoom;
|
|
|
|
|
params.zoomRatio = mPhotoInfo.zoomRatio;
|
|
|
|
|
params.requestTemplate = mPhotoInfo.requestTemplate;
|
|
|
|
|
params.awbMode = mPhotoInfo.awbMode;
|
|
|
|
|
params.wait3ALocked = mPhotoInfo.wait3ALocked;
|
|
|
|
|
params.burstRawCapture = mPhotoInfo.usingRawFormat;
|
|
|
|
|
params.burstCaptures = mPhotoInfo.burstCaptures;
|
|
|
|
|
if (params.requestTemplate <= 0 || params.requestTemplate > 5)
|
|
|
|
|
{
|
|
|
|
|
params.requestTemplate = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
if (photoInfo.ldrEnabled)
|
|
|
|
|
{
|
|
|
|
|
if (GpioControl::getLightAdc() > 1400)
|
|
|
|
|
{
|
|
|
|
|
params.autoExposure = 0;
|
|
|
|
|
params.exposureTime = 1200000000;
|
|
|
|
|
params.sensitivity = 1200;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
mCamera = new CPhoneCamera(this, photoInfo.width, photoInfo.height, params);
|
|
|
|
|
// mCamera = new CJpegCamera(this, photoInfo.width, photoInfo.height, mPath, params);
|
|
|
|
|
if (mCamera->open(to_string(mPhotoInfo.cameraId)) == 0)
|
|
|
|
@ -1490,6 +1495,62 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
RestartApp(REBOOT_TYPE_APP, 60000, "FatalErrorOnCamera");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((mPhotoInfo.mediaType == 0) && (mPhotoInfo.cameraType == CAM_TYPE_NET))
|
|
|
|
|
{
|
|
|
|
|
// Start Thread
|
|
|
|
|
CPhoneDevice* pThis = this;
|
|
|
|
|
|
|
|
|
|
vector<IDevice::OSD_INFO> osds;
|
|
|
|
|
osds.swap(mOsds);
|
|
|
|
|
IDevice::PHOTO_INFO localPhotoInfo = mPhotoInfo;
|
|
|
|
|
|
|
|
|
|
std::thread t([localPhotoInfo, path, pThis, osds]() mutable
|
|
|
|
|
{
|
|
|
|
|
NET_PHOTO_INFO netPhotoInfo = { 0 };
|
|
|
|
|
strcpy(netPhotoInfo.ip, "192.168.19.107");
|
|
|
|
|
strcpy(netPhotoInfo.url, "/cgi-bin/snapshot.cgi");
|
|
|
|
|
strcpy(netPhotoInfo.outputPath, path.c_str());
|
|
|
|
|
|
|
|
|
|
std::vector<uint8_t> img;
|
|
|
|
|
bool res = nc_hy::requestCapture(localPhotoInfo.channel, localPhotoInfo.preset, netPhotoInfo, img);
|
|
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
|
{
|
|
|
|
|
time_t takingTime = time(NULL);
|
|
|
|
|
if (localPhotoInfo.remedy != 0)
|
|
|
|
|
{
|
|
|
|
|
if ((takingTime - localPhotoInfo.scheduleTime) > 30)
|
|
|
|
|
{
|
|
|
|
|
takingTime = localPhotoInfo.scheduleTime + localPhotoInfo.channel * 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
localPhotoInfo.photoTime = takingTime;
|
|
|
|
|
// GpioControl::setOtgState(false);
|
|
|
|
|
GpioControl::set12VEnable(false);
|
|
|
|
|
|
|
|
|
|
// Notify to take next photo
|
|
|
|
|
pThis->TakePhotoCb(1, localPhotoInfo, "", takingTime);
|
|
|
|
|
|
|
|
|
|
cv::Mat rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
cv::imwrite("/sdcard/com.xypower.mpapp/tmp/netimg2.jpg", rgb);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
res = pThis->PostProcessPhoto(localPhotoInfo, osds, path, "", rgb);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pThis->TakePhotoCb(0, localPhotoInfo, "", 0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
t.detach();
|
|
|
|
|
}
|
|
|
|
|
else if (mPhotoInfo.mediaType == 0 && (mPhotoInfo.cameraType == CAM_TYPE_SERIAL))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (mPhotoInfo.usingSysCamera == 1)
|
|
|
|
|
{
|
|
|
|
@ -1586,7 +1647,7 @@ bool CPhoneDevice::CloseCamera()
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, unsigned int photoId, bool turnOffOtg)
|
|
|
|
|
void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, unsigned int photoId, unsigned char cameraType)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: Start CloseCamera PHOTOID=%u", photoId);
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
|
|
@ -1597,11 +1658,16 @@ void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, unsigned int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: Will Turn Off Power PHOTOID=%u", photoId);
|
|
|
|
|
if (turnOffOtg)
|
|
|
|
|
if (cameraType == CAM_TYPE_NET)
|
|
|
|
|
{
|
|
|
|
|
TurnOffOtg(NULL);
|
|
|
|
|
GpioControl::set12VEnable(false);
|
|
|
|
|
}
|
|
|
|
|
TurnOffCameraPower(NULL);
|
|
|
|
|
|
|
|
|
|
if (cameraType == CAM_TYPE_USB || cameraType == CAM_TYPE_NET)
|
|
|
|
|
{
|
|
|
|
|
GpioControl::setOtgState(false);
|
|
|
|
|
}
|
|
|
|
|
GpioControl::setCam3V3Enable(false);
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: End Turn Off Power PHOTOID=%u", photoId);
|
|
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: CloseCamera PHOTOID=%u", photoId);
|
|
|
|
@ -1682,7 +1748,7 @@ bool CPhoneDevice::onOneCapture(std::shared_ptr<ACameraMetadata> characteristics
|
|
|
|
|
|
|
|
|
|
media_status_t mstatus;
|
|
|
|
|
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, photoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, photoInfo.photoId, photoInfo.cameraType);
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
if (closeThread.joinable())
|
|
|
|
|
{
|
|
|
|
@ -1794,7 +1860,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristi
|
|
|
|
|
CPhoneCamera* pCamera = mCamera;
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, photoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, photoInfo.photoId, photoInfo.cameraType);
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
if (closeThread.joinable())
|
|
|
|
|
{
|
|
|
|
@ -2237,7 +2303,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristi
|
|
|
|
|
|
|
|
|
|
frames.clear();
|
|
|
|
|
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, photoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, photoInfo.photoId, mPhotoInfo.cameraType);
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
if (closeThread.joinable())
|
|
|
|
|
{
|
|
|
|
@ -2980,7 +3046,7 @@ bool CPhoneDevice::OnCaptureReady(bool photoOrVideo, bool result, cv::Mat& mat,
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, mPhotoInfo.cameraType);
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
if (closeThread.joinable())
|
|
|
|
|
{
|
|
|
|
@ -3008,7 +3074,7 @@ bool CPhoneDevice::OnVideoReady(bool photoOrVideo, bool result, const char* path
|
|
|
|
|
TakePhotoCb(result ? 3 : 0, mPhotoInfo, fullPath, time(NULL), objs);
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, mPhotoInfo.cameraType);
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
@ -3025,7 +3091,7 @@ bool CPhoneDevice::OnVideoReady(bool photoOrVideo, bool result, const char* path
|
|
|
|
|
TakePhotoCb(result ? 3 : 0, mPhotoInfo, fullPath, time(NULL), objs);
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, mPhotoInfo.cameraType);
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3047,7 +3113,7 @@ void CPhoneDevice::onError(const std::string& msg)
|
|
|
|
|
TakePhotoCb(0, mPhotoInfo, mPath, 0);
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, mPhotoInfo.cameraType);
|
|
|
|
|
// closeThread.detach();
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
}
|
|
|
|
@ -3066,7 +3132,7 @@ void CPhoneDevice::onDisconnected(ACameraDevice* device)
|
|
|
|
|
TakePhotoCb(0, mPhotoInfo, mPath, 0);
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, mPhotoInfo.cameraType);
|
|
|
|
|
// closeThread.detach();
|
|
|
|
|
m_threadClose.swap(closeThread);
|
|
|
|
|
}
|
|
|
|
@ -3251,6 +3317,7 @@ bool CPhoneDevice::OpenSensors(int sensortype)
|
|
|
|
|
GpioControl::set12VEnable(true);
|
|
|
|
|
GpioControl::setCam3V3Enable(true);
|
|
|
|
|
GpioControl::setRS485Enable(true);
|
|
|
|
|
GpioControl::setInt(CMD_SET_SPI_POWER, 1);
|
|
|
|
|
// GpioControl::setInt(CMD_SET_485_EN_STATE, 1); // 打开RS485电源
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
#ifndef USING_PLZ
|
|
|
|
@ -3263,7 +3330,6 @@ bool CPhoneDevice::OpenSensors(int sensortype)
|
|
|
|
|
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 1);
|
|
|
|
|
GpioControl::setInt(CMD_RS485_3V3_EN, 1);
|
|
|
|
|
#endif
|
|
|
|
|
GpioControl::setInt(CMD_SET_SPI_POWER, 1);
|
|
|
|
|
}
|
|
|
|
|
if(sensortype == CAMERA_SENSOR_OPEN)
|
|
|
|
|
{
|
|
|
|
|