資源簡介
純C深度學習庫,采用VS2010編譯,里面包含訓練數據MNIST,點擊就能生成,包括訓練和預測,另外送一個C讀取圖片的文件,有必要自己改寫代碼

代碼片段和文件信息
/*
???*This?program?will?open?a?imageand?output?to?another?file
???*Author:hujian?in?nankai?2016/3/29
*/
#include??
#include?
using?namespace?std;
#define???__FILENAME??“./img/in.jpg“??//this?is?the?default?imageif?no?input?filenamethe?image?will?be?used
int?main()
{
????//the?fp?is?the?file?stream?of?reading?data
????//the?out?is?the?file?stream?of?writing?to?file(hex)
????//the?dst?file?is?the?file?stream?of?dest?image
????//
????FILE?*fp?*out?*dstFile;
????//this?is?the?image?size
????//we?will?use?fseek?and?ftell?to?get?the?size
????//
????long?int?size;
????unsigned?char?ch?ch1?ch2;
????//get?the?higt?bites?and?low?bites
????//
????unsigned?char?high?low;
????//this?is?the?image?name?buffer
????//
????char?pic_name[30];
????memset(pic_name?0?sizeof(pic_name));
????//we?can?input?the?file‘s?nameand?the?program?will?open?the?image?and?do?some
????//oprtationsuch?as?read?datawrite?from?image?data..
????//
//#define?INPUT
#ifdef?INPUT?//if?we?want?to?input?the?filename?just?define?the?input.
????printf(“\nPlease?input?the?image‘s?name:“);
????cin?>>?pic_name;
#else??//okyou?don‘t?want?to?input
????strcpy_s(pic_name__FILENAME);
#endif??INPUT
????printf_s(“The?filename?is:%s\n“?pic_name);
????//the?follow?lines?will?open?the?file
????//
????{
????????//open?the?src?image?for?reading?the?image?data
????????//
????????fopen_s(&fp?pic_name?“rb“);
????????//open?the?text?stream(write)
????????//
????????fopen_s(&out“res.txt“?“wb+“);
????????//open?the?dest?image?file?stream
????????//
????????fopen_s(&dstFile“./img/res.jpg“?“wb+“);
????????//okcheck?the?file?stream
????????//
????????{
????????????if?(!fp?||?!out?||?!dstFile){
????????????????printf_s(“Can?not?open?the?file?you?inputcheck?the?filename?and?re-try\n“);
????????????????//exit(EXIT_FAILURE);
????????????}
????????}
????}//end?of?open?filenow?we?get?the?file?stream?done.
????//we?want?to?get?the?size?of?the?imagewe?just?use?the?fseek?and?ftell?get?the?size
????//
????fseek(fp?0?SEEK_END);
????size?=?ftell(fp);
????//printf?the?size
????printf(“get?the?size?is:?%d\n“?size);
????//rewind?means?jump?to?start?of?the?file
????//
????rewind(fp);
????//traversal?the?image?data
????//
????long?int?i;
????for?(i?=?0;?i ????{
????????ch?=?fgetc(fp);
????????high?=?ch?>>?4;
????????low?=?ch?&?0x0f;
????????if?(high?10)
????????????high?+=?‘0‘;
????????else
????????????high?+=?55;
????????if?(low?10)
????????????low?+=?‘0‘;
????????else
????????????low?+=?55;
????????//write?to?file?stream?out
????????//
????????fputc(high?out);
????????fputc(low?out);
????????fputc(‘?‘?out);
????????//16?one?line
????????//
????????if?(i?%?16?==?0)
????????????fprintf(out?“\r\n“);
????}
????//jump?to?start?of?the?image?file
????//
????rewind(fp);
????bool?FormatRight?=?false;
????for?(i?=?0;?i ????{
????????ch1?=?fgetc(fp);
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????.......???????876??2017-04-27?03:40??CNN\CNN.sln
????.......??????3515??2017-04-27?03:40??CNN\CNN\CNN.vcxproj
????.......??????1493??2017-04-27?03:40??CNN\CNN\CNN.vcxproj.filters
????.......???????143??2017-04-27?03:40??CNN\CNN\CNN.vcxproj.user
?????文件??????21411??2018-02-12?14:02??CNN\CNN\cnn.cpp
????.......??????4059??2017-04-27?03:40??CNN\CNN\cnn.h
?????文件???????5161??2018-02-12?19:49??CNN\CNN\main.cpp
????.......??????5817??2017-04-27?03:40??CNN\CNN\mat.cpp
????.......??????1357??2017-04-27?03:40??CNN\CNN\mat.h
????.......?????15592??2017-04-27?03:40??CNN\CNN\minst.cnn
?????文件???????4242??2018-02-10?19:41??CNN\CNN\minst.cpp
????.......???????934??2017-04-27?03:40??CNN\CNN\minst.h
????.......????????37??2017-04-27?03:40??CNN\CNN\Minst\ReadMe.txt
?????文件????7840016??2017-12-24?23:01??CNN\CNN\Minst\test-images.idx3-ubyte
?????文件??????10008??2017-12-24?23:00??CNN\CNN\Minst\test-labels.idx1-ubyte
?????文件???47040016??2017-12-24?23:00??CNN\CNN\Minst\train-images.idx3-ubyte
?????文件??????60008??2017-12-24?23:00??CNN\CNN\Minst\train-labels.idx1-ubyte
?????文件???????3801??2018-02-12?19:34??CNN\readImageC.c
?????目錄??????????0??2018-02-10?19:37??CNN\CNN\Minst\testImgs
?????目錄??????????0??2018-02-12?14:01??CNN\CNN\PicTrans\CNNData
?????目錄??????????0??2017-04-27?03:40??CNN\CNN\Minst
?????目錄??????????0??2018-02-10?19:38??CNN\CNN\PicTrans
?????目錄??????????0??2017-04-27?03:40??CNN\CNN
?????目錄??????????0??2017-04-27?03:40??CNN
-----------?---------??----------?-----??----
?????????????55018486????????????????????24
- 上一篇:JSN-SR04T超聲波測距資料
- 下一篇:矩形檢測OPENCV
評論
共有 條評論