Skip to content

Commit

Permalink
STBI_ONLY_JPEG (#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
jomjol authored Jan 11, 2023
1 parent eefdc74 commit a390924
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
12 changes: 6 additions & 6 deletions code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,9 @@ bool ClassFlowCNNGeneral::doAlignAndCut(string time)
if (SaveAllFiles)
{
if (GENERAL[_ana]->name == "default")
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".bmp"));
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
else
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".bmp"));
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
}
}

Expand Down Expand Up @@ -826,20 +826,20 @@ std::vector<HTMLInfo*> ClassFlowCNNGeneral::GetHTMLInfo()
if (GENERAL[_ana]->ROI[i]->image)
{
if (GENERAL[_ana]->name == "default")
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".bmp"));
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
else
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".bmp"));
GENERAL[_ana]->ROI[i]->image->SaveToFile(FormatFileName("/sdcard/img_tmp/" + GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg"));
}

HTMLInfo *zw = new HTMLInfo;
if (GENERAL[_ana]->name == "default")
{
zw->filename = GENERAL[_ana]->ROI[i]->name + ".bmp";
zw->filename = GENERAL[_ana]->ROI[i]->name + ".jpg";
zw->filename_org = GENERAL[_ana]->ROI[i]->name + ".jpg";
}
else
{
zw->filename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".bmp";
zw->filename = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg";
zw->filename_org = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg";
}

Expand Down
6 changes: 5 additions & 1 deletion code/components/jomjol_image_proc/CAlignAndCutImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int d
p_target[_channels] = p_source[_channels];
}

// stbi_write_jpg(_template1.c_str(), dx, dy, channels, odata, 0);
#ifdef STBI_ONLY_JPEG
stbi_write_jpg(_template1.c_str(), dx, dy, channels, odata, 100);
#else
stbi_write_bmp(_template1.c_str(), dx, dy, channels, odata);
#endif


RGBImageRelease();

Expand Down
4 changes: 3 additions & 1 deletion code/components/jomjol_image_proc/CImageBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,13 @@ void CImageBasis::SaveToFile(std::string _imageout)
{
stbi_write_jpg(_imageout.c_str(), width, height, channels, rgb_image, 0);
}


#ifndef STBI_ONLY_JPEG
if ((typ == "bmp") || (typ == "BMP"))
{
stbi_write_bmp(_imageout.c_str(), width, height, channels, rgb_image);
}
#endif
RGBImageRelease();
}

Expand Down
2 changes: 1 addition & 1 deletion code/include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
//#define STB_IMAGE_IMPLEMENTATION
//#define STB_IMAGE_WRITE_IMPLEMENTATION
//#define STB_IMAGE_RESIZE_IMPLEMENTATION
//#define STBI_ONLY_JPEG // (save 2% of Flash, but breaks the alignment mark generation, see https://github.com/jomjol/AI-on-the-edge-device/issues/1721)
#define STBI_ONLY_JPEG // (save 2% of Flash, but breaks the alignment mark generation, see https://github.com/jomjol/AI-on-the-edge-device/issues/1721)

//interface_influxdb
#define MAX_HTTP_OUTPUT_BUFFER 2048
Expand Down

0 comments on commit a390924

Please sign in to comment.