I want to print a QR COde on a cylindrical surface, but the scanner doesn't scan the regular QR Code from a curved surface. So I want to do an implementation in Matlab. I just never worked with image processing toolbox, so I do not really know what to do. The QR Code should be mapped to the cylindrical surface so that you see the right QR Code up front. I tried implementing a cylinder an mapping the QR Code on the surface, but still when I want to print it out, the QR Code doesn't appear distorted on the edges, as I want it to be, so that the scanner can read the QR code.
Code is from : Projecting an image onto a cylindrical surface in a way where the image appears flat
%% Creating cylinder
r = 0.4; %centimeter
h = 1; %centimeter
\[X,Y,Z\] = cylinder(r,100);
x = X(:,1:ceil(length(X)/4));
y = Y(:,1:ceil(length(Y)/4));
z = Z(:,1:ceil(length(Z)/4));
%% Plotting cylinder surface
figure(1), clf
h = surf(x,y,z); hold on
axis(\[-r r -r r\]\*2.2)
plot3(\[-r -r\], get(gca,'ylim'), \[0 0\]);
plot3(\[r r\], get(gca,'ylim'), \[0 0\]);
plot3(get(gca,'xlim'), \[-r -r\], \[0 0\]);
plot3(get(gca,'xlim'), \[r r\], \[0 0\]);
xlabel('x');
ylabel('y');
zlabel('z');
rotate3d on
axis vis3d
%% Car image
img = imread('BI_QR.jpg');
img = imrotate(img,180);
figure(2), clf
%imshow(img(1:340, 1:340, :));
imagesc(img(1:340, 1:340, :));
figure(), clf
warped_plot = warp(x,y,z,img(1:340, 1:340, :))
That's the code for the cylindrical surface.
I found a way in Mathematica, but I cannot convert it into a matlab file:
tag=Import["https://i.stack.imgur.com/SVKj3.png"]
grid = Image[Plot3D[0, {x, 0, 1}, {y, 0, 1}, ViewPoint -> {0, 0, \[Infinity]},
Lighting -> "Neutral", Boxed -> False, Axes -> False]]
h[x_] := (ArcTan[5 (x - 1/2)] + Pi/2)/Pi;
Plot[h[x], {x, 0, 1}]
ImageTransformation[grid, {#[[1]], h[#[[2]]]} &, {400, 600}]
imgS = ImageTransformation[tag, {#[[1]], h[#[[2]]]} &, {400, 600}]
ParametricPlot3D[{Cos[theta], Sin[theta], rho}, {theta, 0, Pi}, {rho, 0, 2},
PlotStyle -> Directive[Specularity[White, 30], Texture[tag]],
TextureCoordinateFunction -> ({#1, #3} &), Lighting -> "Neutral",
Mesh -> None, PlotRange -> All, TextureCoordinateScaling -> True,
ViewPoint -> {0, 10, 0}, Boxed -> False, Axes -> False]
ParametricPlot3D[{Cos[theta], -Sin[theta], rho}, {theta, 0, Pi}, {rho, 0, 2},
PlotStyle -> Directive[Specularity[White, 30], Texture[tag]],
TextureCoordinateFunction -> ({#1, #3} &), Lighting -> "Neutral",
Mesh -> None, PlotRange -> All, TextureCoordinateScaling -> True,
ViewPoint -> {0, 10, 0}, Boxed -> False, Axes -> False]
ParametricPlot3D[{Cos[theta], -Sin[theta], rho}, {theta, 0, Pi}, {rho, 0, 2},
PlotStyle -> Directive[Specularity[White, 30], Texture[imgS]],
TextureCoordinateFunction -> ({#3, #1} &), Lighting -> "Neutral",
Mesh -> None, PlotRange -> All, TextureCoordinateScaling -> True,
ViewPoint -> {0, 10, 0}, Boxed -> False, Axes -> False]`
But here the edges on the top and the bottom are missing.