Skip to content
Snippets Groups Projects
Commit 1d1581e2 authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Merge branch '32-investigate-qr-code-generation-as-option' into 'development'

Resolve "investigate QR-Code generation as option"

See merge request !56
parents d06415e5 42307c7a
No related branches found
No related tags found
2 merge requests!62Introduce changes for V1.0 RC 1,!56Resolve "investigate QR-Code generation as option"
Pipeline #653154 passed
......@@ -24,6 +24,8 @@ arguments
options.Position (1,2) {mustBeVector} = [1,0.4] % default for east
options.Rotation (1,1) {mustBeReal} = NaN
options.ConfigFileName (1,:) {mustBeText} = 'config.json'
options.QRcode (1,1) {mustBeNumericOrLogical} = false %experimental
options.QRsize (1,1) {mustBeNonnegative} = 0.15 % size of the QRCode
end
if isempty(options.ProjectID)
......@@ -73,16 +75,25 @@ IDs = cell(numel(figs),1);
for n = 1:numel(figs)
IDs{n} = PlotID.CreateID; % Create ID
IDs{n} = [options.ProjectID,'-',IDs{n}]; % add options.ProjectID
axes = get(figs(n),'CurrentAxes'); % Axes object for text annotation
pltAxes = get(figs(n),'CurrentAxes'); % Axes object for text annotation
% Limits for relative Positioning
ylim =get(axes,'YLim');
xlim =get(axes,'XLim');
ylim =get(pltAxes,'YLim');
xlim =get(pltAxes,'XLim');
%ID
position = [options.Position(1), options.Position(2)];
text(axes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,...
t=text(pltAxes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,...
'Rotation',Rotation, 'VerticalAlignment','bottom','Color',...
options.Color,'BackgroundColor','w', 'Units', 'normalized');
set(figs(n),'Tag', IDs{n});
set(figs(n),'Tag', IDs{n});
if options.QRcode
% this should be seen and use as a proof of concept
qrCode = PlotID.plotQR(IDs{n});
size = options.QRsize;
axes('Position',[position(1)-.05 position(2)+0.1 size size]);
imshow(qrCode);
t.Visible = 'off';
end
end
if numel(figs) == 1
......
function img = plotQR(data, size)
%QR reads a QR code from qrserver (depends on API)
% created by J.Stifter
arguments
data {mustBeTextScalar} = 'example';
size (1,2) {mustBeInteger} = [150, 150];
end
m = size(1);
n = size(2);
base_api = 'https://api.qrserver.com/v1/create-qr-code/?size=%dx%d&data=%s';
request = sprintf(base_api, m, n, data);
options = weboptions;
options.Timeout = 5;
img = webread(request, options);
img =logical(img);
end
clear; close all; clc;
%% Tag the plot with a QR code (experimental)
% here the work flow for tagging the plot with a QR code is shown
% the content of the qr code is the ID
% plots and data
fig(1) = figure;
[x1, y1, datapath1] = createExampleData('matlab');
plot(x1,y1,'-b'); box off; hold on; set(gca, 'TickDir', 'out', 'YLim', [0,4]);
%% 1. Tag plot with QRcode
% QR size is the relative size of the QR code (0.15 default)
[fig, IDs] = PlotID.TagPlot(fig,'Location','southeast','QRcode',true, 'QRsize', 0.18);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment