Skip to content

Commit a9955d6

Browse files
committed
修改注释
1 parent 2f133fa commit a9955d6

File tree

7 files changed

+5
-70
lines changed

7 files changed

+5
-70
lines changed

app/src/main/java/com/flir/flirone/PreviewActivity.java

+3-58
Original file line numberDiff line numberDiff line change
@@ -52,53 +52,28 @@
5252
public class PreviewActivity extends Activity implements Device.Delegate, FrameProcessor.Delegate, Device.StreamDelegate, ConnectivityChangeReceiver.NetworkStateInteraction {
5353
private ImageView thermalImageView;
5454
private volatile boolean imageCaptureRequested = false;
55-
5655
private volatile Device flirOneDevice;
5756
private FrameProcessor frameProcessor;
58-
5957
private String lastSavedPath;
60-
61-
//控制警告是否打开
6258
private ToggleButton warnButton;
63-
64-
//播放警告音
6559
private MediaPlayer mp, mp_strong;
66-
67-
//拍照音效
6860
private SoundPool sp;
6961
private int sound;
70-
71-
//查看图片
7262
private ImageButton showImage;
7363
private ImageHelp imageHelp;
74-
75-
//设置阈值
7664
private Button showDialog;
7765
ThresholdHelp thresholdHelp;
78-
79-
//保存图片信息
8066
private double maxTemp, meantTemp;
8167
private int maxX, maxY;
82-
83-
//点击屏幕获取温度
8468
private int width;
8569
private int height;
8670
private short[] thermalPixels;
87-
88-
//nfc
8971
private TextView showNfcResult;
9072
private String nfc_result;
91-
92-
//检测网络状态
9373
private TextView showNetworkState;
94-
95-
//手机串号
9674
private TextView showTeleimei;
97-
98-
//校准
9975
private Device.TuningState currentTuningState = Device.TuningState.Unknown;
10076

101-
//Device.Delegate接口实现的方法,设备已连接
10277
public void onDeviceConnected(Device device) {
10378
runOnUiThread(new Runnable() {
10479
@Override
@@ -109,10 +84,8 @@ public void run() {
10984

11085
flirOneDevice = device;
11186
flirOneDevice.startFrameStream(this);
112-
11387
}
11488

115-
//Device.Delegate接口实现的方法,设备未连接
11689
public void onDeviceDisconnected(Device device) {
11790

11891
runOnUiThread(new Runnable() {
@@ -133,7 +106,6 @@ public void run() {
133106
public void onTuningStateChanged(Device.TuningState tuningState) {
134107

135108
currentTuningState = tuningState;
136-
//当热成像设备正在连接
137109
if (tuningState == Device.TuningState.InProgress) {
138110
runOnUiThread(new Thread() {
139111
@Override
@@ -148,7 +120,6 @@ public void run() {
148120
}
149121
});
150122
} else {
151-
//连接成功
152123
runOnUiThread(new Thread() {
153124
@Override
154125
public void run() {
@@ -166,7 +137,6 @@ public void onAutomaticTuningChanged(boolean deviceWillTuneAutomatically) {
166137

167138
}
168139

169-
//显示更新热成像视图
170140
private void updateThermalImageView(final Bitmap frame) {
171141
runOnUiThread(new Runnable() {
172142
@Override
@@ -176,7 +146,6 @@ public void run() {
176146
});
177147
}
178148

179-
//Device.StreamDelegate实现的方法,处理视图
180149
public void onFrameReceived(Frame frame) {
181150

182151
if (currentTuningState != Device.TuningState.InProgress) {
@@ -186,18 +155,15 @@ public void onFrameReceived(Frame frame) {
186155

187156
private Bitmap thermalBitmap = null;
188157

189-
//FrameProcessor.Delegate接口实现的方法,的获取温度,视图处理器授权方法,将访问每次的frame的产生,实时进行扫描
190158
public void onFrameProcessed(final RenderedImage renderedImage) {
191159

192160
if (renderedImage.imageType() == RenderedImage.ImageType.ThermalRadiometricKelvinImage) {
193161
// Note: this code is not optimized
194162

195-
thermalPixels = renderedImage.thermalPixelData(); //thermalPixels[76800]
196-
//每次扫描都会产生这样的一串数组
163+
thermalPixels = renderedImage.thermalPixelData();
197164

198-
// 计算中心周围9个像素的平均值
199165
width = renderedImage.width();
200-
height = renderedImage.height(); //width * height = 76800
166+
height = renderedImage.height();
201167
int centerPixelIndex = width * (height / 2) + (width / 2);
202168
int[] centerPixelIndexes = new int[]{
203169
centerPixelIndex, centerPixelIndex - 1, centerPixelIndex + 1,
@@ -209,7 +175,6 @@ public void onFrameProcessed(final RenderedImage renderedImage) {
209175
centerPixelIndex + width + 1
210176
};
211177

212-
//扫描全屏温度并进行高温预警
213178
new Thread(new Runnable() {
214179
short[] thermalPixels = renderedImage.thermalPixelData();
215180
int width = renderedImage.width();
@@ -250,7 +215,7 @@ public void run() {
250215
}).start();
251216
//////
252217

253-
double averageTemp = 0; //平均温度,单位K
218+
double averageTemp = 0;
254219

255220
for (int i = 0; i < centerPixelIndexes.length; i++) { //centerPixelIndexes.length = 9
256221
// Remember: all primitives are signed, we want the unsigned value,
@@ -263,7 +228,6 @@ public void run() {
263228
NumberFormat numberFormat = NumberFormat.getInstance();
264229
numberFormat.setMaximumFractionDigits(2);
265230
numberFormat.setMinimumFractionDigits(2);
266-
//显示温度
267231
final String spotMeterValue = numberFormat.format(averageC) + "ºC";
268232

269233
runOnUiThread(new Runnable() {
@@ -297,7 +261,6 @@ public void run() {
297261
updateThermalImageView(thermalBitmap);
298262
}
299263

300-
//捕获图像
301264
if (this.imageCaptureRequested) {
302265
imageCaptureRequested = false;
303266
final Context context = this;
@@ -334,8 +297,6 @@ public void onScanCompleted(String path, Uri uri) {
334297
}
335298

336299
}
337-
338-
//捕获图像单击事件
339300
public void onCaptureImageClicked(View v) {
340301

341302
if (flirOneDevice == null && lastSavedPath != null) {
@@ -372,7 +333,6 @@ private void setThumb() {
372333
}
373334
}
374335

375-
//获取文件名
376336
private String getFileName() {
377337
Date date = new Date();
378338
DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
@@ -381,7 +341,6 @@ private String getFileName() {
381341
return fileName;
382342
}
383343

384-
//热成像主界面
385344
@Override
386345
protected void onStart() {
387346
super.onStart();
@@ -405,7 +364,6 @@ protected void onStart() {
405364

406365
ScaleGestureDetector mScaleDetector;
407366

408-
//开机提示
409367
private ProgressBar loading;
410368
private ImageView spotMeterIcon;
411369

@@ -415,15 +373,12 @@ protected void onCreate(Bundle savedInstanceState) {
415373
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
416374
setContentView(R.layout.activity_preview);
417375

418-
//启动上传服务
419376
Intent serviceIntent = new Intent(PreviewActivity.this, UpLoadService.class);
420377
startService(serviceIntent);
421378

422-
//显示开机提示
423379
spotMeterIcon = (ImageView) findViewById(R.id.spotMeterIcon);
424380
loading = (ProgressBar) findViewById(R.id.loading);
425381

426-
//网络检测
427382
IntentFilter intentFilter = new IntentFilter();
428383
intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
429384
ConnectivityChangeReceiver receiver = new ConnectivityChangeReceiver();
@@ -433,8 +388,6 @@ protected void onCreate(Bundle savedInstanceState) {
433388
//网络状态
434389
showNetworkState = (TextView) findViewById(R.id.show_network_state);
435390

436-
//手机串号
437-
//设置手机串号
438391
try {
439392
showTeleimei = (TextView) findViewById(R.id.show_teleimei);
440393
TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
@@ -458,11 +411,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
458411
}
459412
});
460413

461-
//音效
462414
sp = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5);//第一个参数为同时播放数据流的最大个数,第二数据流类型,第三为声音质量
463415
sound = sp.load(this, R.raw.sound, 0);
464416

465-
//阈值
466417
showDialog = (Button) findViewById(R.id.showDialog);
467418
thresholdHelp = new ThresholdHelp(PreviewActivity.this, showDialog);
468419
thresholdHelp.setThreshold();
@@ -473,7 +424,6 @@ public void onClick(View v) {
473424
}
474425
});
475426

476-
//设置默认滤镜
477427
RenderedImage.ImageType defaultImageType = RenderedImage.ImageType.BlendedMSXRGBA8888Image;
478428
frameProcessor = new FrameProcessor(this, this, EnumSet.of(defaultImageType, RenderedImage.ImageType.ThermalRadiometricKelvinImage));
479429

@@ -494,15 +444,12 @@ public boolean onScale(ScaleGestureDetector detector) {
494444
}
495445
});
496446

497-
//查看所有图片按钮设置缩略图
498447
showImage = (ImageButton) findViewById(R.id.showImage);
499448
imageHelp = new ImageHelp(GlobalConfig.IMAGE_PATH);
500449
setThumb();
501450

502-
//检查所有图片的时间
503451
imageHelp.checkAllImagesDate();
504452

505-
//点击查看所有图片按钮进入图片展示页面
506453
showImage.setOnClickListener(new View.OnClickListener() {
507454
@Override
508455
public void onClick(View v) {
@@ -511,7 +458,6 @@ public void onClick(View v) {
511458
}
512459
});
513460

514-
//获取nfc 数据
515461
showNfcResult = (TextView) findViewById(R.id.show_nfc_result);
516462
if (getIntent() != null) {
517463
nfc_result = getIntent().getStringExtra("nfcresult");
@@ -553,7 +499,6 @@ protected void onDestroy() {
553499
super.onDestroy();
554500
}
555501

556-
//网络状态改变时设置提示文字
557502
@Override
558503
public void setNetworkState(String state) {
559504
if (state != null) {

app/src/main/java/com/flir/flirone/imagehelp/ImageHelp.java

-5
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ public Bitmap getImageThumbnail(String imagePath, int width, int height) {
6262
Bitmap bitmap = null;
6363
BitmapFactory.Options options = new BitmapFactory.Options();
6464
options.inJustDecodeBounds = true;
65-
// 获取这个图片的宽和高,注意此处的bitmap为null
6665
bitmap = BitmapFactory.decodeFile(imagePath, options);
6766
options.inJustDecodeBounds = false; // 设为 false
68-
// 计算缩放比
6967
int h = options.outHeight;
7068
int w = options.outWidth;
7169
int beWidth = w / width;
@@ -80,9 +78,7 @@ public Bitmap getImageThumbnail(String imagePath, int width, int height) {
8078
be = 1;
8179
}
8280
options.inSampleSize = be;
83-
// 重新读入图片,读取缩放后的bitmap,注意这次要把options.inJustDecodeBounds 设为 false
8481
bitmap = BitmapFactory.decodeFile(imagePath, options);
85-
// 利用ThumbnailUtils来创建缩略图,这里要指定要缩放哪个Bitmap对象
8682
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
8783
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
8884
return bitmap;
@@ -130,7 +126,6 @@ private String FormetFileSize(long fileS) {
130126
return fileSizeString;
131127
}
132128

133-
//从图片名中获取图片创建时间
134129
public String getTimeFromName(File file) {
135130
String name = file.getName();
136131

app/src/main/java/com/flir/flirone/imagehelp/MyImage.java

-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public MyImage(String isUpLoad) {
3333
this.isUpLoad = isUpLoad;
3434
}
3535

36-
//用于保存到数据库
3736
public MyImage(String isUpLoad, String teleimei, String barcode, String path, String imagename, String imagetime, String maxtemperature, String maxtemplocalx, String maxtemplocaly, String meantemperature) {
3837
this.isUpLoad = isUpLoad;
3938
this.teleimei = teleimei;
@@ -47,7 +46,6 @@ public MyImage(String isUpLoad, String teleimei, String barcode, String path, St
4746
this.meantemperature = meantemperature;
4847
}
4948

50-
//用于上传图片
5149
public MyImage(String isUpLoad, String teleimei, String barcode, Bitmap heatimage, String imagename, String imagetime, String maxtemperature, String maxtemplocalx, String maxtemplocaly, String meantemperature) {
5250
this.isUpLoad = isUpLoad;
5351
this.teleimei = teleimei;
@@ -61,7 +59,6 @@ public MyImage(String isUpLoad, String teleimei, String barcode, Bitmap heatimag
6159
this.meantemperature = meantemperature;
6260
}
6361

64-
//包含所有属性
6562
public MyImage(String teleimei, String barcode, Bitmap heatimage, String imagename, String path, String type, String size, String imagetime, String maxtemperature, String maxtemplocalx, String maxtemplocaly, String meantemperature) {
6663
this.teleimei = teleimei;
6764
this.barcode = barcode;

app/src/main/java/com/flir/flirone/networkhelp/ConnectivityChangeReceiver.java

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public void onReceive(Context context, Intent intent) {
2727
networkStateInteraction.setNetworkState(GlobalConfig.WIFI_CONNECTED);
2828
}
2929

30-
//启动上传服务
3130
try {
3231
Intent serviceIntent = new Intent(context, UpLoadService.class);
3332
context.startService(serviceIntent);

app/src/main/java/com/flir/flirone/networkhelp/UpLoadService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private boolean request(WebServiceCall call, ImageHelp imageHelp, ImageInfo imag
176176
public void onDestroy() {
177177
super.onDestroy();
178178

179-
Log.i("temp", "UpLoadService onDestroy");
179+
Log.i("upload", "UpLoadService onDestroy");
180180
}
181181

182182
@Override

app/src/main/java/com/flir/flirone/threshold/ThresholdHelp.java

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* Created by txiaozhe on 09/02/2017.
1515
*/
1616

17-
//需要设置阈值并保存,进入时读取保存的阈值并显示
1817

1918
public class ThresholdHelp {
2019

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.3'
8+
classpath 'com.android.tools.build:gradle:2.3.0'
99
// NOTE: Do not place your application dependencies here; they belong
1010
// in the individual module build.gradle files
1111
}

0 commit comments

Comments
 (0)