loadImage.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __IMAGE_LOADER_H_
  23. #define __IMAGE_LOADER_H_
  24. #include <opencv2/core/mat.hpp>
  25. #include "../util/cuda/cudaUtility.h"
  26. /**
  27. * Load a color image from disk into CUDA memory with alpha.
  28. * This function loads the image into shared CPU/GPU memory, using the functions from cudaMappedMemory.h
  29. *
  30. * @param filename Path to the image file on disk.
  31. * @param cpu Pointer to CPU buffer allocated containing the image.
  32. * @param gpu Pointer to CUDA device buffer residing on GPU containing image.
  33. * @param width Variable containing width in pixels of the image.
  34. * @param height Variable containing height in pixels of the image.
  35. *
  36. * @ingroup util
  37. */
  38. bool loadImageRGBA( const char* filename, float4** cpu, float4** gpu, int* width, int* height );
  39. /**
  40. * Save an image to disk
  41. * @ingroup util
  42. */
  43. bool saveImageRGBA( const char* filename, float4* cpu, int width, int height, float max_pixel=255.0f );
  44. /**
  45. * Load a color image from disk into CUDA memory.
  46. * This function loads the image into shared CPU/GPU memory, using the functions from cudaMappedMemory.h
  47. *
  48. * @param filename Path to the image file on disk.
  49. * @param cpu Pointer to CPU buffer allocated containing the image.
  50. * @param gpu Pointer to CUDA device buffer residing on GPU containing image.
  51. * @param width Variable containing width in pixels of the image.
  52. * @param height Variable containing height in pixels of the image.
  53. *
  54. * @ingroup util
  55. */
  56. bool loadImageRGB( const char* filename, float3** cpu, float3** gpu, int* width, int* height, const float3& mean=make_float3(0,0,0) );
  57. /**
  58. * Load a color image from disk into CUDA memory.
  59. * This function loads the image into shared CPU/GPU memory, using the functions from cudaMappedMemory.h
  60. *
  61. * @param filename Path to the image file on disk.
  62. * @param cpu Pointer to CPU buffer allocated containing the image.
  63. * @param gpu Pointer to CUDA device buffer residing on GPU containing image.
  64. * @param width Variable containing width in pixels of the image.
  65. * @param height Variable containing height in pixels of the image.
  66. *
  67. * @ingroup util
  68. */
  69. bool loadImageBGR( cv::Mat frame, float3** cpu, float3** gpu, int* width, int* height, const float3& mean=make_float3(0,0,0) );
  70. #endif