<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Lazarus Pascal - macOS - Fast Scan QR code from image with macOS CoreImage - Delphi, Lazarus, Free Pascal				            </title>
            <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-fast-scan-qr-code-from-image-with-macos-coreimage/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Wed, 15 Jul 2026 19:49:38 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Lazarus Pascal - macOS - Fast Scan QR code from image with macOS CoreImage</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-fast-scan-qr-code-from-image-with-macos-coreimage/#post-6408</link>
                        <pubDate>Tue, 30 Jun 2026 15:34:23 +0000</pubDate>
                        <description><![CDATA[If you&#039;re already using CoreImage&#039;s QR detector, one thing that helped me was preprocessing the image a bit first (grayscale, improve contrast, and scale up small QR codes). That made detect...]]></description>
                        <content:encoded><![CDATA[<p>If you're already using CoreImage's QR detector, one thing that helped me was preprocessing the image a bit first (grayscale, improve contrast, and scale up small QR codes). That made detection much more reliable for low-quality images.<br />If anyone just needs to quickly check whether an image contains a readable QR code before debugging their code, I've also used <a href="https://scannr.net/" target="_blank" rel="noopener">https://scannr.net/</a> as a quick online tester. It can be handy for ruling out whether the image itself is the problem rather than the Lazarus/CoreImage code.</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>jossica</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-fast-scan-qr-code-from-image-with-macos-coreimage/#post-6408</guid>
                    </item>
				                    <item>
                        <title>Lazarus Pascal - macOS - Fast Scan QR code from image with macOS CoreImage</title>
                        <link>https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-fast-scan-qr-code-from-image-with-macos-coreimage/#post-5819</link>
                        <pubDate>Wed, 09 Apr 2025 07:29:39 +0000</pubDate>
                        <description><![CDATA[While tinkering with some of the newer Apple frameworks, I ran into this very fast function in CoreImage to quickly find and scan QR codes.Works great in Lazarus Pascal /FPC, so I though I&#039;d...]]></description>
                        <content:encoded><![CDATA[<p>While tinkering with some of the newer Apple frameworks, I ran into this very fast function in CoreImage to quickly find and scan QR codes.<br />Works great in Lazarus Pascal /FPC, so I though I'd share this here.</p>
<p>The CoreImage QR code scanner even picks up multiple QR code's in an image. And FAST.</p>
<p>Note that you <em>may</em> need to set the compiler option "<strong>-WM11.0</strong>".</p>
<p>Code:</p>
<p>I just made a simple form with a <strong>TButton</strong>, <strong>TImage</strong>, <strong>TLabel</strong>, <strong>TOpenDialog</strong>.<br />It allows you to select a picture and scans for QR codes right away.<br />The text of the QR code will be placed in the caption of Label1.</p>
<p>I've tested this with the latest Lazarus Pascal (trunk) but it looks like this will work in a release version as well.</p>
<pre contenteditable="false">unit Unit1;

{$mode objfpc}{$H+}
{$modeswitch objectivec1}
{$modeswitch objectivec2}
{$modeswitch cvar}
{$modeswitch cblocks}
{$packrecords c}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls
  , CocoaAll, CocoaUtils;

type
  { TForm1 }

  TForm1 = class(TForm)
    btnDetectQR: TButton;
    Image1: TImage;
    Label1: TLabel;
    OpenDialog1: TOpenDialog;
    procedure btnDetectQRClick(Sender: TObject);
  private

  public

  end;


var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.btnDetectQRClick(Sender: TObject);
var
  QRCodeImage : NSImage;
  MyCIImage   : CIImage;
  Detector    : CIDetector;
  Features    : NSArray;
  Feature     : CIFeature;
  Filename    : string;
begin
  if OpenDialog1.Execute then
    begin
      Filename := OpenDialog1.FileName;
      Image1.Picture.LoadFromFile(Filename);
      QRCodeImage := NSImage.alloc.initWithContentsOfFile(NSSTR(Filename));

      MyCIImage := CIImage.imageWithData(QRCodeImage.TIFFRepresentation);
      Detector  := CIDetector.detectorOfType_context_options(CIDetectorTypeQRCode, nil, nil);
      Features  := Detector.featuresInImage(MyCIImage);

      label1.caption:='';
      for Feature in Features do
      begin
        if Feature.isKindOfClass(CIQRCodeFeature) then
          label1.Caption:=label1.Caption+NSStringToString(CIQRCodeFeature(Feature).messageString_)+LineEnding;
      end;
    end;
end;

end.
</pre>
<p>Hopefully this is useful to someone, and at the least its a nice reference for myself in case I need this in the future &#x1f609; </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/">Delphi, Lazarus, Free Pascal</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/delphi-lazarus-free-pascal/lazarus-pascal-macos-fast-scan-qr-code-from-image-with-macos-coreimage/#post-5819</guid>
                    </item>
							        </channel>
        </rss>
		