Python Forum
How to fix statement seems to have no effect
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to fix statement seems to have no effect
#1
Hi, i know there are similar questions but they didn't solve my problem. I have been trying to read brightness of my webcam using OpenCV and QT. I have tried to implement my codes on 3 different files (main,view,model). I created get_brightness in models.py and i call it on views.py but i see statement has no effect warning, and print_brightness never works.

main.py
from PyQt5.QtWidgets import QApplication from views import UI_Window from models import Camera if __name__ == '__main__': #hangi dosyaya sag tiklayip Run dersek o dosya main oluyor. eger dosya main ise kosul saglanmis oluyor. camera = Camera(0) #0, webcam numarasi app = QApplication([]) start_window = UI_Window(camera) start_window.show() app.exit(app.exec_())
views.py

from PyQt5.QtCore import QThread, QTimer from PyQt5.QtWidgets import QLabel, QWidget, QPushButton, QVBoxLayout, QApplication, QHBoxLayout, QMessageBox, QMainWindow from PyQt5.QtGui import QPixmap, QImage from models import Camera class UI_Window(QWidget): def __init__(self, cam_num): super().__init__() self.cam_num = cam_num self.cam_num.open() # Create a timer. self.timer = QTimer() self.timer.timeout.connect(self.nextFrameSlot) self.timer.start(1000. / 24) self.print_brightness def nextFrameSlot(self): frame = self.cam_num.read() if frame is not None: image = QImage(frame, frame.shape[1], frame.shape[0], QImage.Format_RGB888) #	The image is stored using a 24-bit RGB format (8-8-8). self.pixmap = QPixmap.fromImage(image) def print_brightness(self): print(Camera.get_brightness())
models.py

import cv2 class Camera: def __init__(self, cam_num): self.cap = cv2.VideoCapture(cam_num) self.cam_num = cam_num def open(self, width=640, height=480, fps=30): # vc.set(5, fps) #set FPS self.cap.set(3, width) # set width #propID =3 yani 3.property si width. 3.property i 480 yap self.cap.set(4, height) # set height return self.cap.isOpened() def read(self): rval, frame = self.cap.read() frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) return frame def get_brightness(self): return self.cap.get(cv2.CAP_PROP_BRIGHTNESS)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  help seeking for prediction of fixed effect model gotodockforevildragon 0 1,353 Jun-18-2024, 04:10 AM
Last Post: gotodockforevildragon
Bug Copying methods to effect the new owner instead of the old instance Daniel285 2 1,481 Jun-03-2024, 07:58 AM
Last Post: Gribouillis
  Printing effect sizes for variables in an anova eyavuz21 2 2,264 Feb-01-2023, 02:12 PM
Last Post: eyavuz21
  Help with TypeWriter Effect in Python Rich Extra 0 2,418 May-23-2022, 09:44 PM
Last Post: Extra
  Rotation Effect on live Webcam Feed Leziiy 0 2,450 Sep-12-2020, 04:25 PM
Last Post: Leziiy
  strange effect from duplicating a file descriptor Skaperen 1 3,119 Feb-18-2019, 08:20 PM
Last Post: Skaperen
  Algorithm effect on the CPU Faruk 3 3,957 Dec-19-2018, 08:57 AM
Last Post: Faruk
  "Statement has no effect" birdieman 21 24,391 Jan-27-2017, 02:59 AM
Last Post: Larz60+

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.