Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/camera n frame count #145

Merged
merged 61 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
463bf21
added BBs for mono8 cameras
Fixstars-momoko Apr 7, 2023
f12d258
updated gain/exposuretime type
Fixstars-momoko May 1, 2023
1ede69c
obtain part data instead of genDC
Fixstars-momoko May 1, 2023
8b9f7ec
fixed the issue of framecout
Fixstars-momoko May 8, 2023
74eaea2
confirmed to update float vals
Fixstars-momoko May 8, 2023
150eb65
got rid of debug log
Fixstars-momoko May 8, 2023
8694d1a
successfully getting gendcdescriptor-length
Fixstars-momoko May 15, 2023
70c8e27
WIP: no seg-fault
Fixstars-momoko May 16, 2023
a9ecbab
WIP: successfully obtained gendcdescriptor
Fixstars-momoko May 25, 2023
136b326
WIP: the cases of image/non-image sensor data
Fixstars-momoko May 26, 2023
a1183a4
frame count applied to both gendc/non-gendc
Fixstars-momoko May 26, 2023
367ff26
works on non-gendc supported
Fixstars-momoko Jun 14, 2023
9fba188
added the version log
Fixstars-momoko Jun 15, 2023
5359570
get rid of framecount
Fixstars-momoko Jun 16, 2023
66875b0
WIP: trying to set output of gendc
Fixstars-momoko Jun 19, 2023
270be70
WIP: successfully obtained the signature of GENDC Descriptor
Fixstars-momoko Jun 19, 2023
af4478b
WIP: now output is whole-gendc
Fixstars-momoko Jun 20, 2023
4549106
WIP: successfully saved gendc to bin
Fixstars-momoko Jun 26, 2023
df86d3f
updated the name of BB with 2 inputs
Fixstars-momoko Jun 30, 2023
24cbb77
WIP: export config.json
Fixstars-momoko Jun 30, 2023
0207f2d
WIP: worked on Mono12
Fixstars-momoko Jun 30, 2023
8337f0e
WIP: successfully passed rawHeader
Fixstars-momoko Jul 1, 2023
e1fcf81
minor update
Fixstars-momoko Jul 1, 2023
ae4d98a
fixed the prev commit
Fixstars-momoko Jul 6, 2023
f94f34d
allows to use one camera while more than one is connected to the host…
Fixstars-momoko Jul 7, 2023
1712294
worked on a single image sensor
Fixstars-momoko Jul 7, 2023
e6ad884
hot-fix for the device having no AcquisitionFrameRate
Fixstars-momoko Jul 14, 2023
f6485ee
Merge branch 'master' into internal-develop
Fixstars-momoko Jul 27, 2023
aa9c8d6
Merge branch 'master' into internal-develop
Fixstars-momoko Jul 27, 2023
3842c36
WIP: confirmed to display 2-cam images
Fixstars-momoko Jul 27, 2023
fce970b
WIP: successfully passed Halide Func as input
Fixstars-momoko Jul 28, 2023
8cf56a1
N-cam-N-USB for U3V BBs
Fixstars-momoko Jul 28, 2023
f2a823f
confirmed to work on camera1 too
Fixstars-momoko Jul 28, 2023
7a75660
WIP: worked with 1cam
Fixstars-momoko Jul 31, 2023
320dc80
WIP: worked with a single camera
Fixstars-momoko Jul 31, 2023
da1948e
worked with 2 cames
Fixstars-momoko Jul 31, 2023
14c5a4a
get rid of framecount from the latest BB
Fixstars-momoko Jul 31, 2023
06ef05a
confirmed the compatibility
Fixstars-momoko Aug 1, 2023
d60088e
corrected the name of bb
Fixstars-momoko Aug 1, 2023
1587fa8
fixed the order of 2-cam
Fixstars-momoko Aug 1, 2023
4fffa52
updated the name of parameter
Fixstars-momoko Aug 10, 2023
e6fdf47
adding dynamic white balance adjuster
Fixstars-momoko Aug 16, 2023
e1f9e87
resolve merge conflict
Fixstars-momoko Aug 29, 2023
5fbf4c2
WIP: confirmed that OperationMode value is obtained
Fixstars-momoko Sep 12, 2023
eca6f07
came1usb2 worked for get (image only data)
Fixstars-momoko Sep 12, 2023
91bc2fb
fixed the place of counting; confirmed get() works
Fixstars-momoko Sep 13, 2023
e90b90a
confirmed to save GenDC
Fixstars-momoko Sep 14, 2023
ab733f8
WIP: image_io_u3v_camera2_uXxY worked without float
Fixstars-momoko Sep 28, 2023
e412668
Revert "WIP: image_io_u3v_camera2_uXxY worked without float"
Fixstars-momoko Sep 28, 2023
8b9c42d
WIP float works on the existing BB
Fixstars-momoko Sep 28, 2023
8d4bbe6
worked with int params
Fixstars-momoko Sep 28, 2023
dcf0ee5
unified the BBs for float and int params
Fixstars-momoko Sep 28, 2023
8bdb1be
updated the debug log date
Fixstars-momoko Sep 28, 2023
6e173e5
merged
Fixstars-momoko Sep 28, 2023
d91d29d
WIP: fixed the gendc-separator
Fixstars-momoko Sep 29, 2023
4d135e9
WIP: tentatively remove u3v_jit
Fixstars-momoko Sep 29, 2023
8a305f6
Merge branch 'master' into internal-develop
Fixstars-momoko Oct 12, 2023
d1e9785
added RGB8/GBR8 support on U3V class
Fixstars-momoko Oct 12, 2023
9b87295
updated the log version
Fixstars-momoko Oct 12, 2023
a977ada
Merge branch 'internal-develop' of github.com:Fixstars-momoko/ion-kit…
Fixstars-momoko Oct 12, 2023
db7cdfe
Implemented frame count output for cameraN BB
Fixstars-iizuka Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ion_jit(demo_jit SRCS demo.cc)
ion_jit(imx219_isp_display_jit SRCS imx219_isp_display.cc)
ion_jit(gender_count SRCS gender_count.cc)
ion_jit(io SRCS io.cc)
ion_jit(u3v_jit SRCS u3v.cc)
# ion_jit(u3v_jit SRCS u3v.cc)

