Commit 68491042 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

More refactoring

parent 46256d14
Loading
Loading
Loading
Loading

src/TpHostGpu.cu

0 → 100644
+12 −0
Original line number Diff line number Diff line
/*
 * TpHostGpu.cu
 *
 *  Created on: Apr 2, 2025
 *      Author: elphel
 */
#include "TpParams.h"
#include "tp_paths.h"
#include "TpHostGpu.h"


src/TpHostGpu.h

0 → 100644
+24 −0
Original line number Diff line number Diff line
/*
 * TpHostGpu.h
 *
 *  Created on: Apr 2, 2025
 *      Author: elphel
 */

#ifndef SRC_TPHOSTGPU_H_
#define SRC_TPHOSTGPU_H_
#include "TpParams.h"
class TpHostGpu{
public:
	TpParams& m_tpParams;
	TpPaths& m_tpPaths;
	TpHostGpu(TpParams& tpParams, TpPaths& tpPaths)
	:m_tpParams{tpParams}
	,m_tpPaths{tpPaths}
	{};
};




#endif /* SRC_TPHOSTGPU_H_ */

src/TpParams.cu

0 → 100644
+45 −0
Original line number Diff line number Diff line
/*
 * TpParams.cu
 *
 *  Created on: Mar 31, 2025
 *      Author: elphel
 */
#include <math.h>
#include "tp_defines.h"   // was not here
#include "geometry_correction.h"
#include "TpParams.h"
TpParams::TpParams(int lwir){
	m_lwir = lwir;
	for (int i = 0; i < sizeof(color_weights)/sizeof(color_weights[0]); i++) {
		color_weights[i] =              lwir? m_color_weights_lwir[i] :        m_color_weights_rgb[i];
	}
	for (int i = 0; i < sizeof(generate_RBGA_params)/sizeof(generate_RBGA_params[0]); i++) {
		generate_RBGA_params[i] =       lwir? m_generate_RBGA_params_lwir[i] : m_generate_RBGA_params_rgb[i];
	}
	num_cams =                   lwir? m_num_cams_lwir :             m_num_cams_rgb;
	num_colors =                 lwir? m_num_colors_lwir :           m_num_colors_rgb;
	num_pairs =                  lwir? m_num_pairs_lwir :            m_num_pairs_rgb;
	sel_pairs =                  lwir? m_sel_pairs_lwir :            m_sel_pairs_rgb;
	task_size = get_task_size(num_cams); // sizeof(struct tp_task)/sizeof(float) - 6 * (NUM_CAMS - num_cams);
    if (num_cams == 4){
    	for (int ncam = 0; ncam < 4; ncam++){
    		port_offsets[ncam][0]= port_offsets4[ncam][0];
    		port_offsets[ncam][1]= port_offsets4[ncam][1];
    	}
    } else {
		 for (int ncam = 0; ncam < num_cams; ncam++) {
			 double alpha = 2 * M_PI * (ncam) /num_cams; // math.h
			 port_offsets[ncam][0] =  0.5 * sin((alpha));
			 port_offsets[ncam][1] = -0.5 * cos((alpha));
		 }
    }
    texture_colors = num_colors; // 3; // result will be 3+1 RGBA (for mono - 2)
    kern_tiles = KERNELS_HOR *  KERNELS_VERT * num_colors; // NUM_COLORS;
    kern_size =  kern_tiles * 4 * 64;
    corr_size =  (2 * CORR_OUT_RAD + 1) * (2 * CORR_OUT_RAD + 1); // CORR_SIZE;



}

src/TpParams.h

0 → 100644
+70 −0
Original line number Diff line number Diff line
/*
 * TpParams.h
 *
 *  Created on: Mar 31, 2025
 *      Author: elphel
 */

#ifndef SRC_TPPARAMS_H_
#define SRC_TPPARAMS_H_
#include <math.h>
class TpParams{
	static constexpr int m_num_cams_lwir =   16;
	static constexpr int m_num_colors_lwir =  1;
	static constexpr int m_num_pairs_lwir = 120;
	static constexpr int m_num_cams_rgb =     4;
	static constexpr int m_num_colors_rgb =   3;
	static constexpr int m_num_pairs_rgb =    6;
	static constexpr unsigned int m_sel_pairs_lwir[4] = {0xffffffff,0xffffffff,0xffffffff,0x00ffffff};
	static constexpr unsigned int m_sel_pairs_rgb[4] =  {0x3f,0,0,0};
	static constexpr int max_num_cams {std::max(m_num_cams_rgb,m_num_cams_lwir)}; // it is always 16 element, RGB uses only first 4
public:
	TpParams(int lwir);
	int     m_lwir;
	float   color_weights[3]{};
	float   generate_RBGA_params[5]{};
    int     num_cams{};
    int     num_colors{};
    int     num_pairs{};
    const unsigned int   * sel_pairs{};
    int     task_size;
    float port_offsets4[4][2] {// used only in textures to scale differences
			{-0.5, -0.5},
			{ 0.5, -0.5},
			{-0.5,  0.5},
			{ 0.5,  0.5}};

    // Could not make it variable port_offsets[?][2], 16 is maximal size

    float port_offsets[max_num_cams][2]; // [NUM_CAMS][2];
    int keep_texture_weights {3}; // 0; // 1; // try with 0 also
    int texture_colors; // 3; // result will be 3+1 RGBA (for mono - 2)
    int kern_tiles;
    int kern_size;
    int corr_size;
//    std::vector<float[2]> m_port_offsets;


private:
    float  m_color_weights_lwir[3] = {
    		1.0f,          // float             weight0,            // scale for R 0.5 / (1.0 + 0.5 +0.2)
			1.0f,          // float             weight1,            // scale for B 0.2 / (1.0 + 0.5 +0.2)
			1.0f};         // float             weight2,            // scale for G 1.0 / (1.0 + 0.5 +0.2)
    float  m_generate_RBGA_params_lwir[5] = {
    		10.0f,         // float             min_shot,           // 10.0
			3.0f,          // float             scale_shot,         // 3.0
			10.0f, // 1.5f,// float             diff_sigma,         // pixel value/pixel change
			10.0f,         // float             diff_threshold,     // pixel value/pixel change
			12.0f}; // 3.0 // float             min_agree,          // minimal number of channels to agree on a point (real number to work with fuzzy averages)
    float m_color_weights_rgb [3] = {
    		0.294118f,     // float             weight0,            // scale for R 0.5 / (1.0 + 0.5 +0.2)
			0.117647f,     // float             weight1,            // scale for B 0.2 / (1.0 + 0.5 +0.2)
			0.588235f};    // float             weight2,            // scale for G 1.0 / (1.0 + 0.5 +0.2)
    float m_generate_RBGA_params_rgb[5] = {
    		10.0f,         // float             min_shot,           // 10.0
			3.0f,          // float             scale_shot,         // 3.0
			1.5f,          // float             diff_sigma,         // pixel value/pixel change
			10.0f,         // float             diff_threshold,     // pixel value/pixel change
			3.0f};         // float             min_agree,          // minimal number of channels to agree on a point (real number to work with fuzzy averages)
};
#endif /* SRC_TPPARAMS_H_ */
Loading