pylonsrc: merge Basler Pylon plugin from gst-pylonsrc

Merged from https://github.com/zingmars/gst-pylonsrc

This includes some changes to include running gst-indent, and
modification to allow it to compile with Visual Studio 2012/VC11.
This commit is contained in:
Joshua M. Doe 2020-04-06 14:35:50 -04:00
parent 552fae8538
commit c0f68e83d3
6 changed files with 2951 additions and 0 deletions

View File

@ -100,6 +100,9 @@ macro_log_feature(PHOENIX_FOUND "Active Silicon Phoenix" "Required to build Acti
find_package(Pleora)
macro_log_feature(Pleora_FOUND "Pleora eBUS" "Required to build Pleora eBUS source element" "http://www.pleora.com/" FALSE)
find_package(Pylon)
macro_log_feature(Pylon_FOUND "Basler Pylon" "Required to build Basler Pylon source element" "http://www.basler.com/" FALSE)
find_package(Sapera)
macro_log_feature(SAPERA_FOUND "Teledyne DALSA Sapera" "Required to build Teledyne DALSA Sapera source element" "http://www.teledynedalsa.com/" FALSE)

View File

@ -0,0 +1,32 @@
# - Try to find Pylon SDK
# Once done this will define
#
# PYLON_FOUND - system has Pylon SDK
# PYLON_INCLUDE_DIR - the Pylon SDK include directory
# PYLON_LIBRARIES - the libraries needed to use Pylon SDK
# Copyright (c) 2006, Tim Beaulen <tbscope@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if (NOT PYLON_DIR)
set (PYLON_DIR "C:/Program Files/Basler/pylon 5" CACHE PATH "Directory containing Pylon SDK includes and libraries")
endif ()
find_path (PYLON_INCLUDE_DIR pylonc/PylonC.h
PATHS
"${PYLON_DIR}/Development/include"
DOC "Directory containing KYFGLib.h include file")
# TODO: support multiple SDK versions
find_library (_PylonCLib NAMES PylonC_MD_VC120
PATHS
"${PYLON_DIR}/Development/lib/x64")
set (PYLON_LIBRARIES ${_PylonCLib})
mark_as_advanced (_PylonCLib)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PYLON DEFAULT_MSG PYLON_INCLUDE_DIR PYLON_LIBRARIES)

View File

@ -58,6 +58,10 @@ if (Pleora_FOUND)
add_subdirectory(pleora)
endif (Pleora_FOUND)
if (PYLON_FOUND)
add_subdirectory(pylon)
endif (PYLON_FOUND)
if (SAPERA_FOUND)
add_subdirectory(sapera)
endif (SAPERA_FOUND)

31
sys/pylon/CMakeLists.txt Normal file
View File

@ -0,0 +1,31 @@
set (SOURCES
gstpylonsrc.c
)
set (HEADERS
gstpylonsrc.h)
include_directories (AFTER
${GSTREAMER_INCLUDE_DIR}/..
${PYLON_INCLUDE_DIR}
)
set (libname libgstpylon)
add_library (${libname} MODULE
${SOURCES}
${HEADERS})
target_link_libraries (${libname}
${GLIB2_LIBRARIES}
${GOBJECT_LIBRARIES}
${GSTREAMER_LIBRARY}
${GSTREAMER_BASE_LIBRARY}
${GSTREAMER_VIDEO_LIBRARY}
${PYLON_LIBRARIES}
)
set (pdbfile "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${libname}.pdb")
install (FILES ${pdbfile} DESTINATION lib/gstreamer-1.0 COMPONENT pdb)
install(TARGETS ${libname}
LIBRARY DESTINATION lib/gstreamer-1.0)

2814
sys/pylon/gstpylonsrc.c Normal file

File diff suppressed because it is too large Load Diff

67
sys/pylon/gstpylonsrc.h Normal file
View File

@ -0,0 +1,67 @@
/* GStreamer
* Copyright (C) 2016-2017 Ingmars Melkis <zingmars@playgineering.com>
* Copyright (C) 2018 Ingmars Melkis <contact@zingmars.me>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _GST_PYLONSRC_H_
#define _GST_PYLONSRC_H_
#include <gst/base/gstpushsrc.h>
#include "pylonc/PylonC.h"
G_BEGIN_DECLS
#define GST_TYPE_PYLONSRC (gst_pylonsrc_get_type())
#define GST_PYLONSRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PYLONSRC,GstPylonSrc))
#define GST_PYLONSRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PYLONSRC,GstPylonSrcClass))
#define GST_IS_PYLONSRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PYLONSRC))
#define GST_IS_PYLONSRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PYLONSRC))
typedef struct _GstPylonSrc GstPylonSrc;
typedef struct _GstPylonSrcClass GstPylonSrcClass;
struct _GstPylonSrc
{
GstPushSrc base_pylonsrc;
gint cameraId;
PYLON_DEVICE_HANDLE deviceHandle; // Handle for the camera.
PYLON_STREAMGRABBER_HANDLE streamGrabber; // Handler for camera's streams.
PYLON_WAITOBJECT_HANDLE waitObject; // Handles timing out in the main loop.
int32_t frameSize; // Size of a frame in bytes.
int32_t payloadSize; // Size of a frame in bytes.
guint64 frameNumber; // Fun note: At 120fps it will take around 4 billion years to overflow this variable.
// Plugin parameters
_Bool setFPS, continuousMode, limitBandwidth, demosaicing, centerx, centery, flipx, flipy;
double fps, exposure, gain, blacklevel, gamma, balancered, balanceblue, balancegreen, redhue, redsaturation, yellowhue, yellowsaturation, greenhue, greensaturation, cyanhue, cyansaturation, bluehue, bluesaturation, magentahue, magentasaturation, sharpnessenhancement, noisereduction, autoexposureupperlimit, autoexposurelowerlimit, gainupperlimit, gainlowerlimit, brightnesstarget, transformation00, transformation01, transformation02, transformation10, transformation11, transformation12, transformation20, transformation21, transformation22;
gint height, width, binningh, binningv, maxHeight, maxWidth, maxBandwidth, testImage, offsetx, offsety;
gchar *imageFormat, *sensorMode, *lightsource, *autoexposure, *autowhitebalance, *autogain, *reset, *autoprofile, *transformationselector, *userid;
};
struct _GstPylonSrcClass
{
GstPushSrcClass base_pylonsrc_class;
};
GType gst_pylonsrc_get_type (void);
G_END_DECLS
#endif