├── .gitignore
├── C#
├── Compact_Scientific_Cameras
│ ├── .vs
│ │ └── Compact_Scientific_Cameras
│ │ │ └── v16
│ │ │ └── .suo
│ ├── Compact_Scientific_Cameras.sln
│ ├── Hardware_Triggering
│ │ ├── App.config
│ │ ├── Hardware_Triggering.csproj
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── bin
│ │ │ └── Debug
│ │ │ │ ├── Hardware_Triggering.exe.config
│ │ │ │ ├── Received_Image1.bmp
│ │ │ │ ├── Received_Image2.bmp
│ │ │ │ ├── Received_Image3.bmp
│ │ │ │ ├── Received_Image4.bmp
│ │ │ │ ├── Received_Image5.bmp
│ │ │ │ └── thorlabs_tsi_logger.cfg
│ │ └── obj
│ │ │ ├── Debug
│ │ │ ├── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs
│ │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ │ ├── Hardware_Triggering.csproj.CopyComplete
│ │ │ └── Hardware_Triggering.csproj.FileListAbsolute.txt
│ │ │ └── Release
│ │ │ └── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs
│ ├── README.md
│ └── Read_Parameters
│ │ ├── App.config
│ │ ├── Program.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Read_Parameters.csproj
│ │ ├── bin
│ │ └── Debug
│ │ │ ├── Read_Parameters.exe.config
│ │ │ └── thorlabs_tsi_logger.cfg
│ │ └── obj
│ │ ├── Debug
│ │ ├── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs
│ │ ├── DesignTimeResolveAssemblyReferencesInput.cache
│ │ ├── Read_Parameters.csproj.AssemblyReference.cache
│ │ └── Read_Parameters.csproj.FileListAbsolute.txt
│ │ └── Release
│ │ └── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs
└── Obsoleted
│ ├── DCx Cameras Single Frame Capture
│ ├── App.config
│ ├── DCx Camera Live capture.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── bin
│ │ └── Debug
│ │ │ └── DCx Camera Live capture.exe.config
│ └── obj
│ │ ├── Debug
│ │ ├── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs
│ │ └── DCx Camera Live capture.csproj.FileListAbsolute.txt
│ │ └── Release
│ │ └── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs
│ └── ReadMe.md
├── C++
├── Compact_Scientific_Cameras
│ ├── Compact_Scientific_Cameras.sln
│ ├── Hardware_Triggering
│ │ ├── Hardware_Triggering.cpp
│ │ ├── Hardware_Triggering.vcxproj
│ │ ├── Hardware_Triggering.vcxproj.filters
│ │ └── x64
│ │ │ └── Debug
│ │ │ └── Hardware_Triggering.exe.recipe
│ ├── README.md
│ ├── Read_Parameters
│ │ ├── Read_Parameters.cpp
│ │ ├── Read_Parameters.vcxproj
│ │ ├── Read_Parameters.vcxproj.filters
│ │ └── x64
│ │ │ └── Debug
│ │ │ └── Read_Parameters.exe.recipe
│ ├── linux_make_files
│ │ └── MakeFile
│ └── x64
│ │ └── Debug
│ │ └── thorlabs_tsi_logger.cfg
└── Obsoleted
│ └── ReadMe.md
├── LICENSE
├── MATLAB
└── Compact_Scientific_Cameras
│ ├── ColorProcessing.m
│ ├── HardwareTrigger.m
│ ├── PolarizationProcessing.m
│ ├── ReadMe.md
│ ├── SoftwareTrigger.m
│ ├── ThorlabsCameraGUI.fig
│ └── ThorlabsCameraGUI.m
├── Python
├── Obsoleted
│ ├── CCD Camera PythonNET
│ │ ├── README.md
│ │ ├── pythonnet_example.py
│ │ └── tl_dotnet_wrapper.py
│ ├── DCx Camera PyuEye
│ │ ├── DCx_PyuEye.py
│ │ └── README.md
│ └── ReadMe.md
├── README.md
├── grab_frames_polling_continuous.py
├── grab_single_frame.py
└── windows_setup.py
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ./C++/Benchtop/BVCX01/*
2 | *.tlog
3 | *.log
4 | *.idb
5 | *.pdb
6 | *.vs
7 | *.lib
8 | *.dll
9 | !CameraTypeConversion.dll
10 | *.cache
11 | *.user
12 | *.exe
13 | *.ilk
14 | *.obj
15 | *.cfg
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/.vs/Compact_Scientific_Cameras/v16/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/.vs/Compact_Scientific_Cameras/v16/.suo
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Compact_Scientific_Cameras.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32126.315
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Read_Parameters", "Read_Parameters\Read_Parameters.csproj", "{4DE3998A-9A46-46CF-A099-C13468A92E3B}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hardware_Triggering", "Hardware_Triggering\Hardware_Triggering.csproj", "{F8072EAD-D580-469E-B4A8-2EFEFC951EA3}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {4DE3998A-9A46-46CF-A099-C13468A92E3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {4DE3998A-9A46-46CF-A099-C13468A92E3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {4DE3998A-9A46-46CF-A099-C13468A92E3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {4DE3998A-9A46-46CF-A099-C13468A92E3B}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {F8072EAD-D580-469E-B4A8-2EFEFC951EA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {F8072EAD-D580-469E-B4A8-2EFEFC951EA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {F8072EAD-D580-469E-B4A8-2EFEFC951EA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {F8072EAD-D580-469E-B4A8-2EFEFC951EA3}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {16938807-BBAF-42C2-8AAB-15C69A11C937}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/Hardware_Triggering.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F8072EAD-D580-469E-B4A8-2EFEFC951EA3}
8 | Exe
9 | Hardware_Triggering
10 | Hardware_Triggering
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | x64
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.Core.dll
47 |
48 |
49 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.CoreInterfaces.dll
50 |
51 |
52 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.ImageData.dll
53 |
54 |
55 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.ImageDataInterfaces.dll
56 |
57 |
58 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.TLCamera.dll
59 |
60 |
61 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.TLCameraInterfaces.dll
62 |
63 |
64 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\thorlabs_tsi_camera_sdk1_cli.dll
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Drawing;
7 | using Thorlabs.TSI.TLCamera;
8 | using Thorlabs.TSI.TLCameraInterfaces;
9 | using Thorlabs.TSI.ImageData;
10 | using Thorlabs.TSI.ImageDataInterfaces;
11 |
12 | namespace Hardware_Triggering
13 | {
14 | class Program
15 | {
16 | static void Main(string[] args)
17 | {
18 | ITLCameraSDK sdk = TLCameraSDK.OpenTLCameraSDK(); //Create Instance of the TL Camera SDK
19 |
20 | //Use SDK to Discover and Open cameras
21 | IList serialNumbers = sdk.DiscoverAvailableCameras();
22 | Console.WriteLine("Number of available cameras: {0}", serialNumbers.Count);
23 | if (serialNumbers.Count == 0)
24 | {
25 | Console.WriteLine("No Cameras Available");
26 | return;
27 | }
28 | ITLCamera cam = sdk.OpenCamera(serialNumbers[0], false); //Open first detected serial number
29 |
30 | //Set Camera parameters
31 | cam.ExposureTime_us = 100; // in microseconds
32 | cam.FramesPerTrigger_zeroForUnlimited = 1;
33 |
34 | //Check if hardware triggering is supported by the camera. If not, close the program
35 | if (cam.GetIsOperationModeSupported(OperationMode.HardwareTriggered))
36 | {
37 | cam.OperationMode = OperationMode.HardwareTriggered;
38 | Console.WriteLine("Camera supports hardware triggering");
39 | }
40 | else
41 | {
42 | Console.WriteLine("Camera does not support hardware triggering");
43 | return;
44 | }
45 | cam.Arm(); //Arm the camera
46 |
47 | //While loop waits for images to come in from the camera. Once it receives 5 images, the loop exits
48 | Console.WriteLine("Waiting for image");
49 | int numImagesAcquired = 0;
50 | while (numImagesAcquired < 5)
51 | {
52 | if (cam.NumberOfQueuedFrames > 0)
53 | {
54 | Frame frame = cam.GetPendingFrameOrNull(); // Get the latest image
55 | if (frame != null)
56 | {
57 | Bitmap image = frame.ImageData.ToBitmap_Format24bppRgb(); //Convert the returned frame to a bitmap
58 | image.Save("Received_Image" + (numImagesAcquired + 1) + ".bmp"); // Saves to exe location
59 | Console.WriteLine("Image Received from the camera");
60 | numImagesAcquired++;
61 | }
62 | }
63 | System.Threading.Thread.Sleep(50);
64 | }
65 |
66 | //Close camera and clean up resources
67 | Console.WriteLine("Camera closing");
68 | cam.Disarm();
69 | cam.Dispose();
70 | sdk.Dispose();
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Hardware_Triggering")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Hardware_Triggering")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f8072ead-d580-469e-b4a8-2efefc951ea3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Hardware_Triggering.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image1.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image1.bmp
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image2.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image2.bmp
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image3.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image3.bmp
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image4.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image4.bmp
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image5.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/Received_Image5.bmp
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/bin/Debug/thorlabs_tsi_logger.cfg:
--------------------------------------------------------------------------------
1 | // Specifies the path where the log files are created.
2 | // This setting is optional and if ommitted, the log files are
3 | // are created in the same directory that the logger DLL resides in.
4 | THORLABS_TSI_LOGGER_LOG_FILE_PATH "C:\SDK_log_files\"
5 |
6 | // Format for global log specification:
7 | // GLOBAL [log channel options] [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format]
8 | // [log channel options] ~= 'c', 'a', 'm', 'g', 'u'
9 | // c - log to the console
10 | // a - log to the master log file
11 | // m - log to the module log file
12 | // g - log to the group log file(s)
13 | // u - log to the unique (module + group) log file
14 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
15 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
16 | // All surplus log statements will be sent to a newly created log file with a name that
17 | // is derived from the original log file name.
18 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
19 | // unbounded.
20 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
21 | // If the number of log files exceeds this number, the logger will delete extra log files to
22 | // maintain this log file count. The logger will always delete the oldest log files first.
23 | // This setting is optional - if it is omitted, then the number of log files are allowed to
24 | // proliferate unbounded.
25 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
26 | // n - include the sequence number
27 | // d - include the date/time stamp
28 | // m - include the module name
29 | // p - include the log priority
30 | // t - include the thread ID
31 | // l - include the source file location
32 | // This setting is optional. If it is ommitted, none of the above
33 | // metadata is prepended to the log statement.
34 | //
35 | // NOTE: The global settings will override the corresponding settings for group and module
36 | // loggers with the exception of the log file size limit. The global log file size limit
37 | // does NOT override any other limit settings.
38 | THORLABS_TSI_LOGGER_GLOBAL camgu Trace ndmplt
39 |
40 | // Format for group log specification:
41 | // GROUP [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format]
42 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
43 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
44 | // All surplus log statements will be sent to a newly created log file with a name that
45 | // is derived from the original log file name.
46 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
47 | // unbounded.
48 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
49 | // If the number of log files exceeds this number, the logger will delete extra log files to
50 | // maintain this log file count. The logger will always delete the oldest log files first.
51 | // This setting is optional - if it is omitted, then the number of log files are allowed to
52 | // proliferate unbounded.
53 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
54 | // n - include the sequence number
55 | // d - include the date/time stamp
56 | // m - include the module name
57 | // p - include the log priority
58 | // t - include the thread ID
59 | // l - include the source file location
60 | // This setting is optional. If it is ommitted, none of the above
61 | // metadata is prepended to the log statement.
62 | THORLABS_TSI_LOGGER_GROUP Trace ndmplt
63 |
64 | // Format for console log specification:
65 | // CONSOLE [logging priority] [Log statement format]
66 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
67 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
68 | // This setting is optional. If it is ommitted, none of the above
69 | // metadata is prepended to the log statement.
70 | THORLABS_TSI_LOGGER_CONSOLE Trace ndmplt
71 |
72 | // The field separator character that is used in the log files and console loggers.
73 | THORLABS_TSI_LOGGER_FIELD_SEPARATOR_CHARACTER ,
74 |
75 | // The field decorator character is used to surround the text of each field of the log statement.
76 | THORLABS_TSI_LOGGER_FIELD_DECORATOR_CHARACTER "
77 |
78 | // The log file extension that will be used for all the generated log files.
79 | THORLABS_TSI_LOGGER_LOG_FILE_EXTENSION log
80 |
81 | // This setting allows the user to disable file buffering.
82 | // If file buffering is off, the logger will persist every log statement to disk.
83 | // This can be advantageous if the user wants to minimize data loss in the event of a catastrophic failure.
84 | // The disadvantage is that this can affect application performance - significantly if large
85 | // numbers of log statements are generated in a short period of time.
86 | // If file buffering is on, then the logging system will buffer an implementation dependent number of log statements
87 | // before writing the batch to disk.
88 | // The recommended setting is on.
89 | THORLABS_TSI_LOGGER_FILE_BUFFERING on
90 |
91 | // Format for a log module:
92 | // [Module name] [log channel options] [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format] [[function filter]]
93 | // [log channel options] ~= 'c', 'a', 'm', 'g', 'u'
94 | // c - log to the console
95 | // a - log to the master log file
96 | // m - log to the module log file
97 | // g - log to the group log file(s)
98 | // u - log to the unique (module + group) log file
99 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
100 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
101 | // All surplus log statements will be sent to a newly created log file with a name that
102 | // is derived from the original log file name.
103 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
104 | // unbounded.
105 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
106 | // If the number of log files exceeds this number, the logger will delete extra log files to
107 | // maintain this log file count. The logger will always delete the oldest log files first.
108 | // This setting is optional - if it is omitted, then the number of log files are allowed to
109 | // proliferate unbounded.
110 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
111 | // n - include the sequence number
112 | // d - include the date/time stamp
113 | // m - include the module name
114 | // p - include the log priority
115 | // t - include the thread ID
116 | // l - include the source file location
117 | // This setting is optional. If it is ommitted, none of the above
118 | // metadata is prepended to the log statement.
119 | // [[function filter]] ~= a comma separated list of function names. The function names
120 | // must exactly match the implementation dependent __FUNCTION__ macro expansion.
121 | // An empty function filter includes all functions. A non-empty list logs statements
122 | // from only those functions.
123 | ::MODULE_1 camgu Trace ndmplt []
124 | ::MODULE_2 camgu Trace ndmplt []
125 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
5 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Debug/Hardware_Triggering.csproj.CopyComplete:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Debug/Hardware_Triggering.csproj.CopyComplete
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Debug/Hardware_Triggering.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Hardware_Triggering.exe.config
2 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Hardware_Triggering.exe
3 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Hardware_Triggering.pdb
4 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.Core.dll
5 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.CoreInterfaces.dll
6 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.ImageData.dll
7 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.ImageDataInterfaces.dll
8 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.TLCamera.dll
9 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.TLCameraInterfaces.dll
10 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\thorlabs_tsi_camera_sdk1_cli.dll
11 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.ColorInterfaces.dll
12 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\Thorlabs.TSI.PolarizationInterfaces.dll
13 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\obj\Debug\Hardware_Triggering.csproj.AssemblyReference.cache
14 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\obj\Debug\Hardware_Triggering.csproj.CoreCompileInputs.cache
15 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\obj\Debug\Hardware_Triggering.csproj.CopyComplete
16 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\obj\Debug\Hardware_Triggering.exe
17 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\obj\Debug\Hardware_Triggering.pdb
18 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\obj\Debug\Hardware_Triggering.csproj.SuggestedBindingRedirects.cache
19 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Hardware_Triggering/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
5 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/README.md:
--------------------------------------------------------------------------------
1 | ## Included Examples
2 |
3 | ### Hardware Triggering:
4 | This examples initializes the first detected camera and sets up for hardware triggering. A loop is started that waits for 5 images to be requested and received. Each image will be saved to the exe location for the project.
5 |
6 | ### Read Parameters:
7 | This example goes through common settable/gettable parameters for the cameras and prints them to console. This also shows how to interpret returns from cameras that are not compatible with certain settings.
8 |
9 | ## Build Instructions
10 | 1. Set the desired startup file.
11 | 2. If you have not done so already unzip the following folder to an accesible location on your drive. This contains the Camera SDK.
12 |
13 | * 32-Bit - C:\Program Files (x86)\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
14 | * 64-Bit - C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
15 | This example will use the dll's here: \Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\
16 |
17 | 3. Set Project Platform under Project -> Properties -> Build. This should be selected to match the bit-version of the dll's you plan to use (e.g. x64 for 64-bit dll's).
18 | 4. Copy the dll's from the managed folder to the bin of this project:
19 | \Camera_Examples\C#\Compact_Scientific_Cameras\Hardware_Triggering\bin\Debug\
20 |
21 | 5. The References are already added to the project, but in the event they need to be re-added you will need the following:
22 | * Thorlabs.TSI.Core
23 | * Thorlabs.TSI.Core Interfaces
24 | * Thorlabs.TSI.ImageData
25 | * Thorlabs.TSI.ImageDataInterfaces
26 | * Thorlabs.TSI.TLCamera
27 | * Thorlabs.TSI.TLCameraInterfaces
28 | * thorlabs_tsi_camera_sdk1_cli
29 | * System.Drawing
30 |
31 |
32 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Drawing;
7 | using Thorlabs.TSI.TLCamera;
8 | using Thorlabs.TSI.TLCameraInterfaces;
9 | using Thorlabs.TSI.ImageData;
10 | using Thorlabs.TSI.ImageDataInterfaces;
11 |
12 | namespace Read_Parameters
13 | {
14 | class Program
15 | {
16 | static void Main(string[] args)
17 | {
18 | ITLCameraSDK sdk = TLCameraSDK.OpenTLCameraSDK(); //Create Instance of the TL Camera SDK
19 |
20 | //Use SDK to Discover and Open cameras
21 | IList serialNumbers = sdk.DiscoverAvailableCameras();
22 | if (serialNumbers.Count == 0)
23 | {
24 | Console.WriteLine("No Cameras Available");
25 | return;
26 | }
27 | Console.WriteLine("Number of Cameras found: {0}", serialNumbers.Count);
28 | Console.WriteLine("Serial Number of first camera: ", serialNumbers[0]);
29 |
30 | ITLCamera cam = sdk.OpenCamera(serialNumbers[0], false);
31 | Console.WriteLine("Camera Opened");
32 |
33 | //Get Camera Info
34 | Console.WriteLine("Model Number: {0}, Name: {1}, Firmware Version: {2}, Serial Number: {3}", cam.Model, cam.Name, cam.FirmwareVersion, cam.SerialNumber);
35 |
36 | //Get Camera Sensor Type
37 | Console.WriteLine("Sebsor Type: {0}", cam.CameraSensorType.ToString());
38 |
39 | //Get the camera sensor dimensions in pixels
40 | Console.WriteLine("Sensor Size: {0}px x {1}px", cam.SensorWidth_pixels, cam.SensorHeight_pixels);
41 |
42 | //Get Camera Bit Depth
43 | Console.WriteLine("Bit Depth: {0}", cam.BitDepth);
44 |
45 | //Get Exposure Time Range
46 | Console.WriteLine("Exposure Time Range: {0} to {1}", cam.ExposureTimeRange_us.Minimum, cam.ExposureTimeRange_us.Maximum); //In microseconds
47 |
48 | //Set and Get Exposure Time
49 | cam.ExposureTime_us = 45000; //In microseconds
50 | Console.WriteLine("Exposure Time: {0}", cam.ExposureTime_us);
51 |
52 | //Get Exposure Frames Per Trigger Range
53 | Console.WriteLine("Frames Per Trigger Range: {0} to {1}", cam.FramesPerTriggerRange.Minimum, cam.FramesPerTriggerRange.Maximum);
54 |
55 | //Set and Get Frames Per Trigger
56 | cam.FramesPerTrigger_zeroForUnlimited = 1;
57 | Console.WriteLine("Frames Per Trigger: {0}", cam.FramesPerTrigger_zeroForUnlimited);
58 |
59 | //Check if camera supports adjusting framerate and check range
60 | if (cam.FrameRateControlValueRange_fps.Maximum != 0)
61 | {
62 | Console.WriteLine("Camera supports framerate adjustment with range of: {0} to {1}", cam.FrameRateControlValueRange_fps.Minimum, cam.FrameRateControlValueRange_fps.Maximum);
63 |
64 | //Set and Get Framerate
65 | cam.FrameRateControlValue_fps = 5; // in fps
66 | Console.WriteLine("Framerate Value: {0}", cam.FrameRateControlValue_fps);
67 | }
68 |
69 | //Check if camera supports adjusting gain and check range
70 | if (cam.GainRange.Maximum != 0)
71 | {
72 | Console.WriteLine("Camera supports gain adjustment with range of: {0} to {1}", cam.GainRange.Minimum, cam.GainRange.Maximum);
73 |
74 | //Set and Get Gain
75 | //Gain units can vary by camera. Use the helper function to set these for the camera
76 | cam.Gain = cam.ConvertDecibelsToGain(.5); // in dB
77 | Console.WriteLine("Gain Value: {0}", cam.ConvertGainToDecibels(cam.Gain));
78 | }
79 |
80 | //Check if camera supports adjusting black level and check range
81 | if (cam.BlackLevelRange.Maximum != 0)
82 | {
83 | Console.WriteLine("Camera supports black level adjustment with range of: {0} to {1}", cam.BlackLevelRange.Minimum, cam.BlackLevelRange.Maximum);
84 |
85 | //Set and Get Black Level
86 | cam.BlackLevel = 5; // in fps
87 | Console.WriteLine("Black Level Value: {0}", cam.BlackLevel);
88 | }
89 |
90 | //Set ROI and Bin Values
91 | cam.ROIAndBin = new ROIAndBin()
92 | {
93 | BinX = 1,
94 | BinY = 1,
95 | ROIOriginX_pixels = 0,
96 | ROIOriginY_pixels = 0,
97 | ROIWidth_pixels = cam.SensorWidth_pixels,
98 | ROIHeight_pixels = cam.SensorHeight_pixels
99 | };
100 |
101 | //Get ROI and Bin Values
102 | Console.WriteLine("Bin X Value: {0} \nBin Y Value: {1} \nROI X Value: {2} \nROI Y Value: {3} \nROI Width {4} \nROI Height {5}", cam.ROIAndBin.BinX,
103 | cam.ROIAndBin.BinY, cam.ROIAndBin.ROIOriginX_pixels, cam.ROIAndBin.ROIOriginY_pixels, cam.ROIAndBin.ROIWidth_pixels, cam.ROIAndBin.ROIHeight_pixels);
104 |
105 | //Close camera and clean up resources
106 | Console.WriteLine("Camera closing");
107 | cam.Disarm();
108 | cam.Dispose();
109 | sdk.Dispose();
110 | Console.WriteLine("Press Enter Key to Close");
111 | Console.ReadLine();
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Read_Parameters")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Read_Parameters")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("4de3998a-9a46-46cf-a099-c13468a92e3b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/Read_Parameters.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {4DE3998A-9A46-46CF-A099-C13468A92E3B}
8 | Exe
9 | Read_Parameters
10 | Read_Parameters
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | x64
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | False
46 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.Core.dll
47 |
48 |
49 | False
50 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.CoreInterfaces.dll
51 |
52 |
53 | False
54 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.ImageData.dll
55 |
56 |
57 | False
58 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.ImageDataInterfaces.dll
59 |
60 |
61 | False
62 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.TLCamera.dll
63 |
64 |
65 | False
66 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\Thorlabs.TSI.TLCameraInterfaces.dll
67 |
68 |
69 | False
70 | ..\..\..\..\..\..\..\..\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib\thorlabs_tsi_camera_sdk1_cli.dll
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/bin/Debug/Read_Parameters.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/bin/Debug/thorlabs_tsi_logger.cfg:
--------------------------------------------------------------------------------
1 | // Specifies the path where the log files are created.
2 | // This setting is optional and if ommitted, the log files are
3 | // are created in the same directory that the logger DLL resides in.
4 | THORLABS_TSI_LOGGER_LOG_FILE_PATH "C:\SDK_log_files\"
5 |
6 | // Format for global log specification:
7 | // GLOBAL [log channel options] [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format]
8 | // [log channel options] ~= 'c', 'a', 'm', 'g', 'u'
9 | // c - log to the console
10 | // a - log to the master log file
11 | // m - log to the module log file
12 | // g - log to the group log file(s)
13 | // u - log to the unique (module + group) log file
14 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
15 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
16 | // All surplus log statements will be sent to a newly created log file with a name that
17 | // is derived from the original log file name.
18 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
19 | // unbounded.
20 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
21 | // If the number of log files exceeds this number, the logger will delete extra log files to
22 | // maintain this log file count. The logger will always delete the oldest log files first.
23 | // This setting is optional - if it is omitted, then the number of log files are allowed to
24 | // proliferate unbounded.
25 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
26 | // n - include the sequence number
27 | // d - include the date/time stamp
28 | // m - include the module name
29 | // p - include the log priority
30 | // t - include the thread ID
31 | // l - include the source file location
32 | // This setting is optional. If it is ommitted, none of the above
33 | // metadata is prepended to the log statement.
34 | //
35 | // NOTE: The global settings will override the corresponding settings for group and module
36 | // loggers with the exception of the log file size limit. The global log file size limit
37 | // does NOT override any other limit settings.
38 | THORLABS_TSI_LOGGER_GLOBAL camgu Trace ndmplt
39 |
40 | // Format for group log specification:
41 | // GROUP [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format]
42 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
43 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
44 | // All surplus log statements will be sent to a newly created log file with a name that
45 | // is derived from the original log file name.
46 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
47 | // unbounded.
48 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
49 | // If the number of log files exceeds this number, the logger will delete extra log files to
50 | // maintain this log file count. The logger will always delete the oldest log files first.
51 | // This setting is optional - if it is omitted, then the number of log files are allowed to
52 | // proliferate unbounded.
53 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
54 | // n - include the sequence number
55 | // d - include the date/time stamp
56 | // m - include the module name
57 | // p - include the log priority
58 | // t - include the thread ID
59 | // l - include the source file location
60 | // This setting is optional. If it is ommitted, none of the above
61 | // metadata is prepended to the log statement.
62 | THORLABS_TSI_LOGGER_GROUP Trace ndmplt
63 |
64 | // Format for console log specification:
65 | // CONSOLE [logging priority] [Log statement format]
66 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
67 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
68 | // This setting is optional. If it is ommitted, none of the above
69 | // metadata is prepended to the log statement.
70 | THORLABS_TSI_LOGGER_CONSOLE Trace ndmplt
71 |
72 | // The field separator character that is used in the log files and console loggers.
73 | THORLABS_TSI_LOGGER_FIELD_SEPARATOR_CHARACTER ,
74 |
75 | // The field decorator character is used to surround the text of each field of the log statement.
76 | THORLABS_TSI_LOGGER_FIELD_DECORATOR_CHARACTER "
77 |
78 | // The log file extension that will be used for all the generated log files.
79 | THORLABS_TSI_LOGGER_LOG_FILE_EXTENSION log
80 |
81 | // This setting allows the user to disable file buffering.
82 | // If file buffering is off, the logger will persist every log statement to disk.
83 | // This can be advantageous if the user wants to minimize data loss in the event of a catastrophic failure.
84 | // The disadvantage is that this can affect application performance - significantly if large
85 | // numbers of log statements are generated in a short period of time.
86 | // If file buffering is on, then the logging system will buffer an implementation dependent number of log statements
87 | // before writing the batch to disk.
88 | // The recommended setting is on.
89 | THORLABS_TSI_LOGGER_FILE_BUFFERING on
90 |
91 | // Format for a log module:
92 | // [Module name] [log channel options] [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format] [[function filter]]
93 | // [log channel options] ~= 'c', 'a', 'm', 'g', 'u'
94 | // c - log to the console
95 | // a - log to the master log file
96 | // m - log to the module log file
97 | // g - log to the group log file(s)
98 | // u - log to the unique (module + group) log file
99 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
100 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
101 | // All surplus log statements will be sent to a newly created log file with a name that
102 | // is derived from the original log file name.
103 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
104 | // unbounded.
105 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
106 | // If the number of log files exceeds this number, the logger will delete extra log files to
107 | // maintain this log file count. The logger will always delete the oldest log files first.
108 | // This setting is optional - if it is omitted, then the number of log files are allowed to
109 | // proliferate unbounded.
110 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
111 | // n - include the sequence number
112 | // d - include the date/time stamp
113 | // m - include the module name
114 | // p - include the log priority
115 | // t - include the thread ID
116 | // l - include the source file location
117 | // This setting is optional. If it is ommitted, none of the above
118 | // metadata is prepended to the log statement.
119 | // [[function filter]] ~= a comma separated list of function names. The function names
120 | // must exactly match the implementation dependent __FUNCTION__ macro expansion.
121 | // An empty function filter includes all functions. A non-empty list logs statements
122 | // from only those functions.
123 | ::MODULE_1 camgu Trace ndmplt []
124 | ::MODULE_2 camgu Trace ndmplt []
125 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
5 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Debug/Read_Parameters.csproj.AssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Debug/Read_Parameters.csproj.AssemblyReference.cache
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Debug/Read_Parameters.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Read_Parameters.exe.config
2 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Read_Parameters.exe
3 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Read_Parameters.pdb
4 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\obj\Debug\Read_Parameters.csproj.AssemblyReference.cache
5 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\obj\Debug\Read_Parameters.csproj.CoreCompileInputs.cache
6 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\obj\Debug\Read_Parameters.exe
7 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\obj\Debug\Read_Parameters.pdb
8 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.Core.dll
9 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.CoreInterfaces.dll
10 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.ImageData.dll
11 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.ImageDataInterfaces.dll
12 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.TLCamera.dll
13 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.TLCameraInterfaces.dll
14 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\thorlabs_tsi_camera_sdk1_cli.dll
15 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.ColorInterfaces.dll
16 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\bin\Debug\Thorlabs.TSI.PolarizationInterfaces.dll
17 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C#\Compact_Scientific_Cameras\Read_Parameters\obj\Debug\Read_Parameters.csproj.CopyComplete
18 |
--------------------------------------------------------------------------------
/C#/Compact_Scientific_Cameras/Read_Parameters/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
5 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/DCx Camera Live capture.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {09C37278-A72F-4074-AB85-5E1D69BBA47F}
8 | Exe
9 | DCx_Camera_Live_capture
10 | DCx Camera Live capture
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | x64
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | False
47 | bin\Debug\uc480DotNet.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Collections.Generic;
6 | using System.ComponentModel;
7 | using System.Data;
8 |
9 | namespace DCx_Camera_Live_capture
10 | {
11 | public class Program
12 | {
13 | private uc480.Camera Camera;
14 | public bool bLive = false;
15 | private object bmpLock;
16 | static void Main(string[] args)
17 | {
18 | // Declare variables and create camera device.
19 | var Pc = new Program();
20 | var Camera = new uc480.Camera();
21 | uc480.Defines.Status statusRet = 0;
22 |
23 | // Open Camera
24 | Console.WriteLine("Initializing Camera....");
25 | statusRet = Camera.Init();
26 |
27 | if (statusRet != uc480.Defines.Status.SUCCESS)
28 | {
29 | Console.WriteLine("Camera initializing failed");
30 | }
31 |
32 | Console.WriteLine("Allocating Memory....");
33 |
34 | // Allocate Memory.
35 | Int32 s32MemID;
36 | statusRet = Camera.Memory.Allocate(out s32MemID, true);
37 | if (statusRet != uc480.Defines.Status.SUCCESS)
38 | {
39 | Console.WriteLine("Allocate Memory failed");
40 | }
41 |
42 | statusRet = Camera.Memory.GetActive(out s32MemID);
43 | statusRet = Camera.Trigger.Set(uc480.Defines.TriggerMode.Software);
44 |
45 | // Press Enter to take Image.
46 | Console.WriteLine("Press Enter to Take Image");
47 |
48 | while (Console.ReadKey().Key != ConsoleKey.Enter)
49 | {
50 | System.Threading.Thread.Sleep(1000);
51 | // Check to see if image is available.
52 | // Forms for live capture.
53 | }
54 |
55 | statusRet = Camera.Acquisition.Freeze(6000);
56 | if (statusRet != uc480.Defines.Status.SUCCESS)
57 | {
58 | Console.WriteLine("Image capture failed");
59 | }
60 | else
61 | {
62 | Pc.bLive = true;
63 | }
64 |
65 | statusRet = Camera.Image.Save("Image test.png", s32MemID, System.Drawing.Imaging.ImageFormat.Png);
66 | if (statusRet != uc480.Defines.Status.SUCCESS)
67 | {
68 | Console.WriteLine("Saving Image failed");
69 | }
70 | else
71 | {
72 | Pc.bLive = true;
73 | }
74 |
75 | Console.WriteLine("Image saved to Debug folder. Now closing program");
76 |
77 |
78 | statusRet = Camera.Exit();
79 | Console.ReadKey();
80 |
81 | }
82 |
83 |
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DCx Camera Live capture")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DCx Camera Live capture")]
13 | [assembly: AssemblyCopyright("Copyright © 2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("09c37278-a72f-4074-ab85-5e1d69bba47f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/bin/Debug/DCx Camera Live capture.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
5 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/obj/Debug/DCx Camera Live capture.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\bin\Debug\DCx Camera Live capture.exe.config
2 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\bin\Debug\DCx Camera Live capture.exe
3 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\bin\Debug\DCx Camera Live capture.pdb
4 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\obj\Debug\DCx Camera Live capture.csproj.AssemblyReference.cache
5 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\obj\Debug\DCx Camera Live capture.csproj.SuggestedBindingRedirects.cache
6 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\obj\Debug\DCx Camera Live capture.csproj.CoreCompileInputs.cache
7 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\obj\Debug\DCx Camera Live capture.exe
8 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\obj\Debug\DCx Camera Live capture.pdb
9 | C:\Users\tmetz\OneDrive - THORLABS Inc\Desktop\VS test\DCx Camera Live capture\obj\Debug\DCx Camera Live capture.csproj.CopyComplete
10 |
--------------------------------------------------------------------------------
/C#/Obsoleted/DCx Cameras Single Frame Capture/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs:
--------------------------------------------------------------------------------
1 | //
2 | using System;
3 | using System.Reflection;
4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
5 |
--------------------------------------------------------------------------------
/C#/Obsoleted/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## This folder contains example code written for products that are obsoleted
2 |
3 | Please be aware that any examlpes here are subject to deletion if the supporting libraries are changed or the implementation is no longer able to be supported. The code and any supporting files here are expected to work with the most recent distribution of the relevant libraries unless otherwise noted.
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Compact_Scientific_Cameras.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32407.343
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Hardware_Triggering", "Hardware_Triggering\Hardware_Triggering.vcxproj", "{E5C74281-3406-4081-9724-68799B9E53BE}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Read_Parameters", "Read_Parameters\Read_Parameters.vcxproj", "{E7F2F704-9CA6-4853-BB3F-9C771E1C7152}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {E5C74281-3406-4081-9724-68799B9E53BE}.Debug|x64.ActiveCfg = Debug|x64
19 | {E5C74281-3406-4081-9724-68799B9E53BE}.Debug|x64.Build.0 = Debug|x64
20 | {E5C74281-3406-4081-9724-68799B9E53BE}.Debug|x86.ActiveCfg = Debug|Win32
21 | {E5C74281-3406-4081-9724-68799B9E53BE}.Debug|x86.Build.0 = Debug|Win32
22 | {E5C74281-3406-4081-9724-68799B9E53BE}.Release|x64.ActiveCfg = Release|x64
23 | {E5C74281-3406-4081-9724-68799B9E53BE}.Release|x64.Build.0 = Release|x64
24 | {E5C74281-3406-4081-9724-68799B9E53BE}.Release|x86.ActiveCfg = Release|Win32
25 | {E5C74281-3406-4081-9724-68799B9E53BE}.Release|x86.Build.0 = Release|Win32
26 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Debug|x64.ActiveCfg = Debug|x64
27 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Debug|x64.Build.0 = Debug|x64
28 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Debug|x86.ActiveCfg = Debug|Win32
29 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Debug|x86.Build.0 = Debug|Win32
30 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Release|x64.ActiveCfg = Release|x64
31 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Release|x64.Build.0 = Release|x64
32 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Release|x86.ActiveCfg = Release|Win32
33 | {E7F2F704-9CA6-4853-BB3F-9C771E1C7152}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {0BC2D696-8F57-4829-A705-84803BDC9B0E}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Hardware_Triggering/Hardware_Triggering.cpp:
--------------------------------------------------------------------------------
1 | // Hardware_Triggering.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include "tl_camera_sdk.h"
8 | #include "tl_camera_sdk_load.h"
9 | #ifdef __linux__
10 | #include
11 | #endif
12 | int is_camera_sdk_open = 0;
13 | int is_camera_dll_open = 0;
14 | void* camera_handle = 0;
15 |
16 | int report_error_and_cleanup_resources(const char* error_string);
17 | int initialize_camera_resources();
18 |
19 | int main()
20 | {
21 | //Initialize the camera by calling the helper function
22 | if (initialize_camera_resources())
23 | return 1;
24 |
25 | //Set the exposure time in microseconds
26 | long long exposure_time = 10000;
27 | if (tl_camera_set_exposure_time(camera_handle, exposure_time))
28 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
29 |
30 | // Configure camera for single-shot acquisition by setting the number of frames to 1.
31 | if (tl_camera_set_frames_per_trigger_zero_for_unlimited(camera_handle, 1))
32 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
33 |
34 | //Check if hardware triggering is supported. If it is, set the camera operating mode to accept a hardware trigger.
35 | int is_hardware_triggering_supported;
36 | tl_camera_get_is_operation_mode_supported(camera_handle, TL_CAMERA_OPERATION_MODE_HARDWARE_TRIGGERED, &is_hardware_triggering_supported);
37 | if (is_hardware_triggering_supported)
38 | {
39 | //Set the trigger polarity for hardware triggers (ACTIVE_HIGH or ACTIVE_LOW)
40 | if (tl_camera_set_trigger_polarity(camera_handle, TL_CAMERA_TRIGGER_POLARITY_ACTIVE_HIGH))
41 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
42 |
43 | if (tl_camera_set_operation_mode(camera_handle, TL_CAMERA_OPERATION_MODE_HARDWARE_TRIGGERED))
44 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
45 | std::cout << "Hardware trigger set\n";
46 | }
47 | else {
48 | report_error_and_cleanup_resources("Camera does not support hardware triggering");
49 | }
50 |
51 | // Set camera to wait 100 ms for a frame to arrive during a poll.
52 | // If an image is not received in 100ms, the returned frame will be null
53 | if (tl_camera_set_image_poll_timeout(camera_handle, 100))
54 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
55 |
56 | // Arm the camera.
57 | if (tl_camera_arm(camera_handle, 2))
58 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
59 | std::cout << "Camera Armed\n";
60 |
61 | //initialize frame variables
62 | unsigned short* image_buffer = 0;
63 | int frame_count = 0;
64 | unsigned char* metadata = 0;
65 | int metadata_size_in_bytes = 0;
66 |
67 | //Loop until 5 images are received.
68 | std::cout << "Waiting for images\n";
69 | int num_images_acquired = 0;
70 | while (num_images_acquired < 5)
71 | {
72 | //Poll for an available image
73 | if (tl_camera_get_pending_frame_or_null(camera_handle, &image_buffer, &frame_count, &metadata, &metadata_size_in_bytes))
74 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
75 | if (!image_buffer)
76 | {
77 | //A small sleep is used to prevent too many calls to the camera.
78 | #ifdef _WIN32
79 | Sleep(50);
80 | #elif defined __linux__
81 | usleep(50000);
82 | #endif
83 | continue; //Timeout case. Skip this loop iteration
84 | }
85 |
86 | std::cout << "Pointer to Image: 0x"<< image_buffer << "\n";
87 | std::cout << "Frame Count " << frame_count << "\n\n";
88 |
89 | num_images_acquired++;
90 | }
91 |
92 | // Stop the camera
93 | if (tl_camera_disarm(camera_handle))
94 | std::cout <<"Failed to stop the camera!\n";
95 |
96 | // Clean up and exit
97 | return report_error_and_cleanup_resources(0);
98 | }
99 |
100 |
101 | //
102 | // Helper functions for opening and closing camera
103 | //
104 | int initialize_camera_resources()
105 | {
106 | // Initializes camera dll
107 | if (tl_camera_sdk_dll_initialize())
108 | return report_error_and_cleanup_resources("Failed to initialize dll!\n");
109 | std::cout << "Successfully initialized dll\n";
110 | is_camera_dll_open = 1;
111 |
112 | // Open the camera SDK
113 | if (tl_camera_open_sdk())
114 | return report_error_and_cleanup_resources("Failed to open SDK!\n");
115 | std::cout << "Successfully Opened SDK\n";
116 | is_camera_sdk_open = 1;
117 |
118 | char camera_ids[1024];
119 | camera_ids[0] = 0;
120 |
121 | // Discover cameras.
122 | if (tl_camera_discover_available_cameras(camera_ids, 1024))
123 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
124 | std::cout << "Available Camera ID's: " << camera_ids << "\n";
125 |
126 | // Check for no cameras.
127 | if (!strlen(camera_ids))
128 | return report_error_and_cleanup_resources("Did not find any cameras!\n");
129 |
130 | // Camera IDs are separated by spaces.
131 | char* p_space = strchr(camera_ids, ' ');
132 | if (p_space)
133 | *p_space = '\0'; // isolate the first detected camera
134 | char first_camera[256];
135 |
136 | // Copy the ID of the first camera to separate buffer (for clarity)
137 | #ifdef _WIN32
138 | strcpy_s(first_camera, 256, camera_ids);
139 | #elif defined __linux__
140 | strcpy(first_camera, camera_ids);
141 | #endif
142 | std::cout << "ID of First Camera: " << first_camera << "\n";
143 |
144 | // Connect to the camera(get a handle to it).
145 | if (tl_camera_open_camera(first_camera, &camera_handle))
146 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
147 | std::cout << "Camera Handle: " << camera_handle << "\n";
148 |
149 | return 0;
150 | }
151 |
152 |
153 | int report_error_and_cleanup_resources(const char* error_string)
154 | {
155 | int num_errors = 0;
156 |
157 | if (error_string)
158 | {
159 | std::cout << error_string << "\n";
160 | num_errors++;
161 | }
162 |
163 | std::cout << "Closing all resources...\n";
164 |
165 | if (camera_handle)
166 | {
167 | if (tl_camera_close_camera(camera_handle))
168 | {
169 | std::cout << "Failed to close camera! Error: " << tl_camera_get_last_error() << "\n";
170 | num_errors++;
171 | }
172 | camera_handle = 0;
173 | }
174 | if (is_camera_sdk_open)
175 | {
176 | if (tl_camera_close_sdk())
177 | {
178 | std::cout << "Failed to close SDK!\n";
179 | num_errors++;
180 | }
181 | is_camera_sdk_open = 0;
182 | }
183 | if (is_camera_dll_open)
184 | {
185 | if (tl_camera_sdk_dll_terminate())
186 | {
187 | std::cout << "Failed to close DLL!\n";
188 | num_errors++;
189 | }
190 | is_camera_dll_open = 0;
191 | }
192 |
193 | std::cout << "Clean up finished\n";
194 | return num_errors;
195 | }
196 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Hardware_Triggering/Hardware_Triggering.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {e5c74281-3406-4081-9724-68799b9e53be}
25 | HardwareTriggering
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v143
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v143
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v143
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v143
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | false
78 |
79 |
80 | true
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Level3
88 | true
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Level3
100 | true
101 | true
102 | true
103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
104 | true
105 |
106 |
107 | Console
108 | true
109 | true
110 | true
111 |
112 |
113 |
114 |
115 | Level3
116 | true
117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 | C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\load_dll_helpers;C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\include;%(AdditionalIncludeDirectories)
120 |
121 |
122 | Console
123 | true
124 |
125 |
126 |
127 |
128 | Level3
129 | true
130 | true
131 | true
132 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
133 | true
134 |
135 |
136 | Console
137 | true
138 | true
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Hardware_Triggering/Hardware_Triggering.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Hardware_Triggering/x64/Debug/Hardware_Triggering.exe.recipe:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | C:\Users\manzelmi\Documents\Compact_Scientific_Cameras\x64\Debug\Hardware_Triggering.exe
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/README.md:
--------------------------------------------------------------------------------
1 | ## Included Examples
2 |
3 | ### Hardware Triggering:
4 | This examples initializes the first detected camera and sets up for hardware triggering. A loop is started that waits for 5 images to be requested and received.
5 |
6 | ### Read Parameters:
7 | This example goes through common settable/gettable parameters for the cameras and prints them to console. This also shows how to interpret returns from cameras that are not compatible with certain settings.
8 |
9 | ## Build Instructions
10 |
11 | 0. If you have not done so already unzip the following folder to an accesible location on your drive. This contains the Camera SDK.
12 |
13 | * 32-Bit - C:\Program Files (x86)\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
14 | * 64-Bit - C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
15 | This example will use the dll's here: \Scientific Camera Interfaces\SDK\Native Toolkit\dlls
16 |
17 | 1. Select the desired project from the Visial Studio Solution by right clicking and selecting "Set as Startup Project"
18 | 2. Change the Solution platform to match the bit version of the dll's.
19 | 3. From the Project Properties under the C/C++ section, add the following locations as Additional Include Directories:
20 | * C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\include
21 | * C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\load_dll_helpers
22 | 4. Right Click on the desired project from the Solution Explorer and select Add -> Existing Item
23 | and add the c source files from C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\load_dll_helpers
24 | This is done already in the solution, but it is recommended to check and redo in case you are using a different location for your dll's and helpers
25 | 5. Copy the dll's from \Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\dlls\Native_64_lib to the bin of the project:\Compact_Scientific_Cameras\x64\Debug\
26 | NOTE: All Projects in the solution will share an output directory
27 |
28 |
29 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Read_Parameters/Read_Parameters.cpp:
--------------------------------------------------------------------------------
1 | // Read_Parameters.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include "tl_camera_sdk.h"
8 | #include "tl_camera_sdk_load.h"
9 |
10 | int is_camera_sdk_open = 0;
11 | int is_camera_dll_open = 0;
12 | void* camera_handle = 0;
13 |
14 | int report_error_and_cleanup_resources(const char* error_string);
15 | int initialize_camera_resources();
16 |
17 | int main()
18 | {
19 | //Initialize the camera by calling the helper function
20 | if (initialize_camera_resources())
21 | return 1;
22 |
23 | //Get Camera Info e.g. Model, Name, Firmware Version
24 | char model_name[256];
25 | tl_camera_get_model(camera_handle, model_name, 256);
26 | std::cout << "Model Name: " << model_name << "\n";
27 |
28 | char camera_name[256];
29 | tl_camera_get_name(camera_handle, camera_name, 256); // Camera name can be changed by the user
30 | std::cout << "Camera Name: " << camera_name << "\n";
31 |
32 | char firmware_version[256];
33 | tl_camera_get_firmware_version(camera_handle, firmware_version, 256);
34 | std::cout << "Firmware Version: " << firmware_version << "\n";
35 |
36 | //Get Sensor Type
37 |
38 | TL_CAMERA_SENSOR_TYPE sensor_type;
39 | tl_camera_get_camera_sensor_type(camera_handle, &sensor_type);
40 | std::cout << "Sensor Type: " << sensor_type << "\n";
41 |
42 | //Get the camera sensor dimensions in pixels
43 | int sensor_width;
44 | int sensor_height;
45 | tl_camera_get_sensor_width(camera_handle, &sensor_width);
46 | tl_camera_get_sensor_height(camera_handle, &sensor_height);
47 | std::cout << "Sensor Witdh: " << sensor_width << "\n";
48 | std::cout << "Sensor Height: " << sensor_height << "\n";
49 |
50 | //Get Camera Bit Depth
51 | int bit_depth;
52 | tl_camera_get_bit_depth(camera_handle, &bit_depth);
53 | std::cout << "Sensor Bit Depth: " << bit_depth << "\n";
54 |
55 | //Get Exposure Time Range
56 | long long exposure_min;
57 | long long exposure_max;
58 | if (tl_camera_get_exposure_time_range(camera_handle, &exposure_min, &exposure_max))
59 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
60 | std::cout << "Exposure Minimum: " << exposure_min << "\n";
61 | std::cout << "Exposure Maximum: " << exposure_max << "\n";
62 |
63 | //Set and Get Exposure Time
64 | long long exposure_time;
65 | if (tl_camera_set_exposure_time(camera_handle, 10000))
66 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
67 | if (tl_camera_get_exposure_time(camera_handle, &exposure_time))
68 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
69 | std::cout << "Exposure Time: " << exposure_time << "\n";
70 |
71 | //Get Frames Per Trigger Range
72 | u_int frames_per_trigger_min;
73 | u_int frames_per_trigger_max;
74 | if (tl_camera_get_frames_per_trigger_range(camera_handle, &frames_per_trigger_min, &frames_per_trigger_max))
75 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
76 | std::cout << "Frames per Trigger Minimum: " << frames_per_trigger_min << "\n";
77 | std::cout << "Frames per Trigger Maximum: " << frames_per_trigger_max << "\n";
78 |
79 | //Set and Get Frames per Trigger
80 | u_int frames_per_trigger;
81 | if (tl_camera_set_frames_per_trigger_zero_for_unlimited(camera_handle, 1))
82 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
83 | if (tl_camera_get_frames_per_trigger_zero_for_unlimited(camera_handle, &frames_per_trigger))
84 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
85 | std::cout << "Frames per trigger: " << frames_per_trigger << "\n";
86 |
87 | //Check if camera supports adjusting framerate and check range
88 | double frame_rate_control_min;
89 | double frame_rate_control_max;
90 |
91 | if (tl_camera_get_frame_rate_control_value_range(camera_handle, &frame_rate_control_min, &frame_rate_control_max))
92 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
93 | std::cout << "Frame Rate Control Valiue Minimum: " << frame_rate_control_min << "\n";
94 | std::cout << "Frame Rate Control Valiue Maximum: " << frame_rate_control_max << "\n";
95 |
96 | if (frame_rate_control_max > 0)
97 | {
98 | //this camera supports adjusting the frame rate, set and get it
99 | if (tl_camera_set_frame_rate_control_value(camera_handle, 10.5))
100 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
101 |
102 | double frame_rate_control_value;
103 | if (tl_camera_get_frame_rate_control_value(camera_handle, &frame_rate_control_value))
104 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
105 | std::cout << "Frame Rate Control Value: " << frame_rate_control_value << "\n";
106 | }
107 |
108 | //Check if camera supports adjusting gain and check range
109 | int gain_min;
110 | int gain_max;
111 | if (tl_camera_get_gain_range(camera_handle, &gain_min, &gain_max))
112 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
113 | std::cout << "Gain Minimum: " << gain_min << "\n";
114 | std::cout << "Gain Maximum: " << gain_max << "\n";
115 | if (gain_max > 0)
116 | {
117 | // this camera supports gain, set and get it
118 | int gain_index;
119 | //Gain units can vary by camera. Use the helper function to set these for the camera
120 | if (tl_camera_convert_decibels_to_gain(camera_handle, 6.0, &gain_index))
121 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
122 | if (tl_camera_set_gain(camera_handle, gain_index))
123 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
124 |
125 | double gain_value_dB;
126 | if (tl_camera_get_gain(camera_handle, &gain_index))
127 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
128 | if (tl_camera_convert_gain_to_decibels(camera_handle, gain_index, &gain_value_dB))
129 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
130 | std::cout << "Gain Index: " << gain_index << " Gain Value in dB: " << gain_value_dB << "\n";
131 | }
132 |
133 | //Check if camera supports adjusting black level and check range
134 | int black_level_min;
135 | int black_level_max;
136 | if (tl_camera_get_black_level_range(camera_handle, &black_level_min, &black_level_max))
137 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
138 | std::cout << "Black Level Minimum: " << black_level_min << "\n";
139 | std::cout << "Black Level Maximum: " << black_level_max << "\n";
140 | if (black_level_max > 0)
141 | {
142 | // this camera supports setting the black level, set and get it
143 | if (tl_camera_set_black_level(camera_handle, 100))
144 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
145 |
146 | int black_level;
147 | if (tl_camera_get_black_level(camera_handle, &black_level))
148 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
149 | std::cout << "Black Level: " << black_level << "\n";
150 | }
151 |
152 | //Check if hardware triggering is supported. If it is, set the camera operating mode to accept a hardware trigger.
153 | int is_hardware_triggering_supported;
154 | tl_camera_get_is_operation_mode_supported(camera_handle, TL_CAMERA_OPERATION_MODE_HARDWARE_TRIGGERED, &is_hardware_triggering_supported);
155 | if (is_hardware_triggering_supported)
156 | {
157 | //Set the trigger polarity for hardware triggers (ACTIVE_HIGH or ACTIVE_LOW)
158 | if (tl_camera_set_trigger_polarity(camera_handle, TL_CAMERA_TRIGGER_POLARITY_ACTIVE_HIGH))
159 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
160 |
161 | if (tl_camera_set_operation_mode(camera_handle, TL_CAMERA_OPERATION_MODE_HARDWARE_TRIGGERED))
162 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
163 | std::cout << "Hardware trigger set\n";
164 | }
165 |
166 | //Set ROI and Bin Values
167 | if (tl_camera_set_roi(camera_handle, 0, 0, 100, 100)) // int upper_left_x_pixels, int upper_left_y_pixels, int lower_right_x_pixels, int lower_right_y_pixels
168 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
169 | if (tl_camera_set_binx(camera_handle, 1))
170 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
171 | if (tl_camera_set_biny(camera_handle, 1))
172 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
173 |
174 | //Get ROI and Bin Values
175 | int binx, biny;
176 | int upper_left_x_pixels, upper_left_y_pixels, lower_right_x_pixels, lower_right_y_pixels;
177 | if (tl_camera_get_binx(camera_handle, &binx))
178 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
179 | if (tl_camera_get_biny(camera_handle, &biny))
180 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
181 | if (tl_camera_get_roi(camera_handle, &upper_left_x_pixels, &upper_left_y_pixels, &lower_right_x_pixels, &lower_right_y_pixels))
182 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
183 |
184 | std::cout << "Bin X Value: " << binx << "\n";
185 | std::cout << "Bin Y Value: " << biny << "\n";
186 | std::cout << "ROI Values - Upper Left X: " << upper_left_x_pixels << " Upper Left Y: " << upper_left_y_pixels << " Lower Right X: " << lower_right_x_pixels << " Lower Right Y: " << lower_right_y_pixels << "\n";
187 |
188 | // Clean up and exit
189 | return report_error_and_cleanup_resources(0);
190 | }
191 |
192 |
193 |
194 | //
195 | // Helper functions for opening and closing camera
196 | //
197 | int initialize_camera_resources()
198 | {
199 | // Initializes camera dll
200 | if (tl_camera_sdk_dll_initialize())
201 | return report_error_and_cleanup_resources("Failed to initialize dll!\n");
202 | std::cout << "Successfully initialized dll\n";
203 | is_camera_dll_open = 1;
204 |
205 | // Open the camera SDK
206 | if (tl_camera_open_sdk())
207 | return report_error_and_cleanup_resources("Failed to open SDK!\n");
208 | std::cout << "Successfully Opened SDK\n";
209 | is_camera_sdk_open = 1;
210 |
211 | char camera_ids[1024];
212 | camera_ids[0] = 0;
213 |
214 | // Discover cameras.
215 | if (tl_camera_discover_available_cameras(camera_ids, 1024))
216 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
217 | std::cout << "Available Camera ID's: " << camera_ids << "\n";
218 |
219 | // Check for no cameras.
220 | if (!strlen(camera_ids))
221 | return report_error_and_cleanup_resources("Did not find any cameras!\n");
222 |
223 | // Camera IDs are separated by spaces.
224 | char* p_space = strchr(camera_ids, ' ');
225 | if (p_space)
226 | *p_space = '\0'; // isolate the first detected camera
227 | char first_camera[256];
228 |
229 | // Copy the ID of the first camera to separate buffer (for clarity)
230 | #ifdef _WIN32
231 | strcpy_s(first_camera, 256, camera_ids);
232 | #elif defined __linux__
233 | strcpy(first_camera, camera_ids);
234 | #endif
235 | std::cout << "ID of First Camera: " << first_camera << "\n";
236 |
237 | // Connect to the camera(get a handle to it).
238 | if (tl_camera_open_camera(first_camera, &camera_handle))
239 | return report_error_and_cleanup_resources(tl_camera_get_last_error());
240 | std::cout << "Camera Handle: " << camera_handle << "\n";
241 |
242 | return 0;
243 | }
244 |
245 |
246 | int report_error_and_cleanup_resources(const char* error_string)
247 | {
248 | int num_errors = 0;
249 |
250 | if (error_string)
251 | {
252 | std::cout << error_string << "\n";
253 | num_errors++;
254 | }
255 |
256 | std::cout << "Closing all resources...\n";
257 |
258 | if (camera_handle)
259 | {
260 | if (tl_camera_close_camera(camera_handle))
261 | {
262 | std::cout << "Failed to close camera! Error: " << tl_camera_get_last_error() << "\n";
263 | num_errors++;
264 | }
265 | camera_handle = 0;
266 | }
267 | if (is_camera_sdk_open)
268 | {
269 | if (tl_camera_close_sdk())
270 | {
271 | std::cout << "Failed to close SDK!\n";
272 | num_errors++;
273 | }
274 | is_camera_sdk_open = 0;
275 | }
276 | if (is_camera_dll_open)
277 | {
278 | if (tl_camera_sdk_dll_terminate())
279 | {
280 | std::cout << "Failed to close DLL!\n";
281 | num_errors++;
282 | }
283 | is_camera_dll_open = 0;
284 | }
285 |
286 | std::cout << "Clean up finished\n";
287 | return num_errors;
288 | }
289 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Read_Parameters/Read_Parameters.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {e7f2f704-9ca6-4853-bb3f-9c771e1c7152}
25 | ReadParameters
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v143
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v143
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v143
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v143
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | false
78 |
79 |
80 | true
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Level3
88 | true
89 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
90 | true
91 |
92 |
93 | Console
94 | true
95 |
96 |
97 |
98 |
99 | Level3
100 | true
101 | true
102 | true
103 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
104 | true
105 |
106 |
107 | Console
108 | true
109 | true
110 | true
111 |
112 |
113 |
114 |
115 | Level3
116 | true
117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
118 | true
119 | C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\load_dll_helpers;C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces\SDK\Native Toolkit\include;%(AdditionalIncludeDirectories)
120 |
121 |
122 | Console
123 | true
124 |
125 |
126 |
127 |
128 | Level3
129 | true
130 | true
131 | true
132 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
133 | true
134 |
135 |
136 | Console
137 | true
138 | true
139 | true
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Read_Parameters/Read_Parameters.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/Read_Parameters/x64/Debug/Read_Parameters.exe.recipe:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | C:\Users\manzelmi\Documents\Tech_Github\Camera_Examples\C++\Compact_Scientific_Cameras\x64\Debug\Read_Parameters.exe
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/linux_make_files/MakeFile:
--------------------------------------------------------------------------------
1 | #This is a makefile for building the Read_Parameters and Hardware_Triggering examples
2 | #The folder should be setup with this make file in the top level directory
3 | #Directories titled "include", "examples", and "load_dll_helpers" should be created alongside the makefile. These should contain the files from the linux installation in \Scientific_Camera_Interfaces\SDK\Native_Toolkit\
4 | #The examples to build should be copied to the "examples folder"
5 | #To build the examples, open a terminal in the makefile location and run the command "make"
6 |
7 | CAMERA_HEADERS = ./include/tl_camera_sdk.h ./load_dll_helpers/tl_camera_sdk_load.h
8 | COLOR_HEADERS = ./include/tl_mono_to_color_processing.h ./include/tl_mono_to_color_enum.h ./load_dll_helpers/tl_mono_to_color_processing_load.h
9 | ADVANCED_COLOR_HEADERS = ./include/tl_color_processing.h ./include/tl_color_LUT.h ./include/tl_color_enum.h ./include/tl_color_demosaic.h ./load_dll_helpers/tl_color_processing_load.h ./load_dll_helpers/tl_color_demosaic_load.h ./load_dll_helpers/tl_color_processing_load.h
10 | POLAR_HEADERS = ./include/tl_polarization_processor.h ./include/tl_polarization_processor_enums.h ./include/tl_polarization_processor_error.h ./load_dll_helpers/tl_polarization_processor_load.h
11 | INCLUDE = -I./include -I./load_dll_helpers
12 | OBJ_DIR = ./obj/
13 |
14 | # targets for examples
15 | all: Read_Parameters Hardware_Triggering
16 |
17 | Read_Parameters: $(OBJ_DIR)Read_Parameters.o $(OBJ_DIR)tl_camera_sdk_load.o
18 | g++ -o Read_Parameters $(OBJ_DIR)Read_Parameters.o $(OBJ_DIR)tl_camera_sdk_load.o -Wl,--no-as-needed -ldl
19 |
20 | Hardware_Triggering: $(OBJ_DIR)Hardware_Triggering.o $(OBJ_DIR)tl_camera_sdk_load.o
21 | g++ -o Hardware_Triggering $(OBJ_DIR)Hardware_Triggering.o $(OBJ_DIR)tl_camera_sdk_load.o -Wl,--no-as-needed -ldl
22 |
23 | # targets for the load files to help with integrating shared library SDK functions
24 |
25 | $(OBJ_DIR)tl_camera_sdk_load.o: $(OBJ_DIR) ./load_dll_helpers/tl_camera_sdk_load.c $(CAMERA_HEADERS)
26 | gcc -c ./load_dll_helpers/tl_camera_sdk_load.c $(INCLUDE) -o $(OBJ_DIR)tl_camera_sdk_load.o
27 |
28 | $(OBJ_DIR)tl_mono_to_color_processing_load.o: $(OBJ_DIR) ./load_dll_helpers/tl_mono_to_color_processing_load.c $(CAMERA_HEADERS)
29 | gcc -c ./load_dll_helpers/tl_mono_to_color_processing_load.c $(INCLUDE) -o $(OBJ_DIR)tl_mono_to_color_processing_load.o
30 |
31 | $(OBJ_DIR)tl_color_demosaic_load.o: $(OBJ_DIR) ./load_dll_helpers/tl_color_demosaic_load.c $(CAMERA_HEADERS)
32 | gcc -c ./load_dll_helpers/tl_color_demosaic_load.c $(INCLUDE) -o $(OBJ_DIR)tl_color_demosaic_load.o
33 |
34 | $(OBJ_DIR)tl_color_processing_load.o: $(OBJ_DIR) ./load_dll_helpers/tl_color_processing_load.c $(CAMERA_HEADERS)
35 | gcc -c ./load_dll_helpers/tl_color_processing_load.c $(INCLUDE) -o $(OBJ_DIR)tl_color_processing_load.o
36 |
37 | $(OBJ_DIR)tl_polarization_processor_load.o: $(OBJ_DIR) ./load_dll_helpers/tl_polarization_processor_load.c $(POLAR_HEADERS)
38 | gcc -c ./load_dll_helpers/tl_polarization_processor_load.c $(INCLUDE) -o $(OBJ_DIR)tl_polarization_processor_load.o
39 |
40 | # targets for the example source code files
41 | $(OBJ_DIR)Read_Parameters.o: $(OBJ_DIR) ./examples/Read_Parameters.cpp $(CAMERA_HEADERS)
42 | gcc -c ./examples/Read_Parameters.cpp -o $(OBJ_DIR)Read_Parameters.o $(INCLUDE)
43 |
44 | $(OBJ_DIR)Hardware_Triggering.o: $(OBJ_DIR) ./examples/Hardware_Triggering.cpp $(CAMERA_HEADERS)
45 | gcc -c ./examples/Hardware_Triggering.cpp -o $(OBJ_DIR)Hardware_Triggering.o $(INCLUDE)
46 |
47 | $(OBJ_DIR):
48 | mkdir -p ./obj
49 |
50 | # cleanup
51 |
52 | clean:
53 | -rm -f Example_C_Camera_Interface_*
54 | -rm tl_*_load.o
55 |
--------------------------------------------------------------------------------
/C++/Compact_Scientific_Cameras/x64/Debug/thorlabs_tsi_logger.cfg:
--------------------------------------------------------------------------------
1 | // Specifies the path where the log files are created.
2 | // This setting is optional and if ommitted, the log files are
3 | // are created in the same directory that the logger DLL resides in.
4 | THORLABS_TSI_LOGGER_LOG_FILE_PATH "C:\SDK_log_files\"
5 |
6 | // Format for global log specification:
7 | // GLOBAL [log channel options] [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format]
8 | // [log channel options] ~= 'c', 'a', 'm', 'g', 'u'
9 | // c - log to the console
10 | // a - log to the master log file
11 | // m - log to the module log file
12 | // g - log to the group log file(s)
13 | // u - log to the unique (module + group) log file
14 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
15 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
16 | // All surplus log statements will be sent to a newly created log file with a name that
17 | // is derived from the original log file name.
18 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
19 | // unbounded.
20 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
21 | // If the number of log files exceeds this number, the logger will delete extra log files to
22 | // maintain this log file count. The logger will always delete the oldest log files first.
23 | // This setting is optional - if it is omitted, then the number of log files are allowed to
24 | // proliferate unbounded.
25 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
26 | // n - include the sequence number
27 | // d - include the date/time stamp
28 | // m - include the module name
29 | // p - include the log priority
30 | // t - include the thread ID
31 | // l - include the source file location
32 | // This setting is optional. If it is ommitted, none of the above
33 | // metadata is prepended to the log statement.
34 | //
35 | // NOTE: The global settings will override the corresponding settings for group and module
36 | // loggers with the exception of the log file size limit. The global log file size limit
37 | // does NOT override any other limit settings.
38 | THORLABS_TSI_LOGGER_GLOBAL camgu Trace ndmplt
39 |
40 | // Format for group log specification:
41 | // GROUP [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format]
42 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
43 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
44 | // All surplus log statements will be sent to a newly created log file with a name that
45 | // is derived from the original log file name.
46 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
47 | // unbounded.
48 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
49 | // If the number of log files exceeds this number, the logger will delete extra log files to
50 | // maintain this log file count. The logger will always delete the oldest log files first.
51 | // This setting is optional - if it is omitted, then the number of log files are allowed to
52 | // proliferate unbounded.
53 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
54 | // n - include the sequence number
55 | // d - include the date/time stamp
56 | // m - include the module name
57 | // p - include the log priority
58 | // t - include the thread ID
59 | // l - include the source file location
60 | // This setting is optional. If it is ommitted, none of the above
61 | // metadata is prepended to the log statement.
62 | THORLABS_TSI_LOGGER_GROUP Trace ndmplt
63 |
64 | // Format for console log specification:
65 | // CONSOLE [logging priority] [Log statement format]
66 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
67 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
68 | // This setting is optional. If it is ommitted, none of the above
69 | // metadata is prepended to the log statement.
70 | THORLABS_TSI_LOGGER_CONSOLE Trace ndmplt
71 |
72 | // The field separator character that is used in the log files and console loggers.
73 | THORLABS_TSI_LOGGER_FIELD_SEPARATOR_CHARACTER ,
74 |
75 | // The field decorator character is used to surround the text of each field of the log statement.
76 | THORLABS_TSI_LOGGER_FIELD_DECORATOR_CHARACTER "
77 |
78 | // The log file extension that will be used for all the generated log files.
79 | THORLABS_TSI_LOGGER_LOG_FILE_EXTENSION log
80 |
81 | // This setting allows the user to disable file buffering.
82 | // If file buffering is off, the logger will persist every log statement to disk.
83 | // This can be advantageous if the user wants to minimize data loss in the event of a catastrophic failure.
84 | // The disadvantage is that this can affect application performance - significantly if large
85 | // numbers of log statements are generated in a short period of time.
86 | // If file buffering is on, then the logging system will buffer an implementation dependent number of log statements
87 | // before writing the batch to disk.
88 | // The recommended setting is on.
89 | THORLABS_TSI_LOGGER_FILE_BUFFERING on
90 |
91 | // Format for a log module:
92 | // [Module name] [log channel options] [logging priority] [Log file size limit in MB] [Number of log files to keep] [Log statement format] [[function filter]]
93 | // [log channel options] ~= 'c', 'a', 'm', 'g', 'u'
94 | // c - log to the console
95 | // a - log to the master log file
96 | // m - log to the module log file
97 | // g - log to the group log file(s)
98 | // u - log to the unique (module + group) log file
99 | // [logging priority] ~= [Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace]
100 | // [Log file size limit in MB] ~= specifies an integral limit in MB for the log file size.
101 | // All surplus log statements will be sent to a newly created log file with a name that
102 | // is derived from the original log file name.
103 | // This setting is optional - if it is ommitted, then the log file is allowed to grow
104 | // unbounded.
105 | // [Number of log files to keep] ~= specifies the number of log files of this type to preserve.
106 | // If the number of log files exceeds this number, the logger will delete extra log files to
107 | // maintain this log file count. The logger will always delete the oldest log files first.
108 | // This setting is optional - if it is omitted, then the number of log files are allowed to
109 | // proliferate unbounded.
110 | // [Log statement format] ~= 'n', 'd', 'm', 'p', 'l', 't'
111 | // n - include the sequence number
112 | // d - include the date/time stamp
113 | // m - include the module name
114 | // p - include the log priority
115 | // t - include the thread ID
116 | // l - include the source file location
117 | // This setting is optional. If it is ommitted, none of the above
118 | // metadata is prepended to the log statement.
119 | // [[function filter]] ~= a comma separated list of function names. The function names
120 | // must exactly match the implementation dependent __FUNCTION__ macro expansion.
121 | // An empty function filter includes all functions. A non-empty list logs statements
122 | // from only those functions.
123 | ::MODULE_1 camgu Trace ndmplt []
124 | ::MODULE_2 camgu Trace ndmplt []
125 |
--------------------------------------------------------------------------------
/C++/Obsoleted/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## This folder contains example code written for products that are obsoleted
2 |
3 | Please be aware that any examlpes here are subject to deletion if the supporting libraries are changed or the implementation is no longer able to be supported. The code and any supporting files here are expected to work with the most recent distribution of the relevant libraries unless otherwise noted.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Thorlabs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MATLAB/Compact_Scientific_Cameras/ColorProcessing.m:
--------------------------------------------------------------------------------
1 | % Matlab sample for using TSICamera and color processing DotNET interface
2 | % with color camera. Demonstrates how to set up custom color processing.
3 |
4 | clear
5 | close all
6 |
7 | % Load TLCamera DotNet assembly. The assembly .dll is assumed to be in the
8 | % same folder as the scripts.
9 | NET.addAssembly([pwd, '\Thorlabs.TSI.TLCamera.dll']);
10 | disp('Dot NET assembly loaded.');
11 |
12 | tlCameraSDK = Thorlabs.TSI.TLCamera.TLCameraSDK.OpenTLCameraSDK;
13 |
14 | % Get serial numbers of connected TLCameras.
15 | serialNumbers = tlCameraSDK.DiscoverAvailableCameras;
16 | disp([num2str(serialNumbers.Count), ' camera was discovered.']);
17 |
18 | if (serialNumbers.Count > 0)
19 | % Open the first TLCamera using the serial number.
20 | disp('Opening the first camera')
21 | tlCamera = tlCameraSDK.OpenCamera(serialNumbers.Item(0), false);
22 |
23 | % Check if the camera is Color.
24 | cameraSensorType = tlCamera.CameraSensorType;
25 | isColorCamera = cameraSensorType == Thorlabs.TSI.TLCameraInterfaces.CameraSensorType.Bayer;
26 | if (isColorCamera)
27 | % Load color processing .NET assemblies
28 | NET.addAssembly([pwd, '\Thorlabs.TSI.Demosaicker.dll']);
29 | NET.addAssembly([pwd, '\Thorlabs.TSI.ColorProcessor.dll']);
30 |
31 | % Initialize the demosaicker
32 | demosaicker = Thorlabs.TSI.Demosaicker.Demosaicker;
33 | % Create color processor SDK.
34 | colorProcessorSDK = Thorlabs.TSI.ColorProcessor.ColorProcessorSDK;
35 |
36 | % Query the default white balance matrix from camera. Alternatively
37 | % can also use user defined white balance matrix.
38 | defaultWhiteBalanceMatrix = tlCamera.GetDefaultWhiteBalanceMatrix;
39 |
40 | % Query other relevant camera information
41 | cameraColorCorrectionMatrix = tlCamera.GetCameraColorCorrectionMatrix;
42 | bitDepth = int32(tlCamera.BitDepth);
43 | colorFilterArrayPhase = tlCamera.ColorFilterArrayPhase;
44 |
45 | % Create standard RGB color processing pipeline.
46 | standardRGBColorProcessor = colorProcessorSDK.CreateStandardRGBColorProcessor(defaultWhiteBalanceMatrix,...
47 | cameraColorCorrectionMatrix, bitDepth);
48 | end
49 |
50 | % Set exposure time and gain of the camera.
51 | tlCamera.ExposureTime_us = 200000;
52 |
53 | figure(1)
54 |
55 | % Check if the camera supports setting "Gain"
56 | gainRange = tlCamera.GainRange;
57 | if (gainRange.Maximum > 0)
58 | tlCamera.Gain = 0;
59 | end
60 |
61 | % Set the FIFO frame buffer size. Default size is 1.
62 | tlCamera.MaximumNumberOfFramesToQueue = 5;
63 |
64 | % Start continuous image acquisition
65 | disp('Starting continuous image acquisition.');
66 | tlCamera.OperationMode = Thorlabs.TSI.TLCameraInterfaces.OperationMode.SoftwareTriggered;
67 | tlCamera.FramesPerTrigger_zeroForUnlimited = 0;
68 | tlCamera.Arm;
69 | tlCamera.IssueSoftwareTrigger;
70 |
71 | maxPixelValue = double(2^tlCamera.BitDepth - 1);
72 |
73 | numberOfFramesToAcquire = 10;
74 | frameCount = 0;
75 | while frameCount < numberOfFramesToAcquire
76 | % Check if image buffer has been filled
77 | if (tlCamera.NumberOfQueuedFrames > 0)
78 |
79 | % If data processing in Matlab falls behind camera image
80 | % acquisition, the FIFO image frame buffer could be filled up,
81 | % which would result in missed frames.
82 | if (tlCamera.NumberOfQueuedFrames > 1)
83 | disp(['Data processing falling behind acquisition. ' num2str(tlCamera.NumberOfQueuedFrames) ' remains']);
84 | end
85 |
86 | % Get the pending image frame.
87 | imageFrame = tlCamera.GetPendingFrameOrNull;
88 | if ~isempty(imageFrame)
89 | frameCount = frameCount + 1;
90 | % For color images, the image data is in BGR format.
91 | imageData = imageFrame.ImageData.ImageData_monoOrBGR;
92 |
93 | disp(['Image frame number: ' num2str(imageFrame.FrameNumber)]);
94 |
95 | % TODO: custom image processing code goes here
96 | imageHeight = imageFrame.ImageData.Height_pixels;
97 | imageWidth = imageFrame.ImageData.Width_pixels;
98 | if (isColorCamera)
99 | % Allocate memory for demosaicking output.
100 | demosaickedImageData = NET.createArray('System.UInt16',imageHeight * imageWidth * 3);
101 | colorFormat = Thorlabs.TSI.ColorInterfaces.ColorFormat.BGRPixel;
102 | % Demosaic the Bayer patterned image from the camera.
103 | demosaicker.Demosaic(imageWidth, imageHeight, int32(0), int32(0), colorFilterArrayPhase,...
104 | colorFormat, Thorlabs.TSI.ColorInterfaces.ColorSensorType.Bayer,...
105 | bitDepth, imageData, demosaickedImageData);
106 |
107 | % Allocate memory for color processed image.
108 | processedImageData = NET.createArray('System.UInt16',imageHeight * imageWidth * 3);
109 |
110 | % Use the color processor to perform color transform.
111 | standardRGBColorProcessor.Transform48To48(demosaickedImageData, colorFormat,...
112 | uint16(0), uint16(maxPixelValue), uint16(0), uint16(maxPixelValue),...
113 | uint16(0), uint16(maxPixelValue), int32(0), int32(0), int32(0), processedImageData, colorFormat);
114 |
115 | % Display the color image
116 | imageColor = reshape(uint16(processedImageData), [3, imageWidth, imageHeight]);
117 | imageColor = double(permute(imageColor,[3 2 1]));
118 | imageColor = flip(imageColor,3); % Change from BGR to RGB
119 | figure(1),image(imageColor/maxPixelValue), colorbar
120 | else
121 | imageData2D = reshape(uint16(imageData), [imageWidth, imageHeight]);
122 | figure(1),imagesc(imageData2D'), colormap(gray), colorbar
123 | end
124 | end
125 |
126 | % Release the image frame
127 | delete(imageFrame);
128 | end
129 | drawnow;
130 | end
131 |
132 | % Stop continuous image acquisition
133 | disp('Stopping continuous image acquisition.');
134 | tlCamera.Disarm;
135 |
136 | % Release the TLCamera
137 | disp('Releasing the camera');
138 | tlCamera.Dispose;
139 | delete(tlCamera);
140 |
141 | if (isColorCamera)
142 | standardRGBColorProcessor.Dispose;
143 | delete(standardRGBColorProcessor);
144 | colorProcessorSDK.Dispose;
145 | delete(colorProcessorSDK);
146 | end
147 | end
148 |
149 | % Release the serial numbers
150 | delete(serialNumbers);
151 |
152 | % Release the TLCameraSDK.
153 | tlCameraSDK.Dispose;
154 | delete(tlCameraSDK);
155 |
--------------------------------------------------------------------------------
/MATLAB/Compact_Scientific_Cameras/HardwareTrigger.m:
--------------------------------------------------------------------------------
1 | % Simple Matlab sample for using TSICamera DotNET interface with hardware
2 | % trigger
3 |
4 | clear
5 | close all
6 |
7 | % Load TLCamera DotNet assembly. The assembly .dll is assumed to be in the
8 | % same folder as the scripts.
9 | NET.addAssembly([pwd, '\Thorlabs.TSI.TLCamera.dll']);
10 | disp('Dot NET assembly loaded.');
11 |
12 | tlCameraSDK = Thorlabs.TSI.TLCamera.TLCameraSDK.OpenTLCameraSDK;
13 |
14 | % Get serial numbers of connected TLCameras.
15 | serialNumbers = tlCameraSDK.DiscoverAvailableCameras;
16 | disp([num2str(serialNumbers.Count), ' camera was discovered.']);
17 |
18 | if (serialNumbers.Count > 0)
19 | % Open the first camera using the serial number.
20 | disp('Opening the first camera')
21 | tlCamera = tlCameraSDK.OpenCamera(serialNumbers.Item(0), false);
22 |
23 | % Check if the camera is Color.
24 | isColorCamera = tlCamera.CameraSensorType == Thorlabs.TSI.TLCameraInterfaces.CameraSensorType.Bayer;
25 | if (isColorCamera)
26 | % Load color processing .NET assemblies
27 | NET.addAssembly([pwd, '\Thorlabs.TSI.Demosaicker.dll']);
28 | NET.addAssembly([pwd, '\Thorlabs.TSI.ColorProcessor.dll']);
29 |
30 | % Initialize the demosaicker
31 | demosaicker = Thorlabs.TSI.Demosaicker.Demosaicker;
32 | % Create color processor SDK.
33 | colorProcessorSDK = Thorlabs.TSI.ColorProcessor.ColorProcessorSDK;
34 |
35 | % Query the default white balance matrix from camera. Alternatively
36 | % can also use user defined white balance matrix.
37 | defaultWhiteBalanceMatrix = tlCamera.GetDefaultWhiteBalanceMatrix;
38 |
39 | % Query other relevant camera information
40 | cameraColorCorrectionMatrix = tlCamera.GetCameraColorCorrectionMatrix;
41 | bitDepth = int32(tlCamera.BitDepth);
42 | colorFilterArrayPhase = tlCamera.ColorFilterArrayPhase;
43 |
44 | % Create standard RGB color processing pipeline.
45 | standardRGBColorProcessor = colorProcessorSDK.CreateStandardRGBColorProcessor(defaultWhiteBalanceMatrix,...
46 | cameraColorCorrectionMatrix, bitDepth);
47 | end
48 |
49 | % Set exposure time and gain of the camera.
50 | tlCamera.ExposureTime_us = 200000;
51 |
52 | % Check if the camera supports setting "Gain"
53 | gainRange = tlCamera.GainRange;
54 | if (gainRange.Maximum > 0)
55 | tlCamera.Gain = 0;
56 | end
57 |
58 | % Set the FIFO frame buffer size. Default size is 1.
59 | tlCamera.MaximumNumberOfFramesToQueue = 5;
60 |
61 | figure(1)
62 |
63 | % Start hardware triggered image acquisition
64 | disp('Starting hardware triggered image acquisition.');
65 |
66 | % Set the number of frames per hardware trigger and start trigger
67 | % acquisition
68 | tlCamera.OperationMode = Thorlabs.TSI.TLCameraInterfaces.OperationMode.HardwareTriggered;
69 | tlCamera.FramesPerTrigger_zeroForUnlimited = 1;
70 | tlCamera.Arm;
71 |
72 | maxPixelValue = double(2^tlCamera.BitDepth - 1);
73 |
74 | numberOfFramesToAcquire = 10;
75 | frameCount = 0;
76 | while frameCount < numberOfFramesToAcquire
77 | % Wait for external trigger.
78 |
79 | % Check if image buffer has been filled
80 | if (tlCamera.NumberOfQueuedFrames > 0)
81 |
82 |
83 | % If data processing in Matlab falls behind camera image
84 | % acquisition, the FIFO image frame buffer could be filled up,
85 | % which would result in missed frames.
86 | if (tlCamera.NumberOfQueuedFrames > 1)
87 | disp(['Data processing falling behind acquisition. ' num2str(tlCamera.NumberOfQueuedFrames) ' remains']);
88 | end
89 |
90 | % Get the pending image frame.
91 | imageFrame = tlCamera.GetPendingFrameOrNull;
92 | if ~isempty(imageFrame)
93 | frameCount = frameCount + 1;
94 | % For color images, the image data is in BGR format.
95 | imageData = imageFrame.ImageData.ImageData_monoOrBGR;
96 |
97 | disp(['Image frame number: ' num2str(imageFrame.FrameNumber)]);
98 |
99 | % TODO: custom image processing code goes here
100 | imageHeight = imageFrame.ImageData.Height_pixels;
101 | imageWidth = imageFrame.ImageData.Width_pixels;
102 | if (isColorCamera)
103 | % Allocate memory for demosaicking output.
104 | demosaickedImageData = NET.createArray('System.UInt16',imageHeight * imageWidth * 3);
105 | colorFormat = Thorlabs.TSI.ColorInterfaces.ColorFormat.BGRPixel;
106 | % Demosaic the Bayer patterned image from the camera.
107 | demosaicker.Demosaic(imageWidth, imageHeight, int32(0), int32(0), colorFilterArrayPhase,...
108 | colorFormat, Thorlabs.TSI.ColorInterfaces.ColorSensorType.Bayer,...
109 | bitDepth, imageData, demosaickedImageData);
110 |
111 | % Allocate memory for color processed image.
112 | processedImageData = NET.createArray('System.UInt16',imageHeight * imageWidth * 3);
113 |
114 | % Use the color processor to perform color transform.
115 | standardRGBColorProcessor.Transform48To48(demosaickedImageData, colorFormat,...
116 | uint16(0), uint16(maxPixelValue), uint16(0), uint16(maxPixelValue),...
117 | uint16(0), uint16(maxPixelValue), int32(0), int32(0), int32(0), processedImageData, colorFormat);
118 |
119 | % Display the color image
120 | imageColor = reshape(uint16(processedImageData), [3, imageWidth, imageHeight]);
121 | imageColor = double(permute(imageColor,[3 2 1]));
122 | imageColor = flip(imageColor,3); % Change from BGR to RGB
123 | figure(1),image(imageColor/maxPixelValue), colorbar
124 | else
125 | imageData2D = reshape(uint16(imageData), [imageWidth, imageHeight]);
126 | figure(1),imagesc(imageData2D'), colormap(gray), colorbar
127 | end
128 | end
129 |
130 | % Release the image frame
131 | delete(imageFrame);
132 | end
133 | drawnow;
134 | end
135 |
136 | % Stop hardware triggered image acquisition
137 | disp('Stopping hardware triggered image acquisition.');
138 | tlCamera.Disarm;
139 |
140 | % Release the camera
141 | disp('Releasing the camera');
142 | tlCamera.Dispose;
143 | delete(tlCamera);
144 |
145 | if (isColorCamera)
146 | standardRGBColorProcessor.Dispose;
147 | delete(standardRGBColorProcessor);
148 | colorProcessorSDK.Dispose;
149 | delete(colorProcessorSDK);
150 | end
151 | end
152 |
153 | % Release the serial numbers
154 | delete(serialNumbers);
155 |
156 | % Release the TLCameraSDK.
157 | tlCameraSDK.Dispose;
158 | delete(tlCameraSDK);
159 |
--------------------------------------------------------------------------------
/MATLAB/Compact_Scientific_Cameras/PolarizationProcessing.m:
--------------------------------------------------------------------------------
1 | % Matlab sample for using TSICamera and polarization processing DotNET
2 | % interface with polarization camera.
3 |
4 | clear
5 | close all
6 |
7 | % Load TLCamera DotNet assembly. The assembly .dll is assumed to be in the
8 | % same folder as the scripts.
9 | NET.addAssembly([pwd, '\Thorlabs.TSI.TLCamera.dll']);
10 | disp('Dot NET assembly loaded.');
11 |
12 | tlCameraSDK = Thorlabs.TSI.TLCamera.TLCameraSDK.OpenTLCameraSDK;
13 |
14 | % Get serial numbers of connected TLCameras.
15 | serialNumbers = tlCameraSDK.DiscoverAvailableCameras;
16 | disp([num2str(serialNumbers.Count), ' camera was discovered.']);
17 |
18 | if (serialNumbers.Count > 0)
19 | % Open the first TLCamera using the serial number.
20 | disp('Opening the first camera')
21 | tlCamera = tlCameraSDK.OpenCamera(serialNumbers.Item(0), false);
22 |
23 | % Check if the camera is Polarization camera.
24 | cameraSensorType = tlCamera.CameraSensorType;
25 | isPolarizationCamera = cameraSensorType == Thorlabs.TSI.TLCameraInterfaces.CameraSensorType.MonochromePolarized;
26 | if (isPolarizationCamera)
27 | % Load polarization processing .NET assemblies
28 | NET.addAssembly([pwd, '\Thorlabs.TSI.PolarizationProcessor.dll']);
29 |
30 | % Create polarization processor SDK.
31 | polarizationProcessorSDK = Thorlabs.TSI.PolarizationProcessor.PolarizationProcessorSDK;
32 |
33 | % Create polarization processor
34 | polarizationProcessor = polarizationProcessorSDK.CreatePolarizationProcessor;
35 |
36 | % Query the polar phase of the camera.
37 | polarPhase = tlCamera.PolarPhase;
38 | end
39 |
40 | % Set exposure time and gain of the camera.
41 | tlCamera.ExposureTime_us = 20000;
42 |
43 | figure(1)
44 |
45 | % Check if the camera supports setting "Gain"
46 | gainRange = tlCamera.GainRange;
47 | if (gainRange.Maximum > 0)
48 | tlCamera.Gain = 0;
49 | end
50 |
51 | % Set the FIFO frame buffer size. Default size is 1.
52 | tlCamera.MaximumNumberOfFramesToQueue = 5;
53 |
54 | % Start continuous image acquisition
55 | disp('Starting continuous image acquisition.');
56 | tlCamera.OperationMode = Thorlabs.TSI.TLCameraInterfaces.OperationMode.SoftwareTriggered;
57 | tlCamera.FramesPerTrigger_zeroForUnlimited = 0;
58 | tlCamera.Arm;
59 | tlCamera.IssueSoftwareTrigger;
60 |
61 | maxPixelValue = double(2^tlCamera.BitDepth - 1);
62 |
63 | numberOfFramesToAcquire = 10;
64 | frameCount = 0;
65 | while frameCount < numberOfFramesToAcquire
66 | % Check if image buffer has been filled
67 | if (tlCamera.NumberOfQueuedFrames > 0)
68 |
69 | % If data processing in Matlab falls behind camera image
70 | % acquisition, the FIFO image frame buffer could be filled up,
71 | % which would result in missed frames.
72 | if (tlCamera.NumberOfQueuedFrames > 1)
73 | disp(['Data processing falling behind acquisition. ' num2str(tlCamera.NumberOfQueuedFrames) ' remains']);
74 | end
75 |
76 | % Get the pending image frame.
77 | imageFrame = tlCamera.GetPendingFrameOrNull;
78 | if ~isempty(imageFrame)
79 | frameCount = frameCount + 1;
80 | % For color images, the image data is in BGR format.
81 | imageData = imageFrame.ImageData.ImageData_monoOrBGR;
82 |
83 | disp(['Image frame number: ' num2str(imageFrame.FrameNumber)]);
84 |
85 | % TODO: custom image processing code goes here
86 | imageHeight = imageFrame.ImageData.Height_pixels;
87 | imageWidth = imageFrame.ImageData.Width_pixels;
88 | bitDepth = imageFrame.ImageData.BitDepth;
89 | maxOutput = uint16(2^bitDepth - 1);
90 | if (isPolarizationCamera)
91 | % Allocate memory for processed Azimuth image output.
92 | outputoAzimuthData = NET.createArray('System.UInt16',imageHeight * imageWidth);
93 | % Calculate the Azimuth image.
94 | polarizationProcessor.TransformToAzimuth(polarPhase, imageData, int32(0), int32(0), imageWidth, imageHeight, ...
95 | bitDepth, maxOutput, outputoAzimuthData);
96 |
97 | % Convert the angle data to degrees (-90 to 90 degrees)
98 | imageAngleData = double(outputoAzimuthData) / double(maxOutput) * 180 - 90;
99 | % Display the Azimuth image
100 | imageAngle2D = reshape(imageAngleData, [imageWidth, imageHeight]);
101 | figure(1)
102 | set(gcf, 'Position', [100 300 550 400]);
103 | imagesc(imageAngle2D'), colormap(jet), colorbar, axis equal
104 | title('Azimuth image (-90 degrees to 90 degrees)')
105 |
106 | % Allocate memory for processed Degree of Linear Polarization (DoLP) image output.
107 | outputoDoLPData = NET.createArray('System.UInt16',imageHeight * imageWidth);
108 | % Calculate the Degree of Linear Polarization (DoLP) image.
109 | polarizationProcessor.TransformToDoLP(polarPhase, imageData, int32(0), int32(0), imageWidth, imageHeight, ...
110 | bitDepth, maxOutput, outputoDoLPData);
111 |
112 | % Convert the DoLP data to percent (0 to 100)
113 | imageDoLPData = double(outputoDoLPData) / double(maxOutput) * 100;
114 | % Display the DoLP image
115 | imageDoLP2D = reshape(imageDoLPData, [imageWidth, imageHeight]);
116 | figure(2)
117 | set(gcf, 'Position', [700 300 550 400]);
118 | imagesc(imageDoLP2D'), colormap(jet), colorbar, axis equal
119 | title('Degree of Linear Polarization image (0 to 100 percent)')
120 |
121 | % Allocate memory for processed Intensity image output.
122 | outputIntensityData = NET.createArray('System.UInt16',imageHeight * imageWidth);
123 | % Calculate the Intensity image.
124 | polarizationProcessor.TransformToIntensity(polarPhase, imageData, int32(0), int32(0), imageWidth, imageHeight, ...
125 | bitDepth, maxOutput, outputIntensityData);
126 |
127 | % Display the Intensity image
128 | imageIntensity2D = reshape(uint16(outputIntensityData), [imageWidth, imageHeight]);
129 | figure(3)
130 | set(gcf, 'Position', [1300 300 550 400]);
131 | imagesc(imageIntensity2D'), colormap(hot), colorbar, axis equal
132 | title('Intensity image')
133 |
134 | else
135 | imageData2D = reshape(uint16(imageData), [imageWidth, imageHeight]);
136 | figure(1),imagesc(imageData2D'), colormap(gray), colorbar
137 | end
138 | end
139 |
140 | % Release the image frame
141 | delete(imageFrame);
142 | end
143 | drawnow;
144 | end
145 |
146 | % Stop continuous image acquisition
147 | disp('Stopping continuous image acquisition.');
148 | tlCamera.Disarm;
149 |
150 | % Release the TLCamera
151 | disp('Releasing the camera');
152 | tlCamera.Dispose;
153 | delete(tlCamera);
154 |
155 | if (isPolarizationCamera)
156 | polarizationProcessor.Dispose;
157 | delete(polarizationProcessor);
158 | polarizationProcessorSDK.Dispose;
159 | delete(polarizationProcessorSDK);
160 | end
161 | end
162 |
163 | % Release the serial numbers
164 | delete(serialNumbers);
165 |
166 | % Release the TLCameraSDK.
167 | tlCameraSDK.Dispose;
168 | delete(tlCameraSDK);
169 |
--------------------------------------------------------------------------------
/MATLAB/Compact_Scientific_Cameras/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## Using the Examples
2 | 1. If you have not done so already unzip the following folder to an accesible location on your drive. This contains the Camera SDK.
3 |
4 | * 32-Bit - C:\Program Files (x86)\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
5 | * 64-Bit - C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
6 |
7 | This example will use the dll's here: \Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\
8 |
9 | 2. Copy the dll's to the location of the matlab example you wish to run. The examples in this folder use the current working directory as the location from which to load the dll's. If you need to use a different directory, change the lines of the program that add the .NET assemblies:
10 |
11 | ```
12 | NET.addAssembly([PATH_TO_DLLs, NAME_OF_DLL_TO_LOAD]);
13 | ```
14 |
15 | ## Included Examples
16 |
17 | ### Color Processing:
18 | This example demonstrates how to retreive the raw data from the camera and convert it to an RGB image.
19 |
20 | ### Hardware Triggering:
21 | This example demonstrates how to set up a camera for hardware triggering.
22 |
23 | ### Polarization Processing:
24 | This example demonstrates how to retreive the raw data from a polarization camera like the CS505MUP1 and convert it to one of the polarization image types.
25 |
26 | ### Software Trigger:
27 | This example demonstrates how to set up a camera for software triggering.
28 |
29 | ### Thorlabs Camera GUI:
30 | This example uses the MATLAB App Designer to create a simple GUI to control the camera. This implements features like device enumeration, color processing, hardware triggering, etc..
--------------------------------------------------------------------------------
/MATLAB/Compact_Scientific_Cameras/SoftwareTrigger.m:
--------------------------------------------------------------------------------
1 | % Simple Matlab sample for using TSICamera DotNET interface with software
2 | % trigger
3 |
4 | clear
5 | close all
6 |
7 | % Load TLCamera DotNet assembly. The assembly .dll is assumed to be in the
8 | % same folder as the scripts.
9 | NET.addAssembly([pwd, '\Thorlabs.TSI.TLCamera.dll']);
10 | disp('Dot NET assembly loaded.');
11 |
12 | tlCameraSDK = Thorlabs.TSI.TLCamera.TLCameraSDK.OpenTLCameraSDK;
13 |
14 | % Get serial numbers of connected TLCamera.
15 | serialNumbers = tlCameraSDK.DiscoverAvailableCameras;
16 | disp([num2str(serialNumbers.Count), ' camera was discovered.']);
17 |
18 | if (serialNumbers.Count > 0)
19 | % Open the first camera using the serial number.
20 | disp('Opening the first camera')
21 | tlCamera = tlCameraSDK.OpenCamera(serialNumbers.Item(0), false);
22 | % Check if the camera is Color.
23 | isColorCamera = tlCamera.CameraSensorType == Thorlabs.TSI.TLCameraInterfaces.CameraSensorType.Bayer;
24 | if (isColorCamera)
25 | % Load color processing .NET assemblies
26 | NET.addAssembly([pwd, '\Thorlabs.TSI.Demosaicker.dll']);
27 | NET.addAssembly([pwd, '\Thorlabs.TSI.ColorProcessor.dll']);
28 |
29 | % Initialize the demosaicker
30 | demosaicker = Thorlabs.TSI.Demosaicker.Demosaicker;
31 | % Create color processor SDK.
32 | colorProcessorSDK = Thorlabs.TSI.ColorProcessor.ColorProcessorSDK;
33 |
34 | % Query the default white balance matrix from camera. Alternatively
35 | % can also use user defined white balance matrix.
36 | defaultWhiteBalanceMatrix = tlCamera.GetDefaultWhiteBalanceMatrix;
37 |
38 | % Query other relevant camera information
39 | cameraColorCorrectionMatrix = tlCamera.GetCameraColorCorrectionMatrix;
40 | bitDepth = int32(tlCamera.BitDepth);
41 | colorFilterArrayPhase = tlCamera.ColorFilterArrayPhase;
42 |
43 | % Create standard RGB color processing pipeline.
44 | standardRGBColorProcessor = colorProcessorSDK.CreateStandardRGBColorProcessor(defaultWhiteBalanceMatrix,...
45 | cameraColorCorrectionMatrix, bitDepth);
46 | end
47 |
48 | % Set exposure time and gain of the camera.
49 | tlCamera.ExposureTime_us = 200000;
50 |
51 | % Check if the camera supports setting "Gain"
52 | gainRange = tlCamera.GainRange;
53 | if (gainRange.Maximum > 0)
54 | tlCamera.Gain = 0;
55 | end
56 |
57 | % Set the FIFO frame buffer size. Default size is 1.
58 | tlCamera.MaximumNumberOfFramesToQueue = 5;
59 |
60 | figure(1)
61 |
62 | % Start software triggered image acquisition
63 | disp('Starting software triggered image acquisition.');
64 |
65 | % Set the number of frames per software trigger and start trigger
66 | % acquisition
67 | tlCamera.OperationMode = Thorlabs.TSI.TLCameraInterfaces.OperationMode.SoftwareTriggered;
68 | tlCamera.FramesPerTrigger_zeroForUnlimited = 1;
69 | tlCamera.Arm;
70 |
71 | maxPixelValue = double(2^tlCamera.BitDepth - 1);
72 |
73 | numberOfFramesToAcquire = 10;
74 | for iloop = 1:numberOfFramesToAcquire
75 | % Each call to Start sends a software trigger.
76 | tlCamera.IssueSoftwareTrigger;
77 |
78 | % Wait for image buffer to be filled to prevent sending too many
79 | % software triggers.
80 | while (tlCamera.NumberOfQueuedFrames == 0)
81 | pause(0.01);
82 | end
83 |
84 | % If data processing in Matlab falls behind camera image
85 | % acquisition, the FIFO image frame buffer could be filled up,
86 | % which would result in missed frames.
87 | if (tlCamera.NumberOfQueuedFrames > 1)
88 | disp(['Data processing falling behind acquisition. ' num2str(tlCamera.NumberOfQueuedFrames) ' remains']);
89 | end
90 |
91 | % Get the pending image frame.
92 | imageFrame = tlCamera.GetPendingFrameOrNull;
93 | if ~isempty(imageFrame)
94 | % For color images, the image data is in BGR format.
95 | imageData = imageFrame.ImageData.ImageData_monoOrBGR;
96 |
97 | disp(['Image frame number: ' num2str(imageFrame.FrameNumber)]);
98 |
99 | % TODO: custom image processing code goes here
100 | imageHeight = imageFrame.ImageData.Height_pixels;
101 | imageWidth = imageFrame.ImageData.Width_pixels;
102 | if (isColorCamera)
103 | % Allocate memory for demosaicking output.
104 | demosaickedImageData = NET.createArray('System.UInt16',imageHeight * imageWidth * 3);
105 | colorFormat = Thorlabs.TSI.ColorInterfaces.ColorFormat.BGRPixel;
106 | % Demosaic the Bayer patterned image from the camera.
107 | demosaicker.Demosaic(imageWidth, imageHeight, int32(0), int32(0), colorFilterArrayPhase,...
108 | colorFormat, Thorlabs.TSI.ColorInterfaces.ColorSensorType.Bayer,...
109 | bitDepth, imageData, demosaickedImageData);
110 |
111 | % Allocate memory for color processed image.
112 | processedImageData = NET.createArray('System.UInt16',imageHeight * imageWidth * 3);
113 |
114 | % Use the color processor to perform color transform.
115 | standardRGBColorProcessor.Transform48To48(demosaickedImageData, colorFormat,...
116 | uint16(0), uint16(maxPixelValue), uint16(0), uint16(maxPixelValue),...
117 | uint16(0), uint16(maxPixelValue), int32(0), int32(0), int32(0), processedImageData, colorFormat);
118 |
119 | % Display the color image
120 | imageColor = reshape(uint16(processedImageData), [3, imageWidth, imageHeight]);
121 | imageColor = double(permute(imageColor,[3 2 1]));
122 | imageColor = flip(imageColor,3); % Change from BGR to RGB
123 | figure(1),image(imageColor/maxPixelValue), colorbar
124 | else
125 | imageData2D = reshape(uint16(imageData), [imageWidth, imageHeight]);
126 | figure(1),imagesc(imageData2D'), colormap(gray), colorbar
127 | end
128 | end
129 |
130 | % Release the image frame
131 | delete(imageFrame);
132 | drawnow;
133 | end
134 |
135 | % Stop software triggered image acquisition
136 | disp('Stopping software triggered image acquisition.');
137 | tlCamera.Disarm;
138 |
139 | % Release the camera
140 | disp('Releasing the camera');
141 | tlCamera.Dispose;
142 | delete(tlCamera);
143 |
144 | if (isColorCamera)
145 | standardRGBColorProcessor.Dispose;
146 | delete(standardRGBColorProcessor);
147 | colorProcessorSDK.Dispose;
148 | delete(colorProcessorSDK);
149 | end
150 | end
151 |
152 | % Release the serial numbers
153 | delete(serialNumbers);
154 |
155 | % Release the TLCameraSDK.
156 | tlCameraSDK.Dispose;
157 | delete(tlCameraSDK);
158 |
--------------------------------------------------------------------------------
/MATLAB/Compact_Scientific_Cameras/ThorlabsCameraGUI.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Thorlabs/Camera_Examples/a867a1b4843eb1f5b16074b52c97e644972369a2/MATLAB/Compact_Scientific_Cameras/ThorlabsCameraGUI.fig
--------------------------------------------------------------------------------
/Python/Obsoleted/CCD Camera PythonNET/README.md:
--------------------------------------------------------------------------------
1 | ## Included Examples
2 |
3 | ### PythonNET Software Trigger and Acquire:
4 | This examples initializes the first detected camera and sets up for software triggering. A loop is started that waits the image to be received. This example should only be used if you have an obsolete CCD camera. For all other Thorlabs cameras (Zelux, Kiralux, Quantalux), the python SDK in the ThorCam installation can be used.
5 |
6 |
7 | ## Build Instructions
8 | NOTE: This uses the pythonNET and numpy packages and requires that these be installed. The file tl_dotnet_wrapper.py is a wrapper for the .NET dll's located in the ThorCam install. This was last tested with PythonNET version 3.0.1 and Python version 3.10.4
9 |
10 | 0. If you have not done so already unzip the following folder to an accesible location on your drive. This contains the Camera SDK.
11 |
12 | * 32-Bit - C:\Program Files (x86)\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
13 | * 64-Bit - C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
14 | This example will use the dll's here: \Scientific Camera Interfaces\SDK\Native Toolkit\dlls
15 |
16 | 1. Copy the dll's from \Scientific Camera Interfaces\SDK\DotNet Toolkit\dlls\Managed_64_lib folder into the location where the wrapper and example are located.
17 | 2. Open the folder containing the files in your preferred IDE. PyCharm and Visual Studio Code have been verified.
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Python/Obsoleted/CCD Camera PythonNET/pythonnet_example.py:
--------------------------------------------------------------------------------
1 | import os
2 | import numpy as np
3 | from tl_dotnet_wrapper import TL_SDK, TL_Camera
4 | # simple example to open camera, set some parameters, wait for an image, and close the camera.
5 |
6 | sdk = TL_SDK()
7 | cameras = sdk.get_camera_list()
8 | first_camera_id = cameras[0]
9 | camera = sdk.open_camera(first_camera_id)
10 | camera.set_exposure_time_us(2000) # 2 second exposure
11 | camera.set_frames_per_trigger_zero_for_unlimited(0) # continuous mode
12 | camera.arm()
13 | camera.issue_software_trigger()
14 | frame = None
15 | while frame is None:
16 | frame = camera.get_pending_frame_or_null()
17 | image_array = camera.frame_to_array(frame) # copies image data from frame into a numpy array
18 | camera.disarm()
19 | camera.close()
20 | sdk.close()
21 |
--------------------------------------------------------------------------------
/Python/Obsoleted/CCD Camera PythonNET/tl_dotnet_wrapper.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import traceback
3 | import ctypes
4 |
5 | import clr
6 | from clr import *
7 | from System import Array, Double, IntPtr, Random, Int64, Convert
8 | from System.Runtime.InteropServices import Marshal
9 |
10 | clr.AddReference('Thorlabs.TSI.TLCamera')
11 | clr.AddReference('Thorlabs.TSI.TLCameraInterfaces')
12 | clr.AddReference('Thorlabs.TSI.ImageData')
13 | clr.AddReference('Thorlabs.TSI.ColorInterfaces')
14 |
15 | import Thorlabs.TSI.ImageData as thorlabs_tsi_imagedata
16 | import Thorlabs.TSI.TLCamera as thorlabs_tsi_tlcamera
17 | import Thorlabs.TSI.TLCameraInterfaces as thorlabs_tsi_tlcamerainterfaces
18 | import Thorlabs.TSI.ColorInterfaces as thorlabs_tsi_colorinterfaces
19 |
20 | TLCameraSDK = thorlabs_tsi_tlcamera.TLCameraSDK
21 | ImageDataUShort1D = thorlabs_tsi_imagedata.ImageDataUShort1D
22 | Taps = thorlabs_tsi_tlcamerainterfaces.Taps
23 | ROIAndBin = thorlabs_tsi_tlcamerainterfaces.ROIAndBin
24 | DataRate = thorlabs_tsi_tlcamerainterfaces.DataRate
25 | CameraConnectEventArgs = thorlabs_tsi_tlcamerainterfaces.CameraConnectEventArgs
26 | CameraDisconnectEventArgs = thorlabs_tsi_tlcamerainterfaces.CameraDisconnectEventArgs
27 | TriggerPolarity = thorlabs_tsi_tlcamerainterfaces.TriggerPolarity
28 | CameraSensorType = thorlabs_tsi_tlcamerainterfaces.CameraSensorType
29 | ColorFilterArrayPhase = thorlabs_tsi_colorinterfaces.ColorFilterArrayPhase
30 |
31 | print("DOTNET WRAPPER successfully imported.")
32 |
33 |
34 | class TL_SDK(object):
35 | """
36 | Python object that holds a DotNet TLCameraSDK and wraps its methods in a more pythonic way
37 | """
38 | # constructor
39 | def __init__(self):
40 | self.connect_delegates = {}
41 | self.disconnect_delegates = {}
42 | self.sdk = None
43 | self.open()
44 |
45 | # assign sdk variable to a new TLCameraSDK
46 | def open(self):
47 | try:
48 | self.connect_delegates = {}
49 | self.disconnect_delegates = {}
50 | self.sdk = TLCameraSDK.OpenTLCameraSDK()
51 | except System.InvalidOperationException as ioe:
52 | raise SDKExceptionError("Error: Unable to open SDK\n" + str(ioe))
53 | except Exception as e:
54 | raise SDKExceptionError("Error: Unable to open SDK\n" + str(e))
55 |
56 | # dispose the TLCameraSDK variable
57 | def close(self):
58 | try:
59 | self.sdk.Dispose()
60 | print("SDK DISPOSED")
61 | except Exception as e:
62 | raise SDKExceptionError("Error: Unable to dispose SDK\n" + str(e))
63 |
64 | def get_number_of_cameras(self):
65 | retval = 0
66 | try:
67 | cams = self.sdk.DiscoverAvailableCameras()
68 | retval = cams.Count
69 | except System.Reflection.TargetInvocationException as tie:
70 | raise SDKExceptionError("Error: could not get number of cameras\n" + str(tie))
71 | except Exception as e:
72 | raise SDKExceptionError("Error: could not get number of cameras\n" + str(e))
73 | return retval
74 |
75 | # returns a tuple of camera serial numbers
76 | def get_camera_list(self):
77 | cams = self.sdk.DiscoverAvailableCameras() # serial numbers
78 | return tuple(cams)
79 |
80 | # return camera name associated with a serial number
81 | def get_camera_name(self, camera_number):
82 | retval = ""
83 | try:
84 | cams = self.sdk.DiscoverAvailableCameras()
85 | if camera_number < cams.Count:
86 | retval = cams[camera_number]
87 | except Exception as e:
88 | raise SDKExceptionError("Error: could not get camera name\n")
89 | return retval
90 |
91 | # if given an int, use camera_id as index into list of available cameras
92 | # otherwise open camera where camera_id is a serial number
93 | # creates a python TL_Camera, which holds a DotNet TLCamera
94 | def open_camera(self, camera_id):
95 | retval = None
96 | if camera_id is None:
97 | raise SDKExceptionError("Could not open camera with Null camera ID")
98 | cam = camera_id
99 |
100 | try:
101 | if type(camera_id) == int:
102 | cams = self.sdk.DiscoverAvailableCameras()
103 | cam = cams[camera_id]
104 | opened_camera = self.sdk.OpenCamera(str(cam), False)
105 | retval = TL_Camera(self, opened_camera)
106 | except System.InvalidOperationException as ioe:
107 | raise SDKExceptionError("Error: could not open camera " + str(camera_id) + "\n" + str(ioe))
108 | except System.ArgumentOutOfRangeException as aoore:
109 | raise SDKExceptionError("Error: could not open camera " + str(camera_id) + "\n" + str(aoore))
110 | except:
111 | raise SDKExceptionError("Error: could not open camera\n")
112 | return retval
113 |
114 | # same as open_camera except that it doesn't create a python object; returns a DotNet TLCamera object
115 | def open_camera_only(self, camera_id):
116 | retval = None
117 | cam = camera_id
118 |
119 | try:
120 | if(type(camera_id) == int):
121 | cams = self.sdk.DiscoverAvailableCameras()
122 | cam = cams[camera_id]
123 | opened_camera = self.sdk.OpenCamera(str(cam), False)
124 | retval = opened_camera
125 | except System.InvalidOperationException as ioe:
126 | raise SDKExceptionError("Error: could not open camera " + str(camera_id) + "\n" + str(ioe))
127 | except System.ArgumentOutOfRangeException as aoore:
128 | raise SDKExceptionError("Error: could not open camera " + str(camera_id) + "\n" + str(aoore))
129 | except Exception as exception:
130 | raise SDKExceptionError("Error: could not open camera; {exception}\n".format(exception=exception))
131 | return retval
132 |
133 | def add_on_camera_connect_delegate(self, callback):
134 | self.sdk.OnCameraConnect += callback
135 |
136 | def remove_camera_connect_delegate(self, callback):
137 | self.sdk.OnCameraConnect -= callback
138 |
139 | def add_on_camera_disconnect_delegate(self, callback):
140 | self.sdk.OnCameraDisconnect += callback
141 |
142 | def remove_camera_disconnect_delegate(self, callback):
143 | self.sdk.OnCameraDisconnect -= callback
144 |
145 |
146 | class TL_Camera(object):
147 |
148 | def __init__(self, sdk, camera):
149 | self.sdk = sdk
150 | self.camera = camera
151 | self.is_open = True
152 | self._is_busy = False
153 |
154 | def __del__(self):
155 | if self.is_open:
156 | self.close()
157 |
158 | @property
159 | def is_busy(self):
160 | return self._is_busy
161 |
162 | @is_busy.setter
163 | def is_busy(self, is_busy):
164 | if type(is_busy) == bool:
165 | self._is_busy = is_busy
166 |
167 | @property
168 | def is_open(self):
169 | return self.__is_open
170 |
171 | @is_open.setter
172 | def is_open(self, is_open):
173 | if type(is_open) == bool:
174 | self.__is_open = is_open
175 |
176 | def close(self):
177 | try:
178 | self.camera.Dispose()
179 | self.is_open = False
180 | except Exception as exception:
181 | raise CameraExceptionError("Error: could not close camera; {exception}\n".format(exception=exception))
182 |
183 | def reopen(self):
184 | try:
185 | id = self.get_serial_number()
186 | sdk = self.sdk
187 | self.close()
188 | self.camera = sdk.open_camera_only(id)
189 | self.is_open = True
190 | return True
191 | except:
192 | self.is_open = False
193 | self.camera = None
194 | return False
195 |
196 | def arm(self):
197 | try:
198 | self.camera.Arm()
199 | except Exception as exception:
200 | raise CameraExceptionError("Error: could not arm camera; {exception}\n".format(exception=exception))
201 |
202 | def disarm(self):
203 | try:
204 | self.camera.Disarm()
205 | except Exception as exception:
206 | raise CameraExceptionError("Error: could not disarm camera; {exception}\n".format(exception=exception))
207 |
208 | def set_frames_per_trigger_zero_for_unlimited(self, num_frames):
209 | try:
210 | self.camera.FramesPerTrigger_zeroForUnlimited = num_frames
211 | except Exception as exception:
212 | raise CameraExceptionError("Error: could not set Frames Per Trigger; {exception}\n".format(
213 | exception=exception))
214 |
215 | def set_maximum_number_of_frames_to_queue(self, num_frames):
216 | try:
217 | self.camera.MaximumNumberOfFramesToQueue = num_frames
218 | except Exception as exception:
219 | raise CameraExceptionError("Error: could not set max number of frames to queue; {exception}\n".format(
220 | exception=exception))
221 |
222 | def issue_software_trigger(self):
223 | try:
224 | self.camera.IssueSoftwareTrigger()
225 | except Exception as exception:
226 | raise CameraExceptionError("Error: IssueSoftwareTrigger failed; {exception}\n".format(exception=exception))
227 |
228 | # get a frame from camera, result will be clr Frame type
229 | def get_pending_frame_or_null(self):
230 | retval = None
231 | try:
232 | # t = time.time()
233 | retval = self.camera.GetPendingFrameOrNull()
234 | # print("time to get pending frame: {time}".format(time=time.time() - t))
235 | except Exception as e:
236 | raise CameraExceptionError("Error: could not get pending frame;{exception}\n".format(exception=e))
237 | return retval
238 |
239 | # call get_pending_frame_or_null but convert frame to an np array
240 | def get_pending_array_or_null(self):
241 | try:
242 | frame = self.get_pending_frame_or_null()
243 | frame = self.frame_to_array(frame)
244 | except Exception as exception:
245 | frame = None
246 | print("Error: could not get pending array; {error}".format(error=exception))
247 | return frame
248 |
249 | # use InteropServices to copy frame image data into an np array
250 | @staticmethod
251 | def frame_to_array(frame) -> np.ndarray:
252 | if frame is None:
253 | raise ValueError("frame_to_array called with no frame")
254 | try:
255 | image = Convert.ChangeType(frame.ImageData, thorlabs_tsi_imagedata.ImageDataUShort1D).ImageData_monoOrBGR
256 |
257 | """
258 | image_handle = GCHandle.Alloc(image, GCHandleType.Pinned)
259 | image_ptr = image_handle.AddrOfPinnedObject().ToInt32()
260 | destination = np.fromstring(ctypes.string_at(image_ptr, len(image)*2), dtype=np.ushort) # 2 is the size of ushort in bytes
261 | destination = destination.reshape(frame.ImageData.Height_pixels, frame.ImageData.Width_pixels)
262 | return destination
263 | """
264 |
265 | ret_array = np.zeros(len(image), dtype=ctypes.c_uint16)
266 | Marshal.Copy(image, 0, IntPtr(ret_array.__array_interface__['data'][0]), len(image)) # .NET method that copies image ( a System.UInt16[] type ) memory to ret_array ( an np array dtype = uint16 ) 'data' memory
267 | ret_array = ret_array.reshape(frame.get_ImageData().get_Height_pixels(), frame.get_ImageData().get_Width_pixels())
268 | return ret_array
269 | except IndexError as ie:
270 | print("frame_to_array: Index out of bounds error")
271 | raise CameraExceptionError("Error: could not convert frame to array - index out of bounds\n" + ie)
272 | except Exception as e:
273 | print("Error converting frame to array")
274 | raise CameraExceptionError("Error: could not convert frame to array:\n" + str(e))
275 | #finally:
276 | # if image_handle.IsAllocated:
277 | # image_handle.Free()
278 |
279 | def set_exposure_time_us(self, time_ms):
280 | try:
281 | self.camera.ExposureTime_us = time_ms
282 | except Exception as exception:
283 | raise CameraExceptionError("Error: could not set exposure time; {exception}\n".format(exception=exception))
284 |
285 | def set_gain(self, gain):
286 | try:
287 | self.camera.Gain = gain
288 | except Exception as exception:
289 | raise CameraExceptionError("Error: could not set gain; {exception}\n".format(exception=exception))
290 |
291 | def set_black_level(self, blacklevel):
292 | try:
293 | self.camera.BlackLevel = blacklevel
294 | except Exception as exception:
295 | raise CameraExceptionError("Error: could not set black level; {exception}\n".format(exception=exception))
296 |
297 | def get_black_level_range(self):
298 | try:
299 | return self.camera.BlackLevelRange.Minimum, self.camera.BlackLevelRange.Maximum
300 | except Exception as exception:
301 | raise CameraExceptionError("Error: could not get black level range; {exception}\n"
302 | .format(exception=exception))
303 |
304 | def get_gain_range(self):
305 | try:
306 | return self.camera.GainRange.Minimum, self.camera.GainRange.Maximum
307 | except Exception as exception:
308 | raise CameraExceptionError("Error: could not get gain range; {exception}\n"
309 | .format(exception=exception))
310 |
311 | def get_highest_supported_tap(self):
312 | if self.get_is_taps_supported(4):
313 | return 4
314 | elif self.get_is_taps_supported(2):
315 | return 2
316 | else:
317 | return 1
318 |
319 | def get_data_rate_list(self):
320 | data_rate_list = []
321 | if self.get_is_data_rate_supported("20MHz"):
322 | data_rate_list.append("20MHz")
323 | if self.get_is_data_rate_supported("40MHz"):
324 | data_rate_list.append("40MHz")
325 | if self.get_is_data_rate_supported("FPS30"):
326 | data_rate_list.append("FPS30")
327 | if self.get_is_data_rate_supported("FPS50"):
328 | data_rate_list.append("FPS50")
329 | return data_rate_list
330 |
331 | def get_sensor_width_pixels(self):
332 | try:
333 | return self.camera.SensorWidth_pixels
334 | except Exception as exception:
335 | raise CameraExceptionError("Error: could not get sensor width; {error}\n".format(error=exception))
336 |
337 | def get_sensor_height_pixels(self):
338 | retval = 0
339 | try:
340 | retval = self.camera.SensorHeight_pixels
341 | except Exception as exception:
342 | raise CameraExceptionError("Error: could not get sensor height; {exception}\n".format(exception=exception))
343 | return retval
344 |
345 | def get_bit_depth(self):
346 | retval = 0
347 | try:
348 | retval = self.camera.BitDepth
349 | except Exception as exception:
350 | raise CameraExceptionError("Error: could not get bit depth; {exception}\n".format(exception=exception))
351 | return retval
352 |
353 | def set_roi_binning(self, x, y, width, height, binX, binY):
354 | new_settings = ROIAndBin()
355 | new_settings.BinX = binX
356 | new_settings.BinY = binY
357 | new_settings.ROIWidth_pixels = width
358 | new_settings.ROIHeight_pixels = height
359 | new_settings.ROIOriginX_pixels = int(x)
360 | new_settings.ROIOriginY_pixels = int(y)
361 | try:
362 | self.camera.ROIAndBin = new_settings
363 | except:
364 | raise CameraExceptionError("Error: could not set ROIAndBin\n")
365 |
366 | def add_on_image_frame_available_callback(self, callback, *args):
367 | try:
368 | if len(args) == 0:
369 | self.camera.OnImageFrameAvailable += callback
370 | else:
371 | self.camera.OnImageFrameAvailable += lambda source, eventargs: callback(source, eventargs, *args) # one could pass any number of arguments to their callback
372 | except:
373 | raise CameraExceptionError("Error: could not set image frame available callback\n")
374 |
375 | def remove_on_image_frame_available_callback(self, callback):
376 | self.camera.OnImageFrameAvailable -= callback # TODO: works with variadic\lambda?
377 |
378 | def get_roi_binning(self):
379 | retval = []
380 | try:
381 | retval = [
382 | self.camera.ROIAndBin.ROIOriginX_pixels,
383 | self.camera.ROIAndBin.ROIOriginY_pixels,
384 | self.camera.ROIAndBin.ROIWidth_pixels,
385 | self.camera.ROIAndBin.ROIHeight_pixels,
386 | self.camera.ROIAndBin.BinX,
387 | self.camera.ROIAndBin.BinY
388 | ]
389 | except Exception as exception:
390 | raise CameraExceptionError("Error: GetRoiBinning failed\n; {exception}".format(exception=exception))
391 | return retval
392 |
393 | def get_name(self):
394 | return self.camera.Name
395 |
396 | def get_model(self) -> str:
397 | return self.camera.Model
398 |
399 | def get_black_level(self):
400 | return self.camera.BlackLevel
401 |
402 | def get_gain(self):
403 | return self.camera.Gain
404 |
405 | def get_taps(self):
406 | try:
407 | if self.camera.Taps == Taps.SingleTap:
408 | return 1
409 | elif self.camera.Taps == Taps.DualTap:
410 | return 2
411 | elif self.camera.Taps == Taps.QuadTap:
412 | return 4
413 | return 0
414 | except BaseException as be:
415 | raise CameraExceptionError("Error: GetTaps failed\n" + str(be))
416 |
417 | def get_is_taps_supported(self, tap):
418 | try:
419 | if tap == 1:
420 | return self.camera.GetIsTapsSupported(Taps.SingleTap)
421 | elif tap == 2:
422 | return self.camera.GetIsTapsSupported(Taps.DualTap)
423 | elif tap == 4:
424 | return self.camera.GetIsTapsSupported(Taps.QuadTap)
425 | except BaseException as be:
426 | raise CameraExceptionError("Error: GetIsTapsSupported failed\n" + str(be))
427 |
428 | def set_taps(self, tap):
429 | try:
430 | if tap == 1:
431 | self.camera.Taps = Taps.SingleTap
432 | elif tap == 2:
433 | self.camera.Taps = Taps.DualTap
434 | elif tap == 4:
435 | self.camera.Taps = Taps.QuadTap
436 | except BaseException as be:
437 | raise CameraExceptionError("Error: SetTaps failed\n" + str(be))
438 |
439 | def get_roi_height_range(self):
440 | try:
441 | return self.camera.ROIHeightRange
442 | except BaseException as be:
443 | raise CameraExceptionError("Error: GetROIHeightRange failed\n" + str(be))
444 |
445 | def get_roi_width_range(self):
446 | try:
447 | return self.camera.ROIWidthRange
448 | except BaseException as be:
449 | raise CameraExceptionError("Error: GetROIWidthRange failed\n" + str(be))
450 |
451 | def set_is_tap_balance_enabled(self, tap_balance_enabled):
452 | try:
453 | self.camera.IsTapBalanceEnabled = tap_balance_enabled
454 | except BaseException as be:
455 | raise CameraExceptionError("Error: SetIsTapBalanceEnabled failed\n" + str(be))
456 |
457 | def get_is_tap_balance_enabled(self):
458 | try:
459 | return self.camera.IsTapBalanceEnabled
460 | except BaseException as be:
461 | raise CameraExceptionError("Error: GetIsTapBalanceEnabled failed\n" + str(be))
462 |
463 | def get_exposure_time_us(self):
464 | try:
465 | return self.camera.ExposureTime_us
466 | except BaseException as be:
467 | raise CameraExceptionError("Error: GetExposureTime failed\n" + str(be))
468 |
469 | def get_serial_number(self):
470 | try:
471 | return self.camera.SerialNumber
472 | except BaseException as be:
473 | raise CameraExceptionError("Error: GetSerialNumber failed\n" + str(be))
474 |
475 | def set_data_rate(self, data_rate):
476 | try:
477 | if data_rate == "20MHz":
478 | self.camera.DataRate = DataRate.ReadoutSpeed20MHz
479 | elif data_rate == "40MHz":
480 | self.camera.DataRate = DataRate.ReadoutSpeed40MHz
481 | elif data_rate == "FPS30":
482 | self.camera.DataRate = DataRate.FPS30
483 | elif data_rate == "FPS50":
484 | self.camera.DataRate = DataRate.FPS50
485 | except BaseException as be:
486 | raise CameraExceptionError("Error: SetDataRate failed\n" + str(be))
487 |
488 | def tap_balance_load_data_from_file(self, file):
489 | try:
490 | self.camera.TapBalanceLoadDataFromFile(file)
491 | except Exception as e:
492 | raise SDKExceptionError("Error: Tap balance data could not be loaded from file\n" + str(e))
493 |
494 | def tap_balance_write_data_to_camera(self):
495 | try:
496 | self.camera.TapBalanceWriteDataToCamera()
497 | except Exception as e:
498 | raise SDKExceptionError("Error: Tap balance data could not be written to camera\n" + str(e))
499 |
500 | def get_is_data_rate_supported(self, data_rate):# div by 0 error?
501 | try:
502 | if data_rate == "20MHz":
503 | return self.camera.GetIsDataRateSupported(DataRate.ReadoutSpeed20MHz)
504 | elif data_rate == "40MHz":
505 | return self.camera.GetIsDataRateSupported(DataRate.ReadoutSpeed40MHz)
506 | elif data_rate == "FPS30":
507 | return self.camera.GetIsDataRateSupported(DataRate.FPS30)
508 | elif data_rate == "FPS50":
509 | return self.camera.GetIsDataRateSupported(DataRate.FPS50)
510 | except ZeroDivisionError as zde:
511 | raise CameraExceptionError("Error: divide by zero\n" + str(zde))
512 |
513 | def set_hot_pixel_correction_threshold(self, threshold):
514 | try:
515 | self.camera.HotPixelCorrectionThreshold = threshold
516 | except Exception as e:
517 | raise CameraExceptionError("Error: could not set hot pixel correction threshold " + str(e))
518 |
519 | def get_hot_pixel_correction_threshold(self):
520 | try:
521 | return self.camera.HotPixelCorrectionThreshold
522 | except Exception as e:
523 | raise CameraExceptionError("Error: could not get hot pixel correction threshold " + str(e))
524 |
525 | def set_is_hot_pixel_correction_enabled(self, is_enabled):
526 | try:
527 | self.camera.IsHotPixelCorrectionEnabled = is_enabled
528 | except Exception as e:
529 | raise CameraExceptionError("Error: could not set IsHotPixelCorrectionEnabled " + str(e))
530 |
531 | def get_is_hot_pixel_correction_enabled(self):
532 | try:
533 | return self.camera.IsHotPixelCorrectionEnabled
534 | except Exception as e:
535 | raise CameraExceptionError("Error: could not get IsHotPixelCorrectionEnabled " + str(e))
536 |
537 | def set_is_cooling_enabled(self, is_enabled):
538 | try:
539 | self.camera.IsCoolingEnabled = is_enabled
540 | except Exception as e:
541 | raise CameraExceptionError("Error: could not set IsCoolingEnabled " + str(e))
542 |
543 | def get_is_cooling_enabled(self):
544 | try:
545 | return self.camera.IsCoolingEnabled
546 | except Exception as e:
547 | raise CameraExceptionError("Error: could not get IsCoolingEnabled " + str(e))
548 |
549 | def set_is_eep_enabled(self, is_enabled):
550 | try:
551 | self.camera.IsEEPEnabled = is_enabled
552 | except Exception as e:
553 | raise CameraExceptionError("Error: could not set IsEEPEnabled " + str(e))
554 |
555 | def get_is_eep_enabled(self):
556 | try:
557 | return self.camera.IsEEPEnabled
558 | except Exception as e:
559 | raise CameraExceptionError("Error: could not get IsEEPEnabled " + str(e))
560 |
561 | def set_is_nir_boost_enabled(self, is_enabled):
562 | try:
563 | self.camera.IsNIRBoostEnabled = is_enabled
564 | except Exception as e:
565 | raise CameraExceptionError("Error: could not set NIRBoostEnabled " + str(e))
566 |
567 | def get_is_nir_boost_enabled(self):
568 | try:
569 | return self.camera.IsNIRBoostEnabled
570 | except Exception as e:
571 | raise CameraExceptionError("Error: could not get NIRBoostEnabled " + str(e))
572 |
573 | def set_operation_mode(self, mode):
574 | try:
575 | self.camera.OperationMode = mode
576 | except Exception as e:
577 | raise CameraExceptionError("Error: could not set operation mode " + str(e))
578 |
579 | def get_operation_mode(self):
580 | try:
581 | return self.camera.OperationMode
582 | except Exception as e:
583 | raise CameraExceptionError("Error: could not get opration mode " + str(e))
584 |
585 | def get_sensor_height_range(self):
586 | try:
587 | return self.camera.SensorHeight_pixels.Minimum, self.camera.SensorHeight_pixels.Maximum
588 | except Exception as e:
589 | raise CameraExceptionError("Error: could not get sensor height")
590 |
591 | def get_sensor_width_range(self):
592 | try:
593 | return self.camera.SensorWidth_pixels.Minimum, self.camera.SensorWidth_pixels.Maximum
594 | except Exception as e:
595 | raise CameraExceptionError("Error: could not get sensor width range")
596 |
597 | def get_sensor_pixel_size_um(self):
598 | try:
599 | return self.camera.SensorPixelSize_um
600 | except Exception as e:
601 | raise CameraExceptionError("Error: could not get sensor pixel size")
602 |
603 | def get_bin_x_range(self):
604 | try:
605 | return self.camera.BinXRange.Minimum, self.camera.BinXRange.Maximum
606 | except Exception as e:
607 | raise CameraExceptionError("Error: could not get bin x range")
608 |
609 | def get_number_of_queued_frames(self):
610 | try:
611 | return self.camera.NumberOfQueuedFrames
612 | except Exception as e:
613 | raise CameraExceptionError("Error: could not get queued frames")
614 |
615 | def get_bin_y_range(self):
616 | try:
617 | return self.camera.BinYRange.Minimum, self.camera.BinYRange.Maximum
618 | except Exception as e:
619 | raise CameraExceptionError("Error: could not get bin y range")
620 |
621 | def set_trigger_polarity(self, polarity):
622 | try:
623 | self.camera.TriggerPolarity = polarity
624 | except Exception as e:
625 | raise CameraExceptionError("Error: could not set trigger polarity")
626 |
627 | def get_trigger_polarity(self):
628 | try:
629 | if self.camera.TriggerPolarity == TriggerPolarity.ActiveHigh:
630 | return 0
631 | elif self.camera.TriggerPolarity == TriggerPolarity.ActiveLow:
632 | return 1
633 | except Exception as e:
634 | raise CameraExceptionError("Error: could not get trigger polarity")
635 |
636 | def tap_balance_config(self, config_select, enable):
637 | self.camera.TapBalanceConfig(config_select, enable)
638 |
639 | def free_all_but_given_number_of_frames(self, number_of_frames_to_leave_in_queue: int):
640 | try:
641 | self.camera.FreeAllButGivenNumberOfFrames(number_of_frames_to_leave_in_queue)
642 | except Exception as exception:
643 | raise CameraExceptionError("Unable to free all but given number of frames; {error}".format(error=exception))
644 |
645 | @property
646 | def is_armed(self):
647 | try:
648 | if self.camera.IsArmed:
649 | return True
650 | else:
651 | return False
652 | except Exception as exception:
653 | raise CameraExceptionError("Unable to free all but given number of frames; {error}".format(error=exception))
654 |
655 | def take_one_image(self):
656 | """
657 | if self.is_armed:
658 | self.disarm()
659 | self.set_frames_per_trigger_zero_for_unlimited(1)
660 | self.set_maximum_number_of_frames_to_queue(10)
661 | self.free_all_but_given_number_of_frames(0)
662 | self.arm()
663 | self.issue_software_trigger()
664 | image = None
665 | while self.get_number_of_queued_frames() <= 0:
666 | pass
667 | image = self.get_pending_array_or_null()
668 | self.disarm()
669 | return image
670 | """
671 |
672 | self.disarm()
673 | self.set_frames_per_trigger_zero_for_unlimited(1)
674 | self.set_maximum_number_of_frames_to_queue(10)
675 | self.arm()
676 | self.issue_software_trigger()
677 | while self.get_number_of_queued_frames() <= 0:
678 | pass
679 | image_array = self.get_pending_array_or_null()
680 | self.disarm()
681 | return image_array
682 |
683 | def get_image_width(self):
684 | try:
685 | roi_and_bin = self.get_roi_binning()
686 | return roi_and_bin[2]
687 | except Exception as e:
688 | raise CameraExceptionError("Error: could not get image width; {error}".format(error=e))
689 |
690 | def get_image_height(self):
691 | try:
692 | roi_and_bin = self.get_roi_binning()
693 | return roi_and_bin[3]
694 | except Exception as e:
695 | raise CameraExceptionError("Error: could not get image height; {error}".format(error=e))
696 |
697 | def get_autoscaled_image(self, image):
698 | try:
699 | image = image.astype(np.float64)
700 | image *= ((2 ** self.get_bit_depth()) - 1) / np.max(image) # auto-scale
701 | return image
702 | except Exception as exception:
703 | raise SDKExceptionError("unable to autoscale image; {error}".format(error=exception))
704 |
705 | def get_camera_sensor_type(self):
706 | try:
707 | if self.camera.CameraSensorType == CameraSensorType.Bayer:
708 | return 'bayer'
709 | elif self.camera.CameraSensorType == CameraSensorType.Monochrome:
710 | return 'monochrome'
711 | elif self.camera.CameraSensorType == CameraSensorType.MonochromePolarized:
712 | return 'monochrome polarized'
713 | else:
714 | return None
715 | except Exception as e:
716 | raise CameraExceptionError("Error: could not get camera sensor type")
717 |
718 | def get_color_filter_array_type(self):
719 | try:
720 | if self.camera.ColorFilterArrayPhase == ColorFilterArrayPhase.BayerRed:
721 | return 'red'
722 | if self.camera.ColorFilterArrayPhase == ColorFilterArrayPhase.BayerBlue:
723 | return 'blue'
724 | if self.camera.ColorFilterArrayPhase == ColorFilterArrayPhase.BayerGreenLeftOfRed:
725 | return 'green left of red'
726 | if self.camera.ColorFilterArrayPhase == ColorFilterArrayPhase.BayerGreenLeftOfBlue:
727 | return 'green left of blue'
728 | else:
729 | return None
730 | except Exception as e:
731 | raise CameraExceptionError("Error: could not get color filter array type")
732 |
733 |
734 | class SDKExceptionError(Exception):
735 | def __init__(self, message):
736 | print(traceback.format_exc())
737 | super(SDKExceptionError, self).__init__(message)
738 |
739 |
740 | class CameraExceptionError(Exception):
741 | def __init__(self, message):
742 | print(traceback.format_exc())
743 | super(CameraExceptionError, self).__init__(message)
744 |
--------------------------------------------------------------------------------
/Python/Obsoleted/DCx Camera PyuEye/DCx_PyuEye.py:
--------------------------------------------------------------------------------
1 | from pyueye import ueye
2 | import numpy as np
3 | import cv2
4 | # simple example to open camera, set some parameters, take live video, and close the camera.
5 |
6 | def main():
7 | # initialize the camera.
8 | hcam = ueye.HIDS(0)
9 | ret = ueye.is_InitCamera(hcam, None)
10 | print(f"initCamera returns {ret}")
11 |
12 | # set the color mode.
13 | ret = ueye.is_SetColorMode(hcam, ueye.IS_CM_BGR8_PACKED)
14 | print(f"SetColorMode IS_CM_BGR8_PACKED returns {ret}")
15 |
16 | # set the region of interest (Camera dependent).
17 | width = 1280
18 | height = 1024
19 | rect_aoi = ueye.IS_RECT()
20 | rect_aoi.s32X = ueye.int(0)
21 | rect_aoi.s32Y = ueye.int(0)
22 | rect_aoi.s32Width = ueye.int(width)
23 | rect_aoi.s32Height = ueye.int(height)
24 | ueye.is_AOI(hcam, ueye.IS_AOI_IMAGE_SET_AOI, rect_aoi, ueye.sizeof(rect_aoi))
25 | print(f"AOI IS_AOI_IMAGE_SET_AOI returns {ret}")
26 |
27 | # allocate memory for live view.
28 | mem_ptr = ueye.c_mem_p()
29 | mem_id = ueye.int()
30 | bitspixel = 24 # for colormode = IS_CM_BGR8_PACKED
31 | ret = ueye.is_AllocImageMem(hcam, width, height, bitspixel,
32 | mem_ptr, mem_id)
33 | print(f"AllocImageMem returns {ret}")
34 |
35 | # set active memory region.
36 | ret = ueye.is_SetImageMem(hcam, mem_ptr, mem_id)
37 | print(f"SetImageMem returns {ret}")
38 |
39 | # continuous capture to memory.
40 | ret = ueye.is_CaptureVideo(hcam, ueye.IS_DONT_WAIT)
41 | print(f"CaptureVideo returns {ret}")
42 |
43 | # get data from camera and display (press the q key to exit out of live capture).
44 | lineinc = width * int((bitspixel + 7) / 8)
45 | while True:
46 | img = ueye.get_data(mem_ptr, width, height, bitspixel, lineinc, copy=True)
47 | img = np.reshape(img, (height, width, 3))
48 | cv2.imshow('uEye Python Example (q to exit)', img)
49 | if cv2.waitKey(1) & 0xFF == ord('q'):
50 | break
51 | cv2.destroyAllWindows()
52 |
53 | # stop capture and close the camera.
54 | ret = ueye.is_StopLiveVideo(hcam, ueye.IS_FORCE_VIDEO_STOP)
55 | print(f"StopLiveVideo returns {ret}")
56 | ret = ueye.is_ExitCamera(hcam)
57 | print(f"ExitCamera returns {ret}")
58 |
59 | if __name__ == '__main__':
60 | main()
61 |
--------------------------------------------------------------------------------
/Python/Obsoleted/DCx Camera PyuEye/README.md:
--------------------------------------------------------------------------------
1 | # Example for Thorlabs DCx cameras using PyuEye.
2 | This example uses the pyuEye library to acquire a live video from a Thorlabs DCx camera.
3 |
4 | ## Library and driver requirements
5 | The PyuEye, numpy and openCV libraries can be installed through pip using the below commands.
6 |
7 | pip install pyueye
8 |
9 | pip install numpy
10 |
11 | pip install opencv
12 |
13 | The camera drivers to use this example can be downloaded from the IDS software suite from the IDS website [here](https://www.ids-imaging.us/downloads.html). To navigate to the download you can search for a UI-3240CP-M-GL model camera.
14 |
15 |
--------------------------------------------------------------------------------
/Python/Obsoleted/ReadMe.md:
--------------------------------------------------------------------------------
1 | ## This folder contains example code written for products that have been obsoleted.
2 |
3 |
4 | Please be aware that any examples for obsolete products are subject to deletion if the supporting libraries are changed or the implementation is no longer supported by the host language. The configurations used to test each example is listed in its description file.
--------------------------------------------------------------------------------
/Python/README.md:
--------------------------------------------------------------------------------
1 | ## Included Examples
2 |
3 | ### Grab Single Frame:
4 | This examples initializes the first detected camera and sets up for software triggering. A single frame is requested and the recieved image is displayed with OpenCV.
5 |
6 | ### Grab Frames Polling Continuous:
7 | This examples initializes the first detected camera and sets up for continuous capture with software triggering and framerate control. The recieved images are displayed with OpenCV
8 |
9 | ## Build Instructions
10 | 1. If you have not done so already unzip the following folder to an accesible location on your drive. This contains the Camera SDK.
11 |
12 | * 32-Bit - C:\Program Files (x86)\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
13 | * 64-Bit - C:\Program Files\Thorlabs\Scientific Imaging\Scientific Camera Support\Scientific Camera Interfaces.zip
14 |
15 | 2. The Python SDK is provided both as an installable package and as source files. To install the Python SDK in your environment, use a package manager such as pip to install from the package file. The zip folder will be found within the location in step 1: \Scientific Camera Interfaces\SDK\Python Toolkit
16 |
17 | Example install command:
18 |
19 | ```
20 | python.exe -m pip install thorlabs_tsi_camera_python_sdk_package.zip
21 | ```
22 |
23 | This will install the thorlabs_tsi_sdk package into your current environment. The examples assume you are using this method.
24 | If you want to use the source files directly, they are included in SDK\Python Camera Toolkit\source.
25 |
26 | 3. To use the examples on a Windows OS, copy the Native DLLs from
27 | * 64-Bit - \Scientific Camera Interfaces\SDK\Native Toolkit\dlls\Native_64_lib
28 | * 32-Bit - \Scientific Camera Interfaces\SDK\Native Toolkit\dlls\Native_32_lib
29 |
30 | To a folder in your script location named __\dlls\64_lib__ for 64-bit machines and __\dlls\32_lib__ for 32-bit. This can be modified in the windows_setup.py script if you wish to change the location.
31 |
32 | 4. Additional examples and a requirements.txt file is provided with ThorCam that lists the libraries needed to run the examples (besides the thorlabs_tsi_sdk package). This is dound in \Scientific Camera Interfaces\SDK\Python Toolkit\examples and can be used with pip to install each dependency at once:
33 |
34 | ```
35 | pip install -r requirements.txt
36 | ```
37 |
--------------------------------------------------------------------------------
/Python/grab_frames_polling_continuous.py:
--------------------------------------------------------------------------------
1 | """
2 | Polling Example
3 |
4 | This example shows how to open a camera, adjust some settings, and poll for images. It also shows how 'with' statements
5 | can be used to automatically clean up camera and SDK resources.
6 |
7 | """
8 |
9 | import numpy as np
10 | import os
11 | import cv2
12 | import time
13 | from thorlabs_tsi_sdk.tl_camera import TLCameraSDK, OPERATION_MODE
14 |
15 | try:
16 | # if on Windows, use the provided setup script to add the DLLs folder to the PATH
17 | from windows_setup import configure_path
18 | configure_path()
19 | except ImportError:
20 | configure_path = None
21 |
22 | with TLCameraSDK() as sdk:
23 | available_cameras = sdk.discover_available_cameras()
24 | if len(available_cameras) < 1:
25 | print("no cameras detected")
26 |
27 | with sdk.open_camera(available_cameras[0]) as camera:
28 | camera.exposure_time_us = 10000 # set exposure to 11 ms
29 | camera.frames_per_trigger_zero_for_unlimited = 0 # start camera in continuous mode
30 | camera.image_poll_timeout_ms = 1000 # 1 second polling timeout
31 | camera.frame_rate_control_value = 10
32 | camera.is_frame_rate_control_enabled = True
33 |
34 | camera.arm(2)
35 | camera.issue_software_trigger()
36 |
37 | try:
38 | while True:
39 | frame = camera.get_pending_frame_or_null()
40 | if frame is not None:
41 | print("frame #{} received!".format(frame.frame_count))
42 | frame.image_buffer
43 | image_buffer_copy = np.copy(frame.image_buffer)
44 | numpy_shaped_image = image_buffer_copy.reshape(camera.image_height_pixels, camera.image_width_pixels)
45 | nd_image_array = np.full((camera.image_height_pixels, camera.image_width_pixels, 3), 0, dtype=np.uint8)
46 | nd_image_array[:,:,0] = numpy_shaped_image
47 | nd_image_array[:,:,1] = numpy_shaped_image
48 | nd_image_array[:,:,2] = numpy_shaped_image
49 |
50 | cv2.imshow("Image From TSI Cam", nd_image_array)
51 | cv2.waitKey(1)
52 |
53 | else:
54 | print("Unable to acquire image, program exiting...")
55 | exit()
56 | except KeyboardInterrupt:
57 | print("loop terminated")
58 |
59 | cv2.destroyAllWindows()
60 | camera.disarm()
61 |
62 | # Because we are using the 'with' statement context-manager, disposal has been taken care of.
63 |
64 | print("program completed")
65 |
--------------------------------------------------------------------------------
/Python/grab_single_frame.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import os
3 | import cv2
4 | from thorlabs_tsi_sdk.tl_camera import TLCameraSDK, OPERATION_MODE
5 |
6 | try:
7 | # if on Windows, use the provided setup script to add the DLLs folder to the PATH
8 | from windows_setup import configure_path
9 | configure_path()
10 | except ImportError:
11 | configure_path = None
12 |
13 | with TLCameraSDK() as sdk:
14 | available_cameras = sdk.discover_available_cameras()
15 | if len(available_cameras) < 1:
16 | print("no cameras detected")
17 |
18 | with sdk.open_camera(available_cameras[0]) as camera:
19 | camera.exposure_time_us = 10000 # set exposure to 11 ms
20 | camera.frames_per_trigger_zero_for_unlimited = 0 # start camera in continuous mode
21 | camera.image_poll_timeout_ms = 1000 # 1 second polling timeout
22 |
23 | camera.arm(2)
24 |
25 | camera.issue_software_trigger()
26 |
27 | frame = camera.get_pending_frame_or_null()
28 | if frame is not None:
29 | print("frame #{} received!".format(frame.frame_count))
30 | frame.image_buffer
31 | image_buffer_copy = np.copy(frame.image_buffer)
32 | numpy_shaped_image = image_buffer_copy.reshape(camera.image_height_pixels, camera.image_width_pixels)
33 | nd_image_array = np.full((camera.image_height_pixels, camera.image_width_pixels, 3), 0, dtype=np.uint8)
34 | nd_image_array[:,:,0] = numpy_shaped_image
35 | nd_image_array[:,:,1] = numpy_shaped_image
36 | nd_image_array[:,:,2] = numpy_shaped_image
37 |
38 | cv2.imshow("Image From TSI Cam", nd_image_array)
39 | else:
40 | print("Unable to acquire image, program exiting...")
41 | exit()
42 |
43 | cv2.waitKey(0)
44 | camera.disarm()
45 |
46 | # Because we are using the 'with' statement context-manager, disposal has been taken care of.
47 |
48 | print("program completed")
49 |
--------------------------------------------------------------------------------
/Python/windows_setup.py:
--------------------------------------------------------------------------------
1 | """
2 | windows_setup.py
3 |
4 | In order for the Thorlabs Python examples to work, they need visibility of the directory containing the Thorlabs TSI
5 | Native DLLs. This setup function changes the PATH environment variable (Just for the current process, not the system
6 | PATH variable) by adding the directory containing the DLLs. This function is written specifically to work for the
7 | Thorlabs Python SDK examples on Windows, but can be adjusted to work with custom programs. Changing the PATH variable
8 | of a running application is just one way of making the DLLs visible to the program. The following methods could
9 | be used instead:
10 |
11 | - Use the os module to adjust the program's current directory to be the directory containing the DLLs.
12 | - Manually copy the DLLs into the working directory of your application.
13 | - Manually add the path to the directory containing the DLLs to the system PATH environment variable.
14 |
15 | """
16 |
17 | import os
18 | import sys
19 |
20 |
21 | def configure_path():
22 | is_64bits = sys.maxsize > 2**32
23 | relative_path_to_dlls = '.' + os.sep + 'dlls' + os.sep
24 |
25 | if is_64bits:
26 | relative_path_to_dlls += '64_lib'
27 | else:
28 | relative_path_to_dlls += '32_lib'
29 |
30 | absolute_path_to_file_directory = os.path.dirname(os.path.abspath(__file__))
31 |
32 | absolute_path_to_dlls = os.path.abspath(absolute_path_to_file_directory + os.sep + relative_path_to_dlls)
33 |
34 | os.environ['PATH'] = absolute_path_to_dlls + os.pathsep + os.environ['PATH']
35 |
36 | try:
37 | # Python 3.8 introduces a new method to specify dll directory
38 | os.add_dll_directory(absolute_path_to_dlls)
39 | except AttributeError:
40 | pass
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Camera_Examples
2 | Software examples for Thorlabs' imaging products (e.g. Scientific Cameras)
3 |
4 | ## Repo Organization
5 | All examples are split up by programming language and product type. Directions on using specific examples are given within the folders.
6 |
7 | ## Requirements
8 |
9 | All examples are built using the libraries provided with ThorCam software package, which can be found [here](https://www.thorlabs.com/software_pages/ViewSoftwarePage.cfm?Code=ThorCam). DLLs are not provided by this repository in order to save space and ensure that the latest or most appropriate versions of the DLLs are used with your application.
10 |
11 | Thorlabs also provides Linux shared libraries on the ThorCam installation page. Examples showing the use of these will be added in the future.
12 |
13 | ### C\# and C++ Soft Requirements
14 |
15 | Guides written for these examples are written with Microsoft's Visual Studio in mind, which can be downloaded [here](https://visualstudio.microsoft.com/).
16 | Other IDEs can be used, but instructions are not provided in this repository.
17 |
--------------------------------------------------------------------------------