Skip to content

Commit

Permalink
Add histogram and photo luminance value to "Exposure" and "Capture"
Browse files Browse the repository at this point in the history
  • Loading branch information
naixx committed Jun 10, 2024
1 parent 9d59d3e commit c87090c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
29 changes: 29 additions & 0 deletions hardware/oled.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ oled.updateHistogram = function(histogram) {
statusDetails.histogram = histogram;
}, 100);
}
oled.setEvHistogram = function (ev, histogram) {
statusDetails.histogram = histogram;
statusDetails.ev = ev;
}

oled.setTimelapseMode = function(set) {
if(set) {
Expand Down Expand Up @@ -1055,6 +1059,22 @@ oled.exposure = function(jpegFile, textArray, highlightTextIndex) {
} else {
fb.rect(0, 15, 160, 128 - 15, true);
}

var histX = 110;
var histY = 76;
var histH = 37;
var histW = 50;
if(statusDetails.histogram) {
color("background");
fb.rect(histX, histY, histW, histH, false);
color("primary");
for(var i = 0; i < 256; i++) {
var x = histX + 1 + (histW - 2) * (i/255);
var h = statusDetails.histogram[i] ? (histH - 2) * (statusDetails.histogram[i]/256) : 0;
fb.line(x, histY + 1 + histH - h, x, histY + 1 + histH, 1);
}
}

fb.font(MENU_STATUS_FONT_SIZE, false, FONT_DEFAULT);
color("primary");
var sectionSize = 160 / textArray.length;
Expand All @@ -1069,6 +1089,15 @@ oled.exposure = function(jpegFile, textArray, highlightTextIndex) {
color("primary");
}
}
if (statusDetails.ev) {
var textSize = fb.textSize(statusDetails.ev);
var x = 160 - textSize.width - 4;
fb.color(0, 0, 0);
var y = 76 - 12;
fb.rect(x - 2, y - textSize.height, textSize.width + 4, textSize.height + 4, true);
color("primary");
fb.text(x, y, statusDetails.ev);
}
oled.update(true);
}

Expand Down
37 changes: 28 additions & 9 deletions intervalometer/intervalometer-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ message args response
'camera-liveview' enable (bool) camera_status (obj)
event payload
event payload
--------------------------------------------------
'error' message (str)
'error' message (str)
'status' intervalometerStatus (obj)
'motion-status' motionStatus (obj)
'camera-status' cameraStatus (obj)
Expand Down Expand Up @@ -512,11 +512,30 @@ function runCommand(type, args, callback, client) {
camera.ptp.new.liveviewImage(function(err, img) {
cameraCallback(err);
if(!err && img) {
var obj = {
base64: new Buffer(img).toString('base64'),
type: 'preview'
};
sendEvent('camera.photo', obj);

var size = {
x: 160,
q: 128-15
}
image.downsizeJpeg(img, size, null, function (err, lowResJpg) {
var img2;
if (!err && lowResJpg) {
img2 = lowResJpg;
} else {
im2g = img;
}
var photoRes = {
base64: new Buffer(img2).toString('base64'),
type: 'preview',
ev: null
}
image.exposureValue(img2, function (err, ev, histogram) {
photoRes.ev = ev;
photoRes.histogram = histogram;
sendEvent('camera.photo', photoRes);
callback && callback(err, photoRes);
});
});
} else {
console.log("PREVIEW: err:", err);
}
Expand Down Expand Up @@ -588,7 +607,7 @@ function runCommand(type, args, callback, client) {
camera.ptp.new.switchPrimary(args.cameraObject, callback);
} else {
camera.ptp.switchPrimary(args.cameraObject, callback);
}
}
break;
case 'camera.ptp.capture':
remap('camera.ptp.capture')(args.options, cameraCallback);
Expand Down Expand Up @@ -723,7 +742,7 @@ function getNewSettings(settings, status) {
shutter: settings.shutter && settings.shutter.list,
aperture: settings.aperture && settings.aperture.list,
iso: settings.iso && settings.iso.list
},
},
details: {
shutter: settings.shutter,
aperture: settings.aperture,
Expand Down
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,8 @@ if (VIEW_HARDWARE) {
inputs.removeListener('D', captureDialHandler);
setTimeout(cb, 500);
ui.status("liveview error");
} else {
showLiveViewScreen();
}
});
lists.fixedApertureEv = core.currentProgram.manualAperture;
Expand Down Expand Up @@ -5872,6 +5874,11 @@ core.on('camera.photo', function() {
} else {
//app.addJpegFrame(core.photo.jpeg);
//app.addJpegFrame(core.photo.jpeg);
var lastPhotoLum
if (core.photo.ev)
lastPhotoLum = (Math.round(core.photo.ev * 10) / 10).toString() + " L";
oled.setEvHistogram(lastPhotoLum, core.photo.histogram);

var size = {
x: 160,
q: 80
Expand All @@ -5891,7 +5898,6 @@ core.on('camera.photo', function() {
}
}
}

previewImage = {
jpeg: core.photo.base64,
zoomed: core.photo.zoomed,
Expand Down
5 changes: 5 additions & 0 deletions oled.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scp -r hardware/oled.js root@192.168.31.21:/home/view/current/hardware
scp -r main.js root@192.168.31.21:/home/view/current/
scp -r intervalometer/intervalometer-server.js root@192.168.31.21:/home/view/current/intervalometer

ssh root@192.168.31.21 "./startup.sh"

0 comments on commit c87090c

Please sign in to comment.