Tag Archives: tool

How to Solve labelme Install Error in Ubuntu

Create a labelme environment using a virtual environment:

According to the official guidelines, link: GitHub – wkentaro/label: image polygon annotation with python (polygon, rectangle, circle, line, point and image level flag annotation)

conda create --name=labelme python=3
source activate labelme
pip install labelme

Question 1:

gcc -pthread -B /home/XXX/fxp/envs/labelme/compiler_compat -Wno-unused-
result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem 
/home/XXX/fxp/envs/labelme/include -fPIC -O2 -isystem 
/home/XXX/fxp/envs/labelme/include -fPIC -DFREETYPE_BUILD_TYPE=system -
DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -
DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -
Iextern/agg24-svn/include -I/home/XXX/fxp/envs/labelme/lib/python3.10/site-
packages/numpy/core/include -I/home/XXX/fxp/envs/labelme/include/python3.10
 -c src/checkdep_freetype2.c -o build/temp.linux-x86_64-cpython-
310/src/checkdep_freetype2.o
      src/checkdep_freetype2.c:3:6: error: #error "FreeType version 2.3 or higher 
is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let 
Matplotlib download it."
           #error "FreeType version 2.3 or higher is required. \

            ^~~~~
      src/checkdep_freetype2.c:10:10: error: #include expects "FILENAME" or 
<FILENAME>
       #include FT_FREETYPE_H
                ^~~~~~~~~~~~~
      src/checkdep_freetype2.c:15:9: note: #pragma message: Compiling with FreeType version FREETYPE_MAJOR.FREETYPE_MINOR.FREETYPE_PATCH.
       #pragma message("Compiling with FreeType version " \
               ^~~~~~~
      src/checkdep_freetype2.c:18:4: error: #error "FreeType version 2.3 or higher
 is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download it."
         #error "FreeType version 2.3 or higher is required. \
          ^~~~~
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with 
pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> matplotlib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Relevant dependent libraries need to be installed:

sudo apt-get update
sudo apt-get install libfreetype6-dev
sudo apt-get install pkg-config
sudo apt-get install libpng12-dev
sudo apt-get install pkg-config

Error 2 encountered:

labelme
[INFO   ] __init__:get_config:70 - Loading config file from: /home/XXX/.labelmerc
Traceback (most recent call last):
  File "/home/XXX/fxp/envs/labelme/lib/python3.10/site-packages/labelme/widgets/canvas.py", line 618, in paintEvent
    p.translate(self.offsetToCenter())
  File "/home/XXX/fxp/envs/labelme/lib/python3.10/site-packages/labelme/widgets/canvas.py", line 659, in offsetToCenter
    return QtCore.QPoint(x, y)
TypeError: arguments did not match any overloaded call:
  QPoint(): too many arguments
  QPoint(int, int): argument 1 has unexpected type 'float'
  QPoint(QPoint): argument 1 has unexpected type 'float'
Aborted (core dumped)

Reference link: https://github.com/wkentaro/labelme/issues/1006

I guess the python version is too high, so I recreated the virtual environment with pyhton = 3.9

conda create --prefix=/home/fxp/envs/labelme python=3.9 -y

The final installation is successful;

[Solved] Windows Start RocketMq Error: Unrecognized VM option ‘UseCMSCompactAtFullCollection‘

Rocketmq download address: downloading the Apache rocketmq releases – Apache rocketmq

Environment

system windows 10 64 bit
jdk version jdk11
RocketMQ version 5.0

question:

After downloading, unzip the package and start the cmd file, the following error message appears:

Solution:
1. Change the jdk version to below 9. Versions 9 and above are obsolete CMSCompactAtFullCollectionand cannot be supported.

2. Delete parameters not supported by jvm: open runserver.cmd to edit; or comment out this line.

There may be other unsupported classes: PrintGCDateStamps, PrintGCTimeStamps, etc. are all handled this way.