ion_register_test(isp isp_jit TARGET_STRING "host-profile")
ion_register_test(isp_and_sgm isp_and_sgm_jit TARGET_STRING "host-profile")
Expand Down
251 changes: 244 additions & 7 deletions include/ion-bb-image-io/bb.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,10 @@ class U3VCamera1 : public ion::BuildingBlock<U3VCamera1<T, D>> {
GeneratorParam<std::string> gain_key_ptr{"gain_key", "Gain"};
GeneratorParam<std::string> exposure_key_ptr{"exposure_key", "Exposure"};
GeneratorParam<bool> realtime_diaplay_mode{"realtime_diaplay_mode", false};

GeneratorInput<bool> dispose{ "dispose" };
GeneratorInput<int32_t> gain0{ "gain0" };
GeneratorInput<int32_t> exposure0{ "exposure0" };
GeneratorInput<double> gain0{ "gain0" };
GeneratorInput<double> exposure0{ "exposure0" };

GeneratorOutput<Halide::Func> output0{ "output0", Halide::type_of<T>(), D};
GeneratorOutput<Halide::Func> frame_count{ "frame_count", Halide::type_of<uint32_t>(), 1 };
Expand Down Expand Up @@ -607,6 +607,7 @@ class U3VCamera1 : public ion::BuildingBlock<U3VCamera1<T, D>> {
};

using U3VCamera1_U8x3 = U3VCamera1<uint8_t, 3>;
using U3VCamera1_U8x2 = U3VCamera1<uint8_t, 2>;
using U3VCamera1_U16x2 = U3VCamera1<uint16_t, 2>;

template<typename T, int D>
Expand All @@ -620,10 +621,10 @@ class U3VCamera2 : public ion::BuildingBlock<U3VCamera2<T, D>> {
GeneratorParam<bool> realtime_diaplay_mode{"realtime_diaplay_mode", false};

GeneratorInput<bool> dispose{ "dispose" };
GeneratorInput<int32_t> gain0{ "gain0" };
GeneratorInput<int32_t> gain1{ "gain1" };
GeneratorInput<int32_t> exposure0{ "exposure0" };
GeneratorInput<int32_t> exposure1{ "exposure1" };
GeneratorInput<double> gain0{ "gain0" };
GeneratorInput<double> gain1{ "gain1" };
GeneratorInput<double> exposure0{ "exposure0" };
GeneratorInput<double> exposure1{ "exposure1" };

GeneratorOutput<Halide::Func> output0{ "output0", Halide::type_of<T>(), D};
GeneratorOutput<Halide::Func> output1{ "output1", Halide::type_of<T>(), D};
Expand Down Expand Up @@ -671,8 +672,168 @@ class U3VCamera2 : public ion::BuildingBlock<U3VCamera2<T, D>> {
};

using U3VCamera2_U8x3 = U3VCamera2<uint8_t, 3>;
using U3VCamera2_U8x2 = U3VCamera2<uint8_t, 2>;
using U3VCamera2_U16x2 = U3VCamera2<uint16_t, 2>;

template<typename T, int D>
class U3VCameraN : public ion::BuildingBlock<U3VCameraN<T, D>> {
public:
GeneratorParam<int32_t> num_devices{"num_devices", 2};

GeneratorParam<bool> frame_sync{"frame_sync", false};
GeneratorParam<std::string> pixel_format_ptr{"pixel_format_ptr", "RGB8"};
GeneratorParam<std::string> gain_key_ptr{"gain_key", "Gain"};
GeneratorParam<std::string> exposure_key_ptr{"exposure_key", "Exposure"};
GeneratorParam<bool> realtime_diaplay_mode{"realtime_diaplay_mode", false};

GeneratorInput<bool> dispose{ "dispose", false };
GeneratorInput<Halide::Func> gain{ "gain", Halide::type_of<double>(), 1};
GeneratorInput<Halide::Func> exposure{ "exposure", Halide::type_of<double>(), 1};

GeneratorOutput<Halide::Func[]> output{ "output", Halide::type_of<T>(), D};
GeneratorOutput<Halide::Func> frame_count{ "frame_count", Halide::type_of<uint32_t>(), 1 };

void generate() {
using namespace Halide;

Func gain_func;
gain_func(_) = gain(_);
gain_func.compute_root();

Func exposure_func;
exposure_func(_) = exposure(_);
exposure_func.compute_root();

Func cameraN("u3v_cameraN");
{
const std::string pixel_format(pixel_format_ptr);
Buffer<uint8_t> pixel_format_buf(static_cast<int>(pixel_format.size() + 1));
pixel_format_buf.fill(0);
std::memcpy(pixel_format_buf.data(), pixel_format.c_str(), pixel_format.size());

const std::string gain_key(gain_key_ptr);
Buffer<uint8_t> gain_key_buf(static_cast<int>(gain_key.size() + 1));
gain_key_buf.fill(0);
std::memcpy(gain_key_buf.data(), gain_key.c_str(), gain_key.size());

const std::string exposure_key(exposure_key_ptr);
Buffer<uint8_t> exposure_key_buf(static_cast<int>(exposure_key.size() + 1));
exposure_key_buf.fill(0);
std::memcpy(exposure_key_buf.data(), exposure_key.c_str(), exposure_key.size());

std::vector<ExternFuncArgument> params{
dispose, static_cast<bool>(frame_sync), static_cast<bool>(realtime_diaplay_mode),
gain_func, exposure_func, pixel_format_buf,
gain_key_buf, exposure_key_buf
};

output.resize(num_devices);
if (output.size() == 1){
cameraN.define_extern("ion_bb_image_io_u3v_multiple_camera" + std::to_string(output.size()), params, Halide::type_of<T>(), D);
}else{
std::vector<Halide::Type> output_type;
for (int i = 0; i < output.size(); i++) {
output_type.push_back(Halide::type_of<T>());
}
cameraN.define_extern("ion_bb_image_io_u3v_multiple_camera" + std::to_string(output.size()), params, output_type, D);

}
cameraN.compute_root();
if (output.size() == 1){
output[0](_) = cameraN(_);
}else{
for (int i = 0; i < output.size(); i++) {
output[i](_) = cameraN(_)[i];
}
}
}

Func cameraN_fc("u3v_cameraN_fc");
{
const std::string pixel_format(pixel_format_ptr);
Buffer<uint8_t> pixel_format_buf(static_cast<int>(pixel_format.size() + 1));
pixel_format_buf.fill(0);
std::memcpy(pixel_format_buf.data(), pixel_format.c_str(), pixel_format.size());

std::vector<ExternFuncArgument> params{
cameraN, dispose, static_cast<int32_t>(output.size()), static_cast<bool>(frame_sync), static_cast<bool>(realtime_diaplay_mode), pixel_format_buf
};
cameraN_fc.define_extern("ion_bb_image_io_u3v_multiple_camera_frame_count" + std::to_string(output.size()), params, type_of<uint32_t>(), 1);
cameraN_fc.compute_root();
frame_count(_) = cameraN_fc(_);
}
}
};

using U3VCameraN_U8x3 = U3VCameraN<uint8_t, 3>;
using U3VCameraN_U8x2 = U3VCameraN<uint8_t, 2>;
using U3VCameraN_U16x2 = U3VCameraN<uint16_t, 2>;

class U3VGenDC : public ion::BuildingBlock<U3VGenDC> {
public:
GeneratorParam<int32_t> num_devices{"num_devices", 2};

GeneratorParam<bool> frame_sync{"frame_sync", false};
GeneratorParam<std::string> pixel_format_ptr{"pixel_format_ptr", "RGB8"};
GeneratorParam<std::string> gain_key_ptr{"gain_key", "Gain"};
GeneratorParam<std::string> exposure_key_ptr{"exposure_key", "Exposure"};
GeneratorParam<bool> realtime_diaplay_mode{"realtime_diaplay_mode", false};

GeneratorInput<bool> dispose{ "dispose" };
GeneratorInput<Halide::Func> gain{ "gain", Halide::type_of<double>(), 1};
GeneratorInput<Halide::Func> exposure{ "exposure", Halide::type_of<double>(), 1};

GeneratorOutput<Halide::Func[]> gendc{ "gendc", Halide::type_of<uint8_t>(), 1};
GeneratorOutput<Halide::Func[]> device_info{ "device_info", Halide::type_of<uint8_t>(), 1};

void generate() {
using namespace Halide;

Func gain_func;
gain_func(_) = gain(_);
gain_func.compute_root();

Func exposure_func;
exposure_func(_) = exposure(_);
exposure_func.compute_root();

const std::string pixel_format(pixel_format_ptr);
Buffer<uint8_t> pixel_format_buf(static_cast<int>(pixel_format.size() + 1));
pixel_format_buf.fill(0);
std::memcpy(pixel_format_buf.data(), pixel_format.c_str(), pixel_format.size());

const std::string gain_key(gain_key_ptr);
Buffer<uint8_t> gain_key_buf(static_cast<int>(gain_key.size() + 1));
gain_key_buf.fill(0);
std::memcpy(gain_key_buf.data(), gain_key.c_str(), gain_key.size());

const std::string exposure_key(exposure_key_ptr);
Buffer<uint8_t> exposure_key_buf(static_cast<int>(exposure_key.size() + 1));
exposure_key_buf.fill(0);
std::memcpy(exposure_key_buf.data(), exposure_key.c_str(), exposure_key.size());

std::vector<ExternFuncArgument> params{
dispose, static_cast<bool>(frame_sync), static_cast<bool>(realtime_diaplay_mode),
gain_func, exposure_func, pixel_format_buf,
gain_key_buf, exposure_key_buf
};

Func u3v_gendc("u3v_gendc");
gendc.resize(num_devices);
device_info.resize(num_devices);
std::vector<Halide::Type> output_type;
for (int i = 0; i < gendc.size() * 2; i++) {
output_type.push_back(Halide::type_of<uint8_t>());
}
u3v_gendc.define_extern("ion_bb_image_io_u3v_gendc_camera" + std::to_string(gendc.size()), params, output_type, 1);
u3v_gendc.compute_root();
for (int i = 0; i < gendc.size(); i++) {
gendc[i](_) = u3v_gendc(_)[2*i];
device_info[i](_) = u3v_gendc(_)[2*i+1];
}
}
};

class BinarySaver : public ion::BuildingBlock<BinarySaver> {
public:
GeneratorParam<std::string> output_directory_ptr{ "output_directory", "." };
Expand Down Expand Up @@ -736,6 +897,70 @@ class BinarySaver : public ion::BuildingBlock<BinarySaver> {
}
};

class BinaryGenDCSaver : public ion::BuildingBlock<BinaryGenDCSaver> {
public:
GeneratorParam<std::string> output_directory_ptr{ "output_directory", "." };

GeneratorParam<int32_t> num_devices{"num_devices", 2};

Input<Halide::Func[]> input_gendc{ "input_gendc", Halide::type_of<uint8_t>(), 1 };
Input<Halide::Func[]> input_deviceinfo{ "input_deviceinfo", Halide::type_of<uint8_t>(), 1 };

Input<bool> dispose{ "dispose" };
Input<int32_t> payloadsize{ "payloadsize" };

Output<int> output{ "output" };

void generate() {
using namespace Halide;
int32_t num_gendc = static_cast<int32_t>(num_devices);

const std::string output_directory(output_directory_ptr);
Halide::Buffer<uint8_t> output_directory_buf(static_cast<int>(output_directory.size() + 1));
output_directory_buf.fill(0);
std::memcpy(output_directory_buf.data(), output_directory.c_str(), output_directory.size());

if (num_gendc==1){
Func gendc;
gendc(_) = input_gendc(_);
gendc.compute_root();

Func deviceinfo;
deviceinfo(_) = input_deviceinfo(_);
deviceinfo.compute_root();

std::vector<ExternFuncArgument> params = { gendc, deviceinfo, dispose, payloadsize, output_directory_buf };
Func image_io_binary_gendc_saver;
image_io_binary_gendc_saver.define_extern("ion_bb_image_io_binary_1gendc_saver", params, Int(32), 0);
image_io_binary_gendc_saver.compute_root();
output() = image_io_binary_gendc_saver();
}else if (num_gendc ==2){
Func gendc0, gendc1;
Var x, y;
gendc0(_) = input_gendc[0](_);
gendc1(_) = input_gendc[1](_);
gendc0.compute_root();
gendc1.compute_root();

Func deviceinfo0, deviceinfo1;
deviceinfo0(_) = input_deviceinfo[0](_);
deviceinfo1(_) = input_deviceinfo[1](_);
deviceinfo0.compute_root();
deviceinfo1.compute_root();

std::vector<ExternFuncArgument> params = { gendc0, gendc1, deviceinfo0, deviceinfo1, dispose, payloadsize, output_directory_buf };
Func image_io_binary_gendc_saver;
image_io_binary_gendc_saver.define_extern("ion_bb_image_io_binary_2gendc_saver", params, Int(32), 0);
image_io_binary_gendc_saver.compute_root();
output() = image_io_binary_gendc_saver();
}else{
std::runtime_error("device number > 2 is not supported");
}


}
};

class BinaryLoader : public ion::BuildingBlock<BinaryLoader> {
public:
GeneratorParam<std::string> output_directory_ptr{ "output_directory_ptr", "" };
Expand Down Expand Up @@ -794,13 +1019,25 @@ ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::GrayscaleDataLoader, image_io_gra

ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::GUIDisplay, image_io_gui_display);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::ImageSaver, image_io_image_saver);

ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera1_U8x3, image_io_u3v_camera1_u8x3);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera1_U16x2, image_io_u3v_camera1_u16x2);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera1_U8x2, image_io_u3v_camera1_u8x2);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera2_U8x3, image_io_u3v_camera2_u8x3);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera2_U8x2, image_io_u3v_camera2_u8x2);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera2_U16x2, image_io_u3v_camera2_u16x2);

ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCameraN_U8x3, image_io_u3v_cameraN_u8x3);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCameraN_U8x2, image_io_u3v_cameraN_u8x2);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCameraN_U16x2, image_io_u3v_cameraN_u16x2);

ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VGenDC, image_io_u3v_gendc);

ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::BinarySaver, image_io_binarysaver);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::BinaryLoader, image_io_binaryloader);

ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::BinaryGenDCSaver, image_io_binary_gendc_saver);

//backward compatability
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera1_U8x3, u3v_camera1_u8x3);
ION_REGISTER_BUILDING_BLOCK(ion::bb::image_io::U3VCamera1_U16x2, u3v_camera1_u16x2);
Expand Down
Loading