调整照片方向

TempBranch
Matthew 9 months ago
parent 21018ae898
commit 54ddc6f9d6

@ -776,8 +776,8 @@ Java_com_xypower_mpapp_MicroPhotoService_captureFinished(
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpapp_MicroPhotoService_burstCaptureFinished(
JNIEnv* env,
jobject pThis, jlong handler, jboolean result, jint numberOfCaptures, jstring pathsJoinedByTab, jlong photoId) {
jobject pThis, jlong handler, jboolean result, jint numberOfCaptures,
jstring pathsJoinedByTab, jboolean frontCamera, jint rotation, jlong photoId) {
CTerminal* pTerminal = reinterpret_cast<CTerminal *>(handler);
if (pTerminal == NULL)
@ -801,7 +801,7 @@ Java_com_xypower_mpapp_MicroPhotoService_burstCaptureFinished(
}
const char* pathsStr = env->GetStringUTFChars(pathsJoinedByTab, 0);
((CPhoneDevice *)dev)->ProcessRawCapture(result != JNI_FALSE, numberOfCaptures, MakeString(pathsStr), photoId);
((CPhoneDevice *)dev)->ProcessRawCapture(result != JNI_FALSE, numberOfCaptures, MakeString(pathsStr), frontCamera != JNI_FALSE, rotation, photoId);
env->ReleaseStringUTFChars(pathsJoinedByTab, pathsStr);
}
}

@ -2017,7 +2017,7 @@ void CPhoneDevice::UpdateSimcard(const std::string& simcard)
m_simcard = simcard;
}
bool CPhoneDevice::ProcessRawCapture(bool result, int numberOfCaptures, const std::string& pathsJoinedByTab, long photoId)
bool CPhoneDevice::ProcessRawCapture(bool result, int numberOfCaptures, const std::string& pathsJoinedByTab, bool frontCamera, int rotation, long photoId)
{
std::vector<std::string> paths = split(pathsJoinedByTab, "\t");
@ -2033,8 +2033,39 @@ bool CPhoneDevice::ProcessRawCapture(bool result, int numberOfCaptures, const st
hdrplus::hdrplus_pipeline pipeline;
cv::Mat mat;
pipeline.run_pipeline(paths, 0, mat);
XYLOG(XYLOG_SEVERITY_ERROR, "Finish HDR CH=%u IMGID=%u", (uint32_t)mPhotoInfo.channel, (uint32_t)mPhotoInfo.photoId);
mat = convert16bit2_8bit_(mat.clone());
if (rotation >= 0)
{
if (rotation == 90)
{
cv::Mat tempPic;
cv::transpose(mat, tempPic);
cv::flip(tempPic, mat, 1);
}
else if (rotation == 180)
{
if (frontCamera)
{
flip(mat, mat, 0);
}
else
{
cv::flip(mat, mat, -1);
}
}
else if (rotation == 270)
{
cv::Mat tempPic;
cv::transpose(mat, tempPic);
cv::flip(tempPic, mat, 0);
}
XYLOG(XYLOG_SEVERITY_ERROR, "Finish rotation CH=%u IMGID=%u", (uint32_t)mPhotoInfo.channel, (uint32_t)mPhotoInfo.photoId);
}
cv::cvtColor(mat, mat, cv::COLOR_RGB2BGR);
XYLOG(XYLOG_SEVERITY_ERROR, "Finish Processing Raw Capture CH=%u IMGID=%u", (uint32_t)mPhotoInfo.channel, (uint32_t)mPhotoInfo.photoId);

@ -221,7 +221,7 @@ public:
void UpdatePosition(double lon, double lat, double radius, time_t ts);
bool OnVideoReady(bool photoOrVideo, bool result, const char* path, unsigned int photoId);
bool OnCaptureReady(bool photoOrVideo, bool result, cv::Mat& mat, unsigned int photoId);
bool ProcessRawCapture(bool result, int numberOfCaptures, const std::string& pathsJoinedByTab, long photoId);
bool ProcessRawCapture(bool result, int numberOfCaptures, const std::string& pathsJoinedByTab, bool frontCamera, int rotation, long photoId);
void UpdateSignalLevel(int signalLevel);
void UpdateTfCardPath(const std::string& tfCardPath)

@ -38,7 +38,7 @@ static const uint64_t kMaxExposureTime = static_cast<uint64_t>(250000000);
#define WAIT_AWB_LOCKED 2
#define WAIT_AF_LOCKED 4
#define EXPECTED_CAPTURE_IDX 0
// #define EXPECTED_CAPTURE_IDX 0
#define EXPECTED_CAPTURE_IDX 1
class CameraManager

@ -436,7 +436,7 @@ public class MicroPhotoService extends Service {
File rawFile = new File(path);
String pathsStr = String.join("\t", paths);
mService.burstCaptureFinished(mService.mNativeHandle, result, numberOfCaptures, pathsStr, videoId);
mService.burstCaptureFinished(mService.mNativeHandle, result, numberOfCaptures, pathsStr, frontCamera, orientation, videoId);
for (String p : paths) {
try {
File f = new File(p);
@ -1324,7 +1324,7 @@ cellSignalStrengthGsm.getDbm();
protected native boolean uninit(long handler);
protected native void recordingFinished(long handler, boolean photoOrVideo, boolean result, String path, long videoId);
protected native void captureFinished(long handler, boolean photoOrVideo, boolean result, Bitmap bm, long videoId);
protected native void burstCaptureFinished(long handler, boolean result, int numberOfCaptures, String pathsJoinedByTab, long photoId);
protected native void burstCaptureFinished(long handler, boolean result, int numberOfCaptures, String pathsJoinedByTab, boolean frontCamera, int rotation, long photoId);
public static native long takePhoto(int channel, int preset, boolean photoOrVideo, String configFilePath, String path);
public static native void releaseDeviceHandle(long deviceHandle);
public static native boolean sendExternalPhoto(long deviceHandle, String path);

@ -620,6 +620,12 @@ public class RawActivity extends AppCompatActivity {
mRawResultQueue.remove(requestId);
finishedCaptureLocked();
}
if (mRequestIds.isEmpty()) {
finish();
} else {
broadcastPhotoFile(false, "");
}
// showToast("Capture failed!");
}

@ -201,6 +201,7 @@ public class MpMasterService extends Service {
mMpAppVersion = packageInfo == null ? "" : packageInfo.versionName;
mPreviousMpHbTime = System.currentTimeMillis();
mTimeToStartMpApp = mPreviousMpHbTime;
buildChargingBatteryVoltage(System.currentTimeMillis());
@ -368,7 +369,7 @@ public class MpMasterService extends Service {
final Context context = getApplicationContext();
long ts = System.currentTimeMillis();
if (ts - mPreviousMpHbTime > mMpHeartbeatDuration * 2) {
if (mPreviousMpHbTime <= ts && ts - mPreviousMpHbTime > mMpHeartbeatDuration * 2) {
// MpApp is not running
if (ts - mTimeToStartMpApp >= 30000) {
MicroPhotoContext.restartMpApp(context);

Loading…
Cancel
Save