Code covered by the BSD License  

Highlights from
Video Sudoku Solver

image thumbnail

Video Sudoku Solver

by

 

19 Jan 2011 (Updated )

Solves a sudoku with a web camera and then displays it while tracking the original video feed.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

solution2image(M,Msol)
function I = solution2image(M,Msol)
% This basically plots the solution, prints it to a temporary file, copies
% that image to an image variable I, and then deletes the temporary file.

figure(10);
set(10,'visible','off');
set(10,'Units','pixels','pos',[1 1 200 200]);
set(10,'paperpositionmode','auto');
a = axes;
set(a,'units','nor','pos',[0 0 1 1]);

axis([0 9 0 9]);
axis ij
axis off

for k = 1:9
    for j = 1:9
        if ~M(k,j)
            text(j-0.5,k-0.5,num2str(Msol(k,j)),'fontweight','bold'...
                ,'horiz','cen','fontsize',10);
        end
    end
end
print('-dpng','testimage.png',['-r' num2str(get(0,'screenPixelsPerInch'))]);
I = im2bw(imread('testimage.png'));
delete testimage.png
close(10);

Contact us