Unrecognized VM option ' <Option> '
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

There is also a list of 50 options that no longer work in JDK 9. Check that you are using these options on the command line and in the startup script:

  • AdjustConcurrency
  • CMSCompactWhenClearAllSoftRefs
  • CMSDumpAtPromotionFailure
  • CMSFullGCsBeforeCompaction
  • CMSIncrementalDutyCycle
  • CMSIncrementalDutyCycleMin
  • CMSIncrementalMode
  • CMSIncrementalOffset
  • CMSIncrementalPacing
  • CMSParPromoteBlocksToClaim
  • CMSPrintEdenSurvivorChunks
  • CollectGen0First
  • GCLogFileSize
  • NumberOfGCLogFiles
  • ParallelGCVerbose
  • PrintAdaptiveSizePolicy
  • PrintCMSInitiationStatistics
  • PrintCMSStatistics
  • PrintClassHistogramAfterFullGC
  • PrintClassHistogramBeforeFullGC
  • PrintFLSCensus
  • PrintFLSStatistics
  • PrintGCApplicationConcurrentTime
  • PrintGCApplicationStoppedTime
  • PrintGCCause
  • PrintGCDateStamps
  • PrintGCTaskTimeStamps
  • PrintGCTimeStamps
  • PrintHeapAtGC
  • PrintHeapAtGCExtended
  • PrintJNIGCStalls
  • PrintOldPLAB
  • PrintPLAB
  • PrintParallelOldGCPhaseTimes
  • PrintPromotionFailure
  • PrintReferenceGC
  • PrintTLAB
  • PrintTenuringDistribution
  • TraceDynamicGCThreads
  • TraceGen0Time
  • TraceGen1Time
  • TraceMetadataHumongousAllocation
  • TraceParallelOldGCTasks
  • UseCMSCollectionPassing
  • UseCMSCompactAtFullCollection
  • UseGCLogFileRotation
  • UseMemSetInBOT
  • UsePPCLWSYNC
  • UseVMInterruptibleIO
  • WorkAroundNPTLTimedWaitHang

Hutool Excel Import & Export Example

Download and generate excel template

Example code:

① Entity class of template:

@Getter
@Setter
@ToString
@SuperBuilder
@NoArgsConstructor
public class WsWorkerTemplate{
    @ApiModelProperty(value = "NAME")
    private String workerName;

    @ApiModelProperty(value = "Phone Number")
    private String workerPhone;
    
    @ApiModelProperty(value = "ID number")
    private String workerIdcard;
}

② Class to generate template:

    @ApiOperation("Download generated excel template")
    @GetMapping("/downloadExcel")
    public void downloadExcel(HttpServletResponse response) throws IOException {

        WsWorkerTemplate wsWorker = new WsWorkerTemplate();
//        wsWorker.setWorkerName("张三");
//        wsWorker.setWorkerPhone("15992714704");
//        wsWorker.setWorkerIdcard("130501197512158843");
        List<WsWorkerTemplate> rows = CollUtil.newArrayList(wsWorker);

        // Create writer by tool class, default create xls format
        ExcelWriter writer = ExcelUtil.getWriter();
        // custom header alias
        writer.addHeaderAlias("workerName", "Name");
        writer.addHeaderAlias("workerPhone", "mobile number");
        writer.addHeaderAlias("workerIdcard", "ID number");
        // merge the header row after the cell, using the default header style
        String content = "Instructions for filling out the form: \n\t" +
                "1, name: 2 to 15 Chinese characters; \n\t" +
                "2, cell phone number: 11-digit cell phone number format; \n\t" +
                "3, ID number: 18-bit second-generation ID number; \n\t";
        writer.merge(2,content,false);
        //set the column width
        writer.setColumnWidth(-1,30);

        writer.setRowHeight(0,80);
        // write the content at once, use the default style, and force the output headers
        writer.write(rows, true);
        //out is the OutputStream, the target stream to write out to
        // response is the HttpServletResponse object
        response.setContentType("application/vnd.ms-excel;charset=utf-8");
        //test.xls is the name of the file that pops up the download dialog box, it can't be Chinese, please encode it yourself
        //response.setHeader("Content-Disposition", "attachment;filename=test-file.xls");
        String excelName="worker.xls";
        // When setting response.setHeader, if it contains Chinese characters, it must be converted to ISO8859-1 format, otherwise the set Chinese will be incorrect.
        response.setHeader("content-disposition", "attachment;filename="+new String(excelName.getBytes("gb2312"), "ISO8859-1"));
        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        // Close the writer and free memory
        writer.close();
        // Remember to close the output servlet stream here
        IoUtil.close(out);
    }

