Jmeter beanshell: get variable type

Examples:

if (vars.get(“price_matchNr”) instanceof Integer){
log.info(“integer”);
}
if (vars.get(“price_matchNr”) instanceof String){
log.info(“string”);
}
if (Integer.parseInt(vars.get(“price_matchNr”)) instanceof int){
log.info(“int”);
}
if (Integer.valueOf(vars.get(“price_matchNr”)) instanceof Integer){
log.info(“Integer ValueOf”);
}

Tesseract initial setup

Install Tesseract:

sudo apt install tesseract-ocr

Install python3-pil

sudo apt-get install -y python3-pil

Insall pytesseract:

pip install pytesseract

Testing Tesseract.

Call the Tesseract engine on the image with image_path and convert image to text, written line by line in the command prompt by typing the following:

$ tesseract image_path stdout

To write the output text in a file:

$ tesseract image_path text_result.txt

To specify the language model name, write language shortcut after -l flag, by default it takes English language:

$ tesseract image_path text_result.txt -l eng

By default, Tesseract expects a page of text when it segments an image. If you’re just seeking to OCR a small region, try a different segmentation mode, using the –psm argument. There are 14 modes available which can be found here. By default, Tesseract fully automates the page segmentation but does not perform orientation and script detection. To specify the parameter, type the following:

$ tesseract image_path text_result.txt -l eng --psm 6

There is also one more important argument, OCR engine mode (oem). Tesseract 4 has two OCR engines — Legacy Tesseract engine and LSTM engine. There are four modes of operation chosen using the –oem option.
0    Legacy engine only.
1    Neural nets LSTM engine only.
2    Legacy + LSTM engines.
3    Default, based on what is available.

Adding Estonian language for ubuntu package:

sudo apt-get install tesseract-ocr-[lang]

Compiling Tesseract:

To run pytesseract in python script:

pip install pytesseract

Preprocessing for Tesseract

pip install opencv-python

To avoid all the ways your tesseract output accuracy can drop, you need to make sure the image is appropriately pre-processed.

This includes rescaling, binarization, noise removal, deskewing, etc.

To preprocess image for OCR, use any of the following python functions or follow the OpenCV documentation.

Improve quality of the output (Official doc)

Gradle “Could not resolve all dependencies for configuration ‘:classpath’.”

Running a gradle project, you may encounter the error below. In my case it occurs after the gradle project crashed, requiring a restart.

Error message:

>Could not resolve all dependencies for configuration ':classpath'.
 >Could not load module metadata from /home/username/.gradle/caches/modules-2/metadata-2.97/descriptors/io.netty/netty-common/4.1.23.Final/671a8ecc284f9e9f4d35b614eb5de66e/descriptor.bin

Solution:

You need to delete the cache

cd /home/username/.gradle
rm -r caches

Check if tensorflow is using the GPU

If you run tensorflow in a docker console you can run the following code in your terminal:

docker exec b61a27999cb8 python3 -c "import tensorflow as tf; tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))"

If you run a jupyter notebook you add the following line:

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

Data persistence with Docker and tensorflow.

https://docs.docker.com/storage/

https://docs.docker.com/storage/volumes/

https://stackoverflow.com/questions/57341455/how-to-persist-my-notebooks-and-data-in-my-docker-image-container

docker run -it -p 8888:8888 -v /home/personal/Documents/tensorflowData:/tf/notebooks tensorflow/tensorflow:latest-gpu-jupyter

Change SOURCE_FOLDER and DEST_FOLDER accordingly (use absolute paths!).

Now if you navigate to localhost:8888 and create a notebook on DEST_FOLDER, it also should be available on SOURCE_FOLDER.

For tensorflow 2, the destination folder is /tf. You can create a folder of your choice, say: notebook, where you will save your file in your jupyter notebook. Those files will be available in the SOURCE_FOLDER you have set.

The changes in tensorflow-tutorials won’t be kept even if you choose it as your destination folder. You have to use another folder as detailed above.

Jmeter: first line of a csv not read in a loop

One obvious reason for this to happen is that you set the “ignore first line” parameter to true.

The most likely case is that you used the csv in another request before your loop. This previous request is taken into account and the first line is considered already done when the loop starts.

If you call the csv three times in three separate requests before using it in a loop, the loop will starts at the fourth line of the csv (disregarding the column name line), even though only the first line was read in the first attempt.