diff --git a/cmake/Modules/FindIPP.cmake b/cmake/Modules/FindIPP.cmake new file mode 100644 index 0000000..d007312 --- /dev/null +++ b/cmake/Modules/FindIPP.cmake @@ -0,0 +1,74 @@ +# Find the Intel IPP (Integrated Performance Primitives) +# +# IPP_FOUND - System has IPP +# IPP_INCLUDE_DIRS - IPP include files directories +# IPP_LIBRARIES - The IPP libraries +# +# The environment variable IPPROOT is used to find the installation location. +# If the environment variable is not set we'll look for it in the default installation locations. +# +# Usage: +# +# find_package(IPP) +# if(IPP_FOUND) +# target_link_libraries(TARGET ${IPP_LIBRARIES}) +# endif() + +find_path(IPP_ROOT_DIR + include/ipp.h + PATHS + $ENV{IPPROOT} + /opt/intel/compilers_and_libraries/linux/ipp + /opt/intel/compilers_and_libraries/mac/ipp + "C:/IntelSWTools/compilers_and_libraries/windows/ipp/" + "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/ipp" + $ENV{HOME}/intel/ipp + $ENV{HOME}/miniconda3 + $ENV{USERPROFILE}/miniconda3/Library + "C:/Miniconda37-x64/Library" # Making AppVeyor happy +) + +find_path(IPP_INCLUDE_DIR + ipp.h + PATHS + ${IPP_ROOT_DIR}/include + ) + +if(WIN32) + set(IPP_SEARCH_LIB ippcoremt.lib) + set(IPP_LIBS ippimt.lib ippccmt.lib ippcoremt.lib ippsmt.lib ippdcmt.lib) +elseif(APPLE) + set(IPP_SEARCH_LIB libippcore.a) + set(IPP_LIBS libippi.a libippcc.a libipps.a libippdc.a libippcore.a) +else() # Linux + set(IPP_SEARCH_LIB libippcore.so) + set(IPP_LIBS ippi ippcc ipps ippdc ippcore) +endif() + + +find_path(IPP_LIB_SEARCHPATH + ${IPP_SEARCH_LIB} + PATHS + ${IPP_ROOT_DIR}/lib/intel64 + ${IPP_ROOT_DIR}/lib +) + +foreach(LIB ${IPP_LIBS}) + find_library(${LIB}_PATH ${LIB} PATHS ${IPP_LIB_SEARCHPATH}) + if(${LIB}_PATH) + set(IPP_LIBRARIES ${IPP_LIBRARIES} ${${LIB}_PATH}) + set(IPP_FOUND TRUE) + else() + # message(STATUS "Could not find ${LIB}: disabling IPP") + set(IPP_NOTFOUND TRUE) + endif() +endforeach() + +if(IPP_FOUND AND NOT IPP_NOTFOUND) + set(IPP_INCLUDE_DIRS ${IPP_INCLUDE_DIR}) + include_directories(${IPP_INCLUDE_DIRS}) + message(STATUS "Found IPP libraries in: ${IPP_LIBRARIES}") +else() + message(STATUS "No IPP libraries found.") + set(IPP_FOUND FALSE) +endif() \ No newline at end of file diff --git a/plugins/yolo/darknet b/plugins/yolo/darknet new file mode 160000 index 0000000..c725270 --- /dev/null +++ b/plugins/yolo/darknet @@ -0,0 +1 @@ +Subproject commit c7252703420159a9f3a1ec416b1b4326c4c95402 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt deleted file mode 100755 index 38a2b93..0000000 --- a/python/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(pythonmodules) - -set(CMAKE_CXX_STANDARD 17) - -find_package(Python2 COMPONENTS Development) - -# Include core header directories -file(GLOB LIGHTDB_CORE_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/../core/*/include/") -include_directories(${LIGHTDB_CORE_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${Python2_INCLUDE_DIRS}) - -# Include python header files -file(GLOB LIGHTDB_PYTHON_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/../python/include") -include_directories(${LIGHTDB_PYTHON_INCLUDE_DIRS}) - -file(GLOB LIGHTDB_PYTHON_SOURCE_DIRS "*/src") -foreach(subdir ${LIGHTDB_PYTHON_SOURCE_DIRS}) - add_subdirectory(${subdir}/..) -endforeach() - -# Gather the core source files -file(GLOB_RECURSE LIGHTDB_PYTHON_SOURCES "*.cc") -set(LIGHTDB_SOURCES ${LIGHTDB_PYTHON_SOURCES}) - - -# Build Python modules. -add_library(pylightdb SHARED ${LIGHTDB_PYTHON_SOURCES}) -target_compile_options(pylightdb PRIVATE "-fvisibility=default") - -target_link_libraries(pylightdb ${Boost_LIBRARIES} ${Python2_LIBRARIES} lightdb_shared) -target_link_libraries(pylightdb opencv_core) -set_target_properties(pylightdb PROPERTIES PREFIX "") diff --git a/python/include/PythonGeometry.h b/python/include/PythonGeometry.h deleted file mode 100644 index 010d58d..0000000 --- a/python/include/PythonGeometry.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef LIGHTDB_PYTHON_GEOMETRY_H -#define LIGHTDB_PYTHON_GEOMETRY_H - -#include "Geometry.h" -#include - -namespace lightdb::python { - class GeometryWrapper : public lightdb::Geometry, public boost::python::wrapper { - public: - bool is_monotonic() const override { - return this->get_override("is_monotonic")(); - } - bool defined_at(const lightdb::Point6D &point) const override { - return this->get_override("defined_at")(); - } - }; - - using angle = lightdb::number; - class MeshGeometryWrapper : public lightdb::MeshGeometry, public boost::python::wrapper { - public: - double u(angle theta, angle phi) const override { - return this->get_override("u")(); - } - double v(angle theta, angle phi) const override { - return this->get_override("v")(); - } - }; -} - - -#endif //LIGHTDB_PYTON_GEOMETRY_H \ No newline at end of file diff --git a/python/include/PythonLightField.h b/python/include/PythonLightField.h deleted file mode 100644 index c536d48..0000000 --- a/python/include/PythonLightField.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef LIGHTDB_PYTHON_LIGHT_FIELD_H -#define LIGHTDB_PYTHON_LIGHT_FIELD_H - -#include "Algebra.h" -#include "Catalog.h" -#include "Greyscale.h" -#include "Visitor.h" -#include "Coordinator.h" -#include "LightField.h" -#include "extension.h" -#include "reference.h" -#include "PythonOptimizer.h" -#include "PythonOptions.h" - -namespace lightdb::python { - - class PythonLightField { - public: - explicit PythonLightField(const lightdb::LightFieldReference &lightField); - PythonLightField Partition(lightdb::Dimension dimension, double interval); - PythonLightField Select(const lightdb::PhiRange &phiRange); - PythonLightField Select(const lightdb::ThetaRange &thetaRange); - PythonLightField Select(lightdb::SpatiotemporalDimension dimension, const lightdb::SpatiotemporalRange &range); - PythonLightField Subquery(PyObject *PyObject); - PythonLightField Union(PythonLightField &lightField); - PythonLightField Union(boost::python::list &listOfLightFields); - PythonLightField Discretize(lightdb::Dimension dimension, double interval); - PythonLightField Interpolate(lightdb::Dimension dimension); - PythonLightField Map(PyObject *udf, const std::filesystem::path &path); - PythonLightField Map(const lightdb::functor::unaryfunctor &functor); - PythonLightField Encode(); - PythonLightField Save(const std::string &filename); - PythonLightField Store(const lightdb::catalog::Catalog &catalog, const std::string &name); - lightdb::LightFieldReference query(); - - private: - lightdb::LightFieldReference _lightField; - }; -} - -#endif //LIGHTDB_PYTHON_LIGHT_FIELD_H \ No newline at end of file diff --git a/python/include/PythonOptimizer.h b/python/include/PythonOptimizer.h deleted file mode 100644 index 1efa618..0000000 --- a/python/include/PythonOptimizer.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef LIGHTDB_PYTHON_OPTIMIZER_H -#define LIGHTDB_PYTHON_OPTIMIZER_H - -#include "Optimizer.h" -#include "HeuristicOptimizer.h" -#include - -namespace lightdb::python { - class OptimizerWrapper : public lightdb::optimization::Optimizer, public boost::python::wrapper { - protected: - const std::vector> rules() const override { - return this->get_override("rules")(); - } - }; -} - -#endif //LIGHTDB_PYTHON_OPTIMIZER_H \ No newline at end of file diff --git a/python/include/PythonOptions.h b/python/include/PythonOptions.h deleted file mode 100644 index 31ebd6d..0000000 --- a/python/include/PythonOptions.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef LIGHTDB_PYTHON_OPTIONS_H -#define LIGHTDB_PYTHON_OPTIONS_H - -#include "Geometry.h" -#include "options.h" -#include "errors.h" -#include -#include -#include -#include -#include - -namespace lightdb::python { - template - class PythonOptions { - public: - explicit PythonOptions(const boost::python::dict &optDict) { - boost::python::list keys = boost::python::list(optDict.keys()); - for (auto i = 0u; i < len(keys); ++i) { - boost::python::extract extractor_keys(keys[i]); - std::string key = extractor_keys(); - std::any value = dictToMap(key, optDict); - _internalMap[key] = value; - } - } - - operator lightdb::options() const { return lightdb::options(_internalMap); } - - private: - std::unordered_map _internalMap; - - static std::any dictToMap(const std::string &key, const boost::python::dict &optDict) { - std::any value{}; - - if (key == "Volume") { - boost::python::extract extractor_values(optDict[key]); - value = std::make_any(extractor_values()); - } else if (key == "Projection") { - boost::python::extract extractor_values(optDict[key]); - value = std::make_any(extractor_values()); - } else if (key == "GOP") { - boost::python::extract extractor_values(optDict[key]); - value = std::make_any(extractor_values()); - } else { - throw InvalidArgumentError("Allowed dictionary keys : Volume, Projection, GOP", key); - } - return value; - } - }; -} - -#endif // LIGHTDB_PYTHON_OPTIONS_H \ No newline at end of file diff --git a/python/src/Module.cc b/python/src/Module.cc deleted file mode 100755 index 85e1340..0000000 --- a/python/src/Module.cc +++ /dev/null @@ -1,87 +0,0 @@ -#include "PythonLightField.h" -#include "PythonGeometry.h" -#include - - -namespace lightdb::python { - BOOST_PYTHON_MODULE (pylightdb) { - lightdb::optimization::Optimizer::instance(lightdb::execution::LocalEnvironment()); - - boost::python::def("Load", +[](const std::string &filepath, boost::python::dict string_options) -> PythonLightField { - return PythonLightField(lightdb::logical::Load(filepath, PythonOptions{string_options})); - }); - boost::python::def("Scan", +[](const std::string &name) -> PythonLightField { - return PythonLightField(lightdb::logical::Scan(name)); - }); - - boost::python::class_("LightFieldReference", boost::python::no_init); - - boost::python::class_("PythonLightField", boost::python::no_init) - .def("Partition", &PythonLightField::Partition) - .def("Select", static_cast(&PythonLightField::Select)) - .def("Select", static_cast(&PythonLightField::Select)) - .def("Select", static_cast(&PythonLightField::Select)) - .def("Subquery", &PythonLightField::Subquery) - .def("Union", static_cast(&PythonLightField::Union)) - .def("Union", static_cast(&PythonLightField::Union)) - .def("Discretize", &PythonLightField::Discretize) - .def("Interpolate", &PythonLightField::Interpolate) - .def("Map", static_cast(&PythonLightField::Map)) - .def("Map", static_cast(&PythonLightField::Map)) - .def("Encode", &PythonLightField::Encode) - .def("Save", &PythonLightField::Save) - .def("Store", &PythonLightField::Store) - .def("query", &PythonLightField::query); - - boost::python::class_("Coordinator") - .def("Execute", static_cast(&lightdb::execution::Coordinator::execute)) - .def("Execute", static_cast(&lightdb::execution::Coordinator::execute)); - - boost::python::enum_("Dimension") - .value("X", lightdb::Dimension::X) - .value("Y", lightdb::Dimension::Y) - .value("Z", lightdb::Dimension::Z) - .value("Time", lightdb::Dimension::Time) - .value("Theta", lightdb::Dimension::Theta) - .value("Phi", lightdb::Dimension::Phi); - - boost::python::enum_("SpatiotemporalDimension") - .value("X", lightdb::SpatiotemporalDimension::X) - .value("Y", lightdb::SpatiotemporalDimension::Y) - .value("Z", lightdb::SpatiotemporalDimension::Z) - .value("Time", lightdb::SpatiotemporalDimension::Time); - - boost::python::class_("Codec", boost::python::no_init) - .def("Hevc", &lightdb::Codec::hevc, boost::python::return_value_policy()) - .staticmethod("Hevc") - .def("Boxes", &lightdb::Codec::boxes, boost::python::return_value_policy()) - .staticmethod("Boxes"); - - boost::python::class_("PhiRange", boost::python::init()); - boost::python::class_("ThetaRange", boost::python::init()); - boost::python::class_("SpatiotemporalRange", boost::python::init()); - - boost::python::class_("Catalog", boost::python::init()); - - boost::python::class_("Volume", boost::python::init()); - boost::python::class_("Geometry", boost::python::no_init); - boost::python::class_("MeshGeometry", boost::python::no_init); - boost::python::class_>("EquirectangularGeometry", boost::python::init()); - - // Exposing Optimizer is necessary so that HeuristicOptimizer can inherit from it. - // Don't expose the initializer because Optimizer is an abstract class. - boost::python::class_("Optimizer", boost::python::no_init); - boost::python::class_>("HeuristicOptimizer", boost::python::init()); - - // Exposing Environment is necessary so LocalEnvironment can inherit from it. - boost::python::class_("Environment", boost::python::no_init); - boost::python::class_>("LocalEnvironment"); - - boost::python::class_("Linear"); - - boost::python::class_>("UnaryFunctor", boost::python::no_init); - boost::python::class_>("Greyscale"); - - boost::python::class_>("PyOptions", boost::python::no_init); - }; -} // namespace Python diff --git a/python/src/PythonLightField.cc b/python/src/PythonLightField.cc deleted file mode 100644 index b083125..0000000 --- a/python/src/PythonLightField.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include "PythonLightField.h" - -namespace lightdb::python { - PythonLightField::PythonLightField(const lightdb::LightFieldReference &lightField) - : _lightField(lightField) - { } - - PythonLightField PythonLightField::Partition(lightdb::Dimension dimension, double interval) { - return PythonLightField(_lightField.Partition(dimension, interval)); - } - - PythonLightField PythonLightField::Select(const lightdb::PhiRange &phiRange) { - return PythonLightField(_lightField.Select(phiRange)); - } - - PythonLightField PythonLightField::Select(const lightdb::ThetaRange &thetaRange) { - return PythonLightField(_lightField.Select(thetaRange)); - } - - PythonLightField PythonLightField::Select(lightdb::SpatiotemporalDimension dimension, const lightdb::SpatiotemporalRange &range) { - return PythonLightField(_lightField.Select(dimension, range)); - } - - PythonLightField PythonLightField::Subquery(PyObject *pyObject) { - return PythonLightField(_lightField.Subquery([pyObject](auto l) { return boost::python::call(pyObject, PythonLightField(l)).query(); })); - } - - PythonLightField PythonLightField::Union(PythonLightField &lightField) { - return PythonLightField(_lightField.Union(lightField.query())); - } - - PythonLightField PythonLightField::Union(boost::python::list &listOfLightFields) { - std::vector pythonLightFields = std::vector( - boost::python::stl_input_iterator(listOfLightFields), - boost::python::stl_input_iterator()); - - std::vector lightFields; - std::transform(pythonLightFields.begin(), pythonLightFields.end(), std::back_inserter(lightFields), - [](PythonLightField lightField) -> lightdb::LightFieldReference { return lightField.query(); }); - - return PythonLightField(_lightField.Union(lightFields)); - } - - PythonLightField PythonLightField::Discretize(const lightdb::Dimension dimension, double interval) { - return PythonLightField(_lightField.Discretize(dimension, lightdb::number(interval))); - } - - PythonLightField PythonLightField::Interpolate(lightdb::Dimension dimension) { - return PythonLightField(_lightField.Interpolate(dimension, lightdb::interpolation::Linear())); - } - - //TODO : Expose UDFs - PythonLightField PythonLightField::Map(PyObject *udf, const std::filesystem::path &path) { - auto yolo = lightdb::extensibility::Load("yolo", path); - return PythonLightField(_lightField.Map(yolo)); - } - - PythonLightField PythonLightField::Map(const lightdb::functor::unaryfunctor &functor) { - return PythonLightField(_lightField.Map(functor)); - } - - PythonLightField PythonLightField::Encode() { - return PythonLightField(_lightField.Encode()); - } - - PythonLightField PythonLightField::Save(const std::string &fileName) { - return PythonLightField(_lightField.Save(static_cast(fileName))); - } - - PythonLightField PythonLightField::Store(const lightdb::catalog::Catalog &catalog, const std::string &name) { - return PythonLightField(_lightField.Store(name, catalog)); - } - - lightdb::LightFieldReference PythonLightField::query() { - return _lightField; - } - -} \ No newline at end of file diff --git a/python/test/test.py b/python/test/test.py deleted file mode 100755 index 0d1969f..0000000 --- a/python/test/test.py +++ /dev/null @@ -1,5 +0,0 @@ -import pytest -import pylightdb as db - -def scan_test(): - PythonLightField pydb = db.Scan() \ No newline at end of file diff --git a/pythonTests/test.py b/pythonTests/test.py deleted file mode 100644 index 1c7e25b..0000000 --- a/pythonTests/test.py +++ /dev/null @@ -1,13 +0,0 @@ -import pylightdb -from pylightdb import * - -x = SpatiotemporalRange(0,0) -y = SpatiotemporalRange(0,0) -z = SpatiotemporalRange(0,0) -vol = Volume(x,y,z) -geo = EquirectangularGeometry(2,1) -env = LocalEnvironment() -optimizer = HeuristicOptimizer(env) -coordinator = Coordinator() -query = Load("/home/pranay99/lightdb/test/resources/test-pattern.h264", {"Volume":vol, "Projection":geo}).Save("/home/pranay99/test.mp4") -coordinator.Execute(query.query(), optimizer) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c39e4eb..6e59284 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -35,6 +35,10 @@ get_property(LIGHTDB_INCLUDES DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INC string(REPLACE ";" "|" LIGHTDB_INCLUDES_STRING "${LIGHTDB_INCLUDES}") foreach(LIGHTDB_PLUGIN_DIR ${LIGHTDB_PLUGIN_DIRS}) + message("Lightdb plugin dir: ${LIGHTDB_PLUGIN_DIR}") + message("CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + message("LIGHTDB_PLUGIN_DIR: ${LIGHTDB_PLUGIN_DIR}") + message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}") if (IS_DIRECTORY ${LIGHTDB_PLUGIN_DIR}) get_filename_component(LIGHTDB_PLUGIN_NAME ${LIGHTDB_PLUGIN_DIR} NAME_WE) string(TOLOWER "${LIGHTDB_PLUGIN_DIR}/cmake-build-${CMAKE_BUILD_TYPE}" LIGHTDB_PLUGIN_BINARY_DIR) diff --git a/test/resources/ffmpeg-generate-video.sh b/test/resources/ffmpeg-generate-video.sh new file mode 100755 index 0000000..8d76bf0 --- /dev/null +++ b/test/resources/ffmpeg-generate-video.sh @@ -0,0 +1,7 @@ +# $1 - color +# $2 - duration +# $3 - frames per second + + +ffmpeg -f lavfi -i color=c=$1@0.2:duration=$2:s=qcif:r=$3 $1.mp4 +ffmpeg -i $1.mp4 -c copy $1.h264 diff --git a/test/src/execution/SelectionTests.cc b/test/src/execution/SelectionTests.cc index 140559c..9ed77de 100755 --- a/test/src/execution/SelectionTests.cc +++ b/test/src/execution/SelectionTests.cc @@ -86,6 +86,21 @@ TEST_F(SelectionTestFixture, testSelectPhi) { EXPECT_EQ(remove(Resources.out.hevc), 0); } +TEST_F(SelectionTestFixture, testSelectPhi2) { + auto query = Load("/home/maureen/lightdb/cmake-build-debug-remote/test/resources/red10/stream0.h264") + .Select(PhiRange{0, rational_times_real({1, 4}, PI)}) + .Encode() + .Save("/home/maureen/encoded0.hevc"); + + Coordinator().execute(query); + + EXPECT_VIDEO_VALID(Resources.out.hevc); + EXPECT_VIDEO_FRAMES(Resources.out.hevc, Resources.red10.frames); + EXPECT_VIDEO_RESOLUTION(Resources.out.hevc, Resources.red10.height / 4, Resources.red10.width); + EXPECT_VIDEO_RED(Resources.out.hevc); + EXPECT_EQ(remove(Resources.out.hevc), 0); +} + TEST_F(SelectionTestFixture, testSelectTheta) { REQUIRE_GPU(); @@ -156,6 +171,15 @@ TEST_F(SelectionTestFixture, testTemporalThetaSelect) { EXPECT_EQ(remove(Resources.out.hevc), 0); } +TEST_F(SelectionTestFixture, testPythonQuery) { + auto query = Load("/home/maureen/lightdb/test/resources/tiles/tile-6.hevc") + .Select(PhiRange{0, rational_times_real({3, 4}, PI)}) + .Encode() + .Save("/home/maureen/selected-tile-6-test.hevc"); + + Coordinator().execute(query); +} + TEST_F(SelectionTestFixture, testDegenerateTimeSelect) { REQUIRE_GPU(); diff --git a/test/src/execution/UDFTests.cc b/test/src/execution/UDFTests.cc index 0549eac..5c4ac8f 100755 --- a/test/src/execution/UDFTests.cc +++ b/test/src/execution/UDFTests.cc @@ -27,7 +27,7 @@ TEST_F(UDFTestFixture, testGreyscale) { auto query = Scan(Resources.red10.name) .Map(lightdb::Greyscale) .Encode() - .Save(Resources.out.hevc); + .Save("/home/maureen/grey_test.hevc"); Coordinator().execute(query);