excel import

 /**
     * Batch Import
     *
     * @param file
     * @return
     */
    public ResultObj<Object> importWorker(@RequestParam("file") MultipartFile file, String worksiteId) {
        ResultObj<Object> resultObj = new ResultObj<Object>();
        String message1 = "";
        List<String> strList = new LinkedList<>();
        List<WsWorker> list = new LinkedList<>();
        try {
            InputStream inputStream = file.getInputStream();
            list = getWsWorkerExcel(inputStream);
            if (list != null && list.size() > 0) {
                    for (WsWorker w : list) {
                        w.setWorksiteId(worksiteId);
                        w.setCheckResult(0);
                        wsWorkerMapper.insertSelective(w);
                    }
                    resultObj.setStatus(200);
                    resultObj.setMsg("import successfully");
              }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return resultObj;
    }

Get Excel data:

  public List<WsWorker> getWsWorkerExcel(InputStream inputStream) {

        ExcelReader reader = ExcelUtil.getReader(inputStream);
        reader.addHeaderAlias("Name", "workerName");
        reader.addHeaderAlias("Phone Number", "workerPhone");
        reader.addHeaderAlias("ID Number", "workerIdcard");

        List<WsWorker> workers = reader.read(1, 2, WsWorker.class);
        return workers;
    }

Base64 Image Compression Example

Compress picture size

@Log4j2
public class Base64Util {

    /**
     * Compressed images within 100k
     *
     * @param base64Img
     * @return
     */
    public static String resizeImageTo100K(String base64Img) {
        try {
            BufferedImage src = base64String2BufferedImage(base64Img);
            BufferedImage output = Thumbnails.of(src).size(src.getWidth()/3, src.getHeight()/3).asBufferedImage();
            String base64 = imageToBase64(output);
            if (base64.length() - base64.length()/8 * 2 > 40000) {
                output = Thumbnails.of(output).scale(1/(base64.length()/40000)).asBufferedImage();
                base64 = imageToBase64(output);
            }
            return base64;
        } catch (Exception e) {
            return base64Img;
        }
    }


    /**
     * base64 convert to BufferedImage
     *
     * @param base64string
     * @return
     */
    public static BufferedImage base64String2BufferedImage(String base64string) {
        BufferedImage image = null;
        try {
            InputStream stream = BaseToInputStream(base64string);
            image = ImageIO.read(stream);
        } catch (IOException e) {
            log.info("");
        }
        return image;
    }

    /**
     * Base64 convert to InputStream
     *
     * @param base64string
     * @return
     */
    private static InputStream BaseToInputStream(String base64string) {
        ByteArrayInputStream stream = null;
        try {
            BASE64Decoder decoder = new BASE64Decoder();
            byte[] bytes1 = decoder.decodeBuffer(base64string);
            stream = new ByteArrayInputStream(bytes1);
        } catch (Exception e) {
            // TODO: handle exception
        }
        return stream;
    }

    /**
     * BufferedImage switch to base64
     *
     * @param bufferedImage
     * @return
     */
    public static String imageToBase64(BufferedImage bufferedImage) {
        Base64 encoder = new Base64();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ImageIO.write(bufferedImage, "jpg", baos);
        } catch (IOException e) {
            log.info("");
        }
        return new String(encoder.encode((baos.toByteArray())));
    }

}

[Solved] Ubuntu: su Switch root Error: Authentication failure

[Ubuntu] solve the problem of error reporting when switching root with Su: authentication failure user authentication failure

Question:

Authentication failure occurs when Ubuntu uses Su to switch root. Authentication fails

Error reporting reason:

Because the Ubuntu system does not activate the root user by default, you need to activate it manually and then use the Su command

Solution:

Enter the following code to set the root password

sudo passwd root

[Solved] Toad Set Error: The following files specified on the Executables tab could not be found:TNS Ping

Today, when the toad adjustment setting of the software is completed, click OK to always report
error: the following files specified on the executables tab could not be found: TNS Ping, as shown in the following figure

in fact, it is mainly caused by the setting problems in other places in the option, here we just need to modify the setting,
Select View toad options editor executables TNS Ping. Then check whether the path of your own command in the figure below is correct, or you can directly click the “auto search” button to automatically obtain the correct path

After that, click OK in other options in toad, and no error will be reported.

[Solved] Error:java: Compilation failed: internal java compiler error 解决办法

Problem: Error:java: Compilation failed: internal java compiler error Solution
Solution: Inconsistent settings in the JDK development tools.
1, check the project jdk (Ctrl+Alt+shift+S)
File ->Project Structure->Project Settings ->Project

2、View the jdk of the project (Ctrl+Alt+shift+S)
File ->Project Structure->Project Settings -> Modules -> (need to modify the name of the project) -> Sources ->

3、View Java configuration in idea
File ->Setting ->Build,Execution,Deployment -> Compiler -> Java Compiler

If the above three steps still fail
Clear IDEA cache Restart IDEA

File->Invalidate Caches/Restart

[Solved] Android gradle Error: gradle project sync failed. Please fix your project and try again

Another error was reported during Android development. This is a version error. The first step is to synchronize the versions
error message:
Android studio error: gradle project sync failed. Please fix your project and try again

1. Version synchronization:

1.1 file> sync project with android gradle

If you succeed, you don’t have to look at the following

1.2 error reporting:

It can be seen or not solved:

It should be the version problem. If we can’t download it, we can download it directly manually (check the network first, and the agent has no problem, but it still can’t be solved)

2. Modify proxy parameters:

Agent:

2.1 open file> setting> Search proxy

2.2 configuration information

The address and port of the agent shall be filled in as follows:

URL: http://127.0.0.1:1080/pac

2.3 check whether the Ping is connected

    1. use check connection

      1. enter a website to test: www.baidu.com, and then test: </ OL>

Still not!

3. Manual Download

So let’s continue:

3.1 open the gradle wrapper properties file

3.2 download

Download the gradle in the last line of the website. Note that the version must be consistent. Download whatever he puts down.

3.3 modifying environment variables

Remember to modify the gradle environment variable in the computer:

        1. system environment variable:

          1. path:

3.4 modify the compilation environment configuration

Then unzip it, modify the gradle configuration in the environment, and it’s OK.

You can see that my environment is OK now:

Node Error: Error: Multipart: Boundary not found [How to Solve]

The front end uses httpclient in the angular library to upload files and set

headers: { ‘Content-Type’: ‘multipart/form-data’ }

When the backend uses featurejs to receive, an error is reported

error: multipart: boundary not found
error reason: multipart does not find the boundary

The uploaded file is a form in multipart/form data format of post request

content-type: multipart/form-data is not followed by the boundary

To sum up, the request header was set many times, overwriting the original form enctype = “multipart/form data”

Conclusion: it is not necessary to set content type: Music/form data repeatedly, otherwise the original may be overwritten and unexpected errors may be caused.


Correct way to get headers:

When uploading formdata type data, you do not need to manually set content typebrowser performance:

it’s